!/*****************************************************************************/1! *2! * Elmer, A Finite Element Software for Multiphysical Problems3! *4! * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland5! *6! * This library is free software; you can redistribute it and/or7! * modify it under the terms of the GNU Lesser General Public8! * License as published by the Free Software Foundation; either9! * version 2.1 of the License, or (at your option) any later version.10! *11! * This library is distributed in the hope that it will be useful,12! * but WITHOUT ANY WARRANTY; without even the implied warranty of13! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14! * Lesser General Public License for more details.15! *16! * You should have received a copy of the GNU Lesser General Public17! * License along with this library (in file ../LGPL-2.1); if not, write18! * to the Free Software Foundation, Inc., 51 Franklin Street,19! * Fifth Floor, Boston, MA 02110-1301 USA20! *21! *****************************************************************************/2223#include "huti_fdefs.h"2425!> \ingroup ElmerLib26!------------------------------------------------------------------------------27SUBROUTINE MultigridPrec( u,v,ipar )28!------------------------------------------------------------------------------29USE Multigrid3031INTEGER, DIMENSION(*) :: ipar !< structure holding info from (HUTIter-iterative solver package)32REAL(KIND=dp), TARGET :: u(*)33REAL(KIND=dp), TARGET :: v(*)3435INTEGER :: i,j,k,me,n, DOFs36TYPE(Solver_t), POINTER :: PSolver3738TYPE(Matrix_t), POINTER :: A39REAL(KIND=dp), POINTER CONTIG :: x(:),b(:)4041CALL Info('MultigridPrec','Starting Multigrid preconditioning cycle',Level=12)4243PSolver => CurrentModel % Solver4445n = HUTI_NDIM46IF ( PSolver % Matrix % COMPLEX ) n=2*n4748x => u(1:n)49b => v(1:n)50A => GlobalMatrix5152IF ( ParEnv % PEs > 1 ) THEN53A => GlobalMatrix % EMatrix54n = A % NumberOfRows55ALLOCATE( x(n), b(n) )56x=0; b=0;5758j = 059me = ParEnv % MyPe60DO i=1,n61IF ( A % ParallelInfo % NeighbourList(i) % Neighbours(1) == me ) THEN62j = j + 163b(i) = v(j)64END IF65END DO66END IF6768DOFs = PSolver % Variable % DOFs69x = b70CALL MultiGridSolve( A, x, b, &71DOFs, PSolver, PSolver % MultiGridLevel, FirstCall(stack_pos))7273IF ( ParEnv % PEs > 1 ) THEN74j = 075DO i=1,n76IF ( A % ParallelInfo % NeighbourList(i) % Neighbours(1) == me ) THEN77j = j + 178u(j) = x(i)79END IF80END DO81DEALLOCATE( x,b )82END IF8384FirstCall(stack_pos) = .FALSE.8586CALL Info('MultigridPrec','Done multigrid preconditioning cycle',Level=12)8788END SUBROUTINE MultigridPrec89!------------------------------------------------------------------------------909192