Scrambler
1
|
00001 !######################################################################### 00002 ! 00003 ! Copyright (C) 2003-2012 Department of Physics and Astronomy, 00004 ! University of Rochester, 00005 ! Rochester, NY 00006 ! 00007 ! elliptic_declarations.f90 is part of AstroBEAR. 00008 ! 00009 ! AstroBEAR is free software: you can redistribute it and/or modify 00010 ! it under the terms of the GNU General Public License as published by 00011 ! the Free Software Foundation, either version 3 of the License, or 00012 ! (at your option) any later version. 00013 ! 00014 ! AstroBEAR is distributed in the hope that it will be useful, 00015 ! but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ! GNU General Public License for more details. 00018 ! 00019 ! You should have received a copy of the GNU General Public License 00020 ! along with AstroBEAR. If not, see <http://www.gnu.org/licenses/>. 00021 ! 00022 !######################################################################### 00025 00029 00032 MODULE EllipticDeclarations 00033 USE GlobalDeclarations 00034 USE PhysicsDeclarations 00035 ! USE DataLevelComms 00036 ! USE CommunicationControl 00037 IMPLICIT NONE 00038 PUBLIC 00039 SAVE 00040 00042 TYPE EllipticLevelObjectDef 00043 SEQUENCE 00044 INTEGER(8) :: Matrix !This should be persistent over two time steps by level 00045 INTEGER(8) :: Solver ! These are locally created and destroyed by level 00046 INTEGER(8) :: VariableVector !These are locally created and destroyed and don't need to be stored by level 00047 INTEGER(8) :: SolutionVector !These are locally created and destroyed and don't need to be stored by level 00048 END TYPE EllipticLevelObjectDef 00049 00051 TYPE EllipticObjectDef 00052 SEQUENCE 00053 TYPE(EllipticLevelObjectDef), DIMENSION(:), ALLOCATABLE :: LevelObjects 00054 REAL(8) :: tolerance=1e-6 ! convergence tolerance 00055 INTEGER(8) :: Stencil ! This should be constant over all levels and does not need to be in 00056 INTEGER :: Interface ! type of HYPRE interface 00057 INTEGER :: solver=1 ! type of HYPRE solver 00058 INTEGER :: printLevel ! verbosity 00059 INTEGER :: maxIters=1000 ! maximum number of iterations 00060 INTEGER :: hVerbosity=0 ! how verbose user-side HYPRE should be 00061 END TYPE EllipticObjectDef 00062 00063 00064 TYPE(EllipticObjectDef), DIMENSION(:), POINTER :: EllipticObjects 00065 00066 INTEGER,PARAMETER,PUBLIC :: StructInterface=1,SStructInterface=2 00067 INTEGER,PARAMETER,PUBLIC :: StructPCG=1, StructGMRES=2 00068 00069 INTEGER :: NrEllipticObjects, iPoissonSolve 00070 00071 LOGICAL :: lPoissonSolve 00072 REAL(KIND=qPREC), DIMENSION(:), ALLOCATABLE :: elliptic_maxspeed 00073 00074 INTEGER :: nEllipticLo, nEllipticHi ! Elliptic indices 00075 INTEGER :: NrEllipticVars=0 00076 00077 INTEGER, PARAMETER :: MAXELLIPTICLENGTH = 20 00078 INTEGER, PARAMETER :: MAXELLIPTICVARS=40 00079 00080 CHARACTER(LEN = MAXELLIPTICLENGTH), DIMENSION(0:MAXELLIPTICVARS) :: EllipticNames 00081 00082 00083 CONTAINS 00084 00088 00089 SUBROUTINE AddElliptic(i, str) 00090 INTEGER :: i 00091 CHARACTER(LEN=*), OPTIONAL :: str 00092 i=nEllipticLo+NrEllipticVars 00093 NrEllipticVars=NrEllipticVars+1 00094 IF (NrEllipticVars <= MaxEllipticVars) THEN 00095 IF (Present(str)) THEN 00096 EllipticNames(NrEllipticVars)=str(1:min(len(str), len(EllipticNames(NrEllipticVars)))) 00097 ELSE 00098 write(EllipticNames(NrEllipticvars), '(A10I3.3)') 'Elliptic', NrEllipticVars 00099 END IF 00100 ELSE 00101 IF (MPI_ID == 0) THEN 00102 PRINT*, 'Warning: Unable to store name of elliptic variable without increasing MaxElliptics in processing_declarations.f90' 00103 END IF 00104 END IF 00105 END SUBROUTINE AddElliptic 00106 00109 FUNCTION EllipticName(i) 00110 INTEGER :: i 00111 CHARACTER(LEN=MAXELLIPTICLENGTH) :: EllipticName 00112 00113 IF (i <= MaxEllipticVars) THEN 00114 EllipticName=EllipticNames(i) 00115 ELSE 00116 write(EllipticName, '(A10I3.3)') 'Elliptic', NrEllipticVars 00117 END IF 00118 00119 END FUNCTION EllipticName 00120 00124 SUBROUTINE CheckErr(errString,iErr) 00125 CHARACTER(*) :: errString 00126 INTEGER :: iErr 00127 CHARACTER(LEN=1000) :: description 00128 IF(iErr/=0 .AND. .NOT. lRequestRestart) THEN 00129 PRINT'(A,I5,A,A)','*** HYPRE returned an error on ',MPI_id,' at ',errString 00130 PRINT'(A,I8)',' with error code ',iErr 00131 ! CALL Hypre_DescribeError(ierr, description) 00132 ! write(*,*) description 00133 ! STOP 00134 IF (.NOT. lRequestRestart) THEN 00135 PRINT*, 'Processor', MPI_ID, 'requesting restart' 00136 END IF 00137 lRequestRestart=.true. 00138 END IF 00139 END SUBROUTINE CheckErr 00140 00141 SUBROUTINE CheckIters(n,m) 00142 INTEGER :: n,m 00143 IF (n == m) THEN 00144 IF (MPI_ID == 0) write(*,*) 'maximum # of iterations reached by hyper solve' 00145 IF (lRestartOnHypreMaxIters) THEN 00146 IF (MPI_ID == 0) write(*,*) 'requesting restart' 00147 lRequestRestart=.true. 00148 END IF 00149 ! ELSE 00150 ! IF (MPI_ID == 0) write(*,*) 'took ', n, 'out of ', m, 'iterations' 00151 END IF 00152 END SUBROUTINE CheckIters 00153 END MODULE EllipticDeclarations