Scrambler  1
MTI/problem.f90
Go to the documentation of this file.
00001 !#########################################################################
00002 !               
00003 !    Copyright (C) 2003-2012 Department of Physics and Astronomy,
00004 !                            University of Rochester,
00005 !                            Rochester, NY
00006 !
00007 !    problem.f90 of module MTI 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 !#########################################################################
00023 MODULE Problem
00024 
00025   USE DataDeclarations
00026   USE GlobalDeclarations
00027   USE PhysicsDeclarations
00028   USE Refinements
00029   USE Shapes
00030  ! USE IFPORT
00031   IMPLICIT NONE
00032   PRIVATE
00033   
00034   PUBLIC ProblemModuleInit, ProblemGridInit, &
00035        ProblemBeforeStep, ProblemAfterStep, ProblemSetErrFlag, ProblemBeforeGlobalStep
00036 
00037   INTEGER :: nmodex, nmodey, bc
00038   REAL(KIND=qPrec) :: rho0, p0, y0, v0, B0, B_static, lx
00039   INTEGER, PARAMETER :: MTI_FILEHANDLE = 32
00040 CONTAINS
00041 
00042 
00043   SUBROUTINE ProblemModuleInit
00044     !! @brief Reads the problem data file and performs a quick sanity check on the parameters.
00045     INTEGER :: iErr
00046 
00047                 
00048   END SUBROUTINE ProblemModuleInit
00049 
00050 
00051   SUBROUTINE ProblemGridInit(Info)
00052         !! @brief Initializes the grid data according to the requirements of the problem.
00053         !! @param Info A grid structure.        
00054     TYPE (InfoDef) :: Info
00055     INTEGER :: i,j,k,iErr
00056     INTEGER :: rmbc,zrmbc
00057     INTEGER :: mx, my, mz
00058     REAL(KIND=qPrec) :: dx,rho,p,vy,pos(3)
00059     !NAMELIST /ProblemData/ rho0,rho1,r0,t0,t1,B0x,B0y
00060       
00061     rmbc = levels(Info%level)%gmbc(1)!CoarsenRatio(Info%level-1) * mbc
00062 
00063     IF(nDim==2)THEN
00064        zrmbc=0
00065     ELSE
00066        zrmbc=rmbc
00067     END IF
00068 
00069     Info%q=0d0;Info%aux=0d0
00070     mx=Info%mX(1); my=Info%mX(2); mz=Info%mX(3); dx=levels(Info%level)%dx
00071 
00072     pos=0d0; Info%q(:,:,:,:)=0d0
00073     DO k=1-zrmbc,mz+zrmbc; DO j=1-rmbc,my+rmbc; DO i=1-rmbc, mx+rmbc
00074        pos=Info%xBounds(1:3,1)+(/REAL(i,8)-1.,REAL(j,8)-1.,REAL(k,8)-1./)*levels(Info%level)%dx
00075        rho = rho0*(1d0-pos(2)/y0)**2
00076        p = p0*(1d0-pos(2)/y0)**3
00077        vy = v0*sin(real(nmodex)*pi*pos(1)/lx)
00078        Info%q(i,j,k,1) = rho
00079        Info%q(i,j,k,3) = rho*vy
00080        Info%q(i,j,k,iBx) = B0
00081        Info%q(i,j,k,iE) = p/(gamma-1d0)+0.5*rho*vy**2+0.5*B0**2
00082        
00083     END DO; END DO; END DO
00084 
00085     IF (MaintainAuxArrays) THEN
00086        DO i=1-rmbc+1,mx+rmbc; DO j=1-rmbc,my+rmbc; DO k=1-zrmbc,mz+zrmbc
00087          Info%aux(i,j,k,1)=.5*(Info%q(i-1,j,k,iBx)+Info%q(i,j,k,iBx))
00088        END DO; END DO; END DO
00089        DO i=1-rmbc,mx+rmbc; DO j=1-rmbc+1,my+rmbc; DO k=1-zrmbc,mz+zrmbc
00090          Info%aux(i,j,k,2)=.5*(Info%q(i,j-1,k,iBy)+Info%q(i,j,k,iBy))
00091        END DO; END DO; END DO
00092        IF(nDim==3)THEN
00093           DO i=1-rmbc,mx+rmbc; DO j=1-rmbc,my+rmbc; DO k=1-zrmbc+1,mz+zrmbc
00094              Info%aux(i,j,k,3)=.5*(Info%q(i,j,k-1,iBz)+Info%q(i,j,k,iBz))
00095           END DO; END DO; END DO
00096        END IF
00097     END IF
00098 
00099   END SUBROUTINE ProblemGridInit
00100 
00101   SUBROUTINE ProblemBeforeStep(Info)
00102         !! @brief Performs any tasks required before the advance step.
00103         !! @param Info A grid structure.        
00104     TYPE (InfoDef) :: Info
00105     INTEGER :: i,j
00106     INTEGER :: rmbc
00107     INTEGER :: mx,my
00108     INTEGER :: iErr
00109 
00110   END SUBROUTINE ProblemBeforeStep
00111 
00112   SUBROUTINE ProblemAfterStep(Info)
00113         !! @brief Performs any post-step corrections that are required.
00114         !! @param Info A grid structure.        
00115     TYPE (InfoDef) :: Info
00116   END SUBROUTINE ProblemAfterStep
00117 
00118   SUBROUTINE ProblemSetErrFlag(Info)
00119         !! @brief Sets error flags according to problem-specific conditions..
00120         !! @param Info A grid structure.        
00121     TYPE (InfoDef) :: Info
00122   END SUBROUTINE ProblemSetErrFlag
00123 
00124   SUBROUTINE ProblemBeforeGlobalStep(n)
00125     INTEGER :: n
00126   END SUBROUTINE ProblemBeforeGlobalStep
00127 
00128 END MODULE Problem
 All Classes Files Functions Variables