boundary_reflecting.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: boundary_reflecting.f90 #
5!# #
6!# Copyright (C) 2006-2014 #
7!# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
8!# #
9!# This program is free software; you can redistribute it and/or modify #
10!# it under the terms of the GNU General Public License as published by #
11!# the Free Software Foundation; either version 2 of the License, or (at #
12!# your option) any later version. #
13!# #
14!# This program is distributed in the hope that it will be useful, but #
15!# WITHOUT ANY WARRANTY; without even the implied warranty of #
16!# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
17!# NON INFRINGEMENT. See the GNU General Public License for more #
18!# details. #
19!# #
20!# You should have received a copy of the GNU General Public License #
21!# along with this program; if not, write to the Free Software #
22!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
23!# #
24!#############################################################################
25
26!----------------------------------------------------------------------------!
33!----------------------------------------------------------------------------!
39 USE common_dict
40 IMPLICIT NONE
41 !--------------------------------------------------------------------------!
42 PRIVATE
45 LOGICAL, DIMENSION(:), ALLOCATABLE :: reflx,refly,reflz
46 CONTAINS
48 PROCEDURE :: setboundarydata
49 PROCEDURE :: finalize
50 END TYPE boundary_reflecting
51 CHARACTER(LEN=32), PARAMETER :: boundcond_name = "reflecting"
52 !--------------------------------------------------------------------------!
53 PUBLIC :: &
55 !--------------------------------------------------------------------------!
56
57CONTAINS
58 !TODO: NOT VERIFIED
60 SUBROUTINE initboundary_reflecting(this,Mesh,Physics,dir,config)
61 IMPLICIT NONE
62 !------------------------------------------------------------------------!
63 CLASS(boundary_reflecting), INTENT(INOUT) :: this
64 CLASS(physics_base), INTENT(IN) :: Physics
65 CLASS(mesh_base), INTENT(IN) :: Mesh
66 TYPE(dict_typ), POINTER, INTENT(IN) :: config
67 INTEGER, INTENT(IN) :: dir
68 !------------------------------------------------------------------------!
69 INTEGER :: err
70 !------------------------------------------------------------------------!
71 CALL this%InitBoundary(mesh,physics,reflecting,boundcond_name,dir,config)
72
73 ALLOCATE( &
74 this%reflX(physics%VNUM), &
75 this%reflY(physics%VNUM), &
76 this%reflZ(physics%VNUM), &
77 stat=err)
78 IF (err.NE.0) THEN
79 CALL this%Error("InitBoundary_reflecting", "Unable to allocate memory.")
80 END IF
81 ! this tells us which vars get the opposite sign/vanish at cell faces;
82 ! e.g. vertical velocities (depends on the underlying physics)
83 CALL physics%ReflectionMasks(mesh,this%reflX,this%reflY,this%reflZ)
84 END SUBROUTINE initboundary_reflecting
85
89 SUBROUTINE setboundarydata(this,Mesh,Physics,time,pvar)
90 IMPLICIT NONE
91 !------------------------------------------------------------------------!
92 CLASS(boundary_reflecting), INTENT(INOUT) :: this
93 CLASS(mesh_base), INTENT(IN) :: Mesh
94 CLASS(physics_base), INTENT(IN) :: Physics
95 REAL, INTENT(IN) :: time
96 CLASS(marray_compound), INTENT(INOUT) :: pvar
97 !------------------------------------------------------------------------!
98 INTEGER :: i,j,k,m
99 !------------------------------------------------------------------------!
100 SELECT CASE(this%direction%GetType())
101 CASE(west)
102!NEC$ SHORTLOOP
103 DO m=1,physics%VNUM
104 IF (this%reflX(m)) THEN
105!NEC$ SHORTLOOP
106 DO i=1,mesh%GINUM
107 pvar%data4d(mesh%IMIN-i,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m) &
108 = -pvar%data4d(mesh%IMIN+i-1,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m)
109 END DO
110 ELSE
111!NEC$ SHORTLOOP
112 DO i=1,mesh%GINUM
113 pvar%data4d(mesh%IMIN-i,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m) &
114 = pvar%data4d(mesh%IMIN+i-1,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m)
115 END DO
116 END IF
117 END DO
118 CASE(east)
119!NEC$ SHORTLOOP
120 DO m=1,physics%VNUM
121 IF (this%reflX(m)) THEN
122!NEC$ SHORTLOOP
123 DO i=1,mesh%GINUM
124 pvar%data4d(mesh%IMAX+i,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m) &
125 = -pvar%data4d(mesh%IMAX-i+1,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m)
126 END DO
127 ELSE
128!NEC$ SHORTLOOP
129 DO i=1,mesh%GINUM
130 pvar%data4d(mesh%IMAX+i,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m) &
131 = pvar%data4d(mesh%IMAX-i+1,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,m)
132 END DO
133 END IF
134 END DO
135 CASE(south)
136!NEC$ SHORTLOOP
137 DO m=1,physics%VNUM
138 IF (this%reflY(m)) THEN
139!NEC$ SHORTLOOP
140 DO j=1,mesh%GJNUM
141 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN-j,mesh%KMIN:mesh%KMAX,m) &
142 = -pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN+j-1,mesh%KMIN:mesh%KMAX,m)
143 END DO
144 ELSE
145!NEC$ SHORTLOOP
146 DO j=1,mesh%GJNUM
147 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN-j,mesh%KMIN:mesh%KMAX,m) &
148 = pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN+j-1,mesh%KMIN:mesh%KMAX,m)
149 END DO
150 END IF
151 END DO
152 CASE(north)
153!NEC$ SHORTLOOP
154 DO m=1,physics%VNUM
155 IF (this%reflY(m)) THEN
156!NEC$ SHORTLOOP
157 DO j=1,mesh%GJNUM
158 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMAX+j,mesh%KMIN:mesh%KMAX,m) &
159 = -pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMAX-j+1,mesh%KMIN:mesh%KMAX,m)
160 END DO
161 ELSE
162!NEC$ SHORTLOOP
163 DO j=1,mesh%GJNUM
164 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMAX+j,mesh%KMIN:mesh%KMAX,m) &
165 = pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMAX-j+1,mesh%KMIN:mesh%KMAX,m)
166 END DO
167 END IF
168 END DO
169 CASE(bottom)
170!NEC$ SHORTLOOP
171 DO m=1,physics%VNUM
172 IF (this%reflZ(m)) THEN
173!NEC$ SHORTLOOP
174 DO k=1,mesh%GKNUM
175 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN-k,m) &
176 = -pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN+k-1,m)
177 END DO
178 ELSE
179!NEC$ SHORTLOOP
180 DO k=1,mesh%GKNUM
181 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN-k,m) &
182 = pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN+k-1,m)
183 END DO
184 END IF
185 END DO
186 CASE(top)
187!NEC$ SHORTLOOP
188 DO m=1,physics%VNUM
189 IF (this%reflZ(m)) THEN
190!NEC$ SHORTLOOP
191 DO k=1,mesh%GKNUM
192 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMAX+k,m) &
193 = -pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMAX-k+1,m)
194 END DO
195 ELSE
196!NEC$ SHORTLOOP
197 DO k=1,mesh%GKNUM
198 pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMAX+k,m) &
199 = pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMAX-k+1,m)
200 END DO
201 END IF
202 END DO
203 END SELECT
204 END SUBROUTINE setboundarydata
205
207 SUBROUTINE finalize(this)
208 IMPLICIT NONE
209 !------------------------------------------------------------------------!
210 CLASS(boundary_reflecting), INTENT(INOUT) :: this
211 !------------------------------------------------------------------------!
212 DEALLOCATE(this%reflX,this%reflY,this%reflZ)
213 CALL this%Finalize_base()
214 END SUBROUTINE finalize
215
216 END MODULE boundary_reflecting_mod
integer, parameter reflecting
reflecting, i.e. wall
Boundary module for reflecting boundaries.
character(len=32), parameter boundcond_name
subroutine initboundary_reflecting(this, Mesh, Physics, dir, config)
Constructor for reflecting boundary conditions.
subroutine setboundarydata(this, Mesh, Physics, time, pvar)
Applies the reflecting boundary condition.
subroutine finalize(this)
Destructor for reflecting boundary conditions.
Dictionary for generic data types.
Definition: common_dict.f90:61
derived class for compound of mesh arrays
basic mesh module
Definition: mesh_base.f90:72
integer, parameter east
named constant for eastern boundary
Definition: mesh_base.f90:101
integer, parameter bottom
named constant for bottom boundary
Definition: mesh_base.f90:101
integer, parameter south
named constant for southern boundary
Definition: mesh_base.f90:101
integer, parameter top
named constant for top boundary
Definition: mesh_base.f90:101
integer, parameter north
named constant for northern boundary
Definition: mesh_base.f90:101
integer, parameter west
named constant for western boundary
Definition: mesh_base.f90:101
Basic physics module.
mesh data structure
Definition: mesh_base.f90:122