boundary_base.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: boundary_generic.f90 #
5!# #
6!# Copyright (C) 2006-2018 #
7!# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
8!# Manuel Jung <mjung@astrophysik.uni-kiel.de> #
9!# Jannes Klee <jklee@astrophysik.uni-kiel.de> #
10!# #
11!# This program is free software; you can redistribute it and/or modify #
12!# it under the terms of the GNU General Public License as published by #
13!# the Free Software Foundation; either version 2 of the License, or (at #
14!# your option) any later version. #
15!# #
16!# This program is distributed in the hope that it will be useful, but #
17!# WITHOUT ANY WARRANTY; without even the implied warranty of #
18!# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
19!# NON INFRINGEMENT. See the GNU General Public License for more #
20!# details. #
21!# #
22!# You should have received a copy of the GNU General Public License #
23!# along with this program; if not, write to the Free Software #
24!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
25!# #
26!#############################################################################
35!----------------------------------------------------------------------------!
39!----------------------------------------------------------------------------!
45 USE common_dict
46#ifdef PARALLEL
47#ifdef HAVE_MPI_MOD
48 USE mpi
49#endif
50#endif
51 IMPLICIT NONE
52#ifdef PARALLEL
53#ifdef HAVE_MPIF_H
54 include 'mpif.h'
55#endif
56#endif
57 !--------------------------------------------------------------------------!
58 PRIVATE
59 TYPE, ABSTRACT, EXTENDS(logging_base) :: boundary_base
61 CLASS(logging_base), ALLOCATABLE :: direction
62! INTEGER :: IMID, & !< i index of cell in the middle
63! JMID, & !< j index of cell in the middle
64! KMID, & !< j index of cell in the middle
65! nohdim !< dimension of Noh problem
66! LOGICAL :: first_call !< used in far-field bc
67! REAL, DIMENSION(:,:,:), POINTER :: invr, & !< inverse distance to center
68! Rinv, & !< Riemann invariants at the boundary
69! RinvInf !< far field Riemann invariants
70#ifdef PARALLEL
71
72 REAL, DIMENSION(:,:,:,:), POINTER :: sendbuf, & !< send buffer for boundary data
73 recvbuf
74#endif
75 CONTAINS
76 PROCEDURE :: initboundary
77 procedure(setboundarydata), DEFERRED :: setboundarydata
78 PROCEDURE :: finalize_base
79 procedure(finalize), DEFERRED :: finalize
80 PROCEDURE :: getdirection
81 END TYPE boundary_base
82
83 ! exclude interface block from doxygen processing
85 abstract INTERFACE
86 SUBROUTINE setboundarydata(this,Mesh,Physics,time,pvar)
88 IMPLICIT NONE
89 CLASS(boundary_base), INTENT(INOUT) :: this
90 CLASS(mesh_base), INTENT(IN) :: mesh
91 CLASS(physics_base), INTENT(IN) :: physics
92 REAL, INTENT(IN) :: time
93 CLASS(marray_compound), INTENT(INOUT) :: pvar
94 END SUBROUTINE
95 SUBROUTINE finalize(this)
96 IMPORT boundary_base
97 IMPLICIT NONE
98 CLASS(boundary_base),INTENT(INOUT) :: this
99 END SUBROUTINE
100 END INTERFACE
102 !--------------------------------------------------------------------------!
104 CHARACTER(LEN=32), DIMENSION(6), PARAMETER :: &
105 direction_name = (/' west', ' east', ' south', ' north', 'bottom', ' top' /)
106
107#ifdef PARALLEL
108 INTEGER, PARAMETER :: none = 0
109#endif
110 INTEGER, PARAMETER :: &
111 no_gradients = int(z'01'), &
112 periodic = int(z'02'), &
113 reflecting = int(z'03'), &
114 axis = int(z'04'), &
115! FOLDED = INT(Z'05'), & !< cuts boundary in half and connects
116! !< the two parts (not supported in parallel mode)
117 fixed = int(z'06'), &
118 extrapolation = int(z'07'), &
119! NOH2D = INT(Z'08'), & !< time-dependent inflow for 2D Noh problem
120! NOH3D = INT(Z'09'), & !< time-dependent inflow for 3D Noh problem
121 noslip = int(z'0A'), &
122 custom = int(z'0B'), &
123 farfield = int(z'0C'), &
124 absorbing = int(z'0D'), &
125! DMR = INT(Z'0E'), & !< ???
126 shearing = int(z'0F')
127 !--------------------------------------------------------------------------!
128 PUBLIC :: &
129 ! types
131 ! constants
132#ifdef PARALLEL
133 none, &
134#endif
136! FOLDED, &
138! NOH2D, NOH3D, &
139 noslip, custom, &
140 farfield, &
141 absorbing, &
142! DMR, &
144 !--------------------------------------------------------------------------!
145
146CONTAINS
147
148 SUBROUTINE initboundary(this,Mesh,Physics,bctype,bcname,dir,config)
149 IMPLICIT NONE
150 !------------------------------------------------------------------------!
151 CLASS(boundary_base), INTENT(INOUT) :: this
152 CLASS(mesh_base), INTENT(IN) :: Mesh
153 CLASS(physics_base), INTENT(IN) :: Physics
154 TYPE(dict_typ), INTENT(IN), POINTER :: config
155 INTEGER, INTENT(IN) :: bctype,dir
156 CHARACTER(LEN=32), INTENT(IN) :: bcname
157 !------------------------------------------------------------------------!
158#ifdef PARALLEL
159 INTEGER, PARAMETER :: strlen = 32
160 CHARACTER(LEN=strlen) :: sendbuf
161 CHARACTER(LEN=strlen) :: recvbuf
162 INTEGER :: status(MPI_STATUS_SIZE)
163 INTEGER :: ierror
164#endif
165 !------------------------------------------------------------------------!
166 ! set boundary condition
167 CALL this%InitLogging(bctype,bcname)
168 ALLOCATE(this%direction)
169 CALL this%direction%InitLogging(dir,direction_name(dir))
170 ! check for wrong direction
171 SELECT CASE(dir)
173 ! ok
174 CASE DEFAULT
175 CALL this%Error("InitBoundary_common", "Unknown direction")
176 END SELECT
177
178! IF(((Physics%GetType().EQ.EULER2D_ISOIAMT).OR.&
179! (Physics%GetType().EQ.EULER2D_IAMT)).AND. &
180! ((dir.EQ.NORTH).OR.(dir.EQ.SOUTH)).AND. &
181! (.NOT.((bctype.EQ.PERIODIC) &
182!#ifdef PARALLEL
183! .OR.(bctype.EQ.NONE) &
184!#endif
185! ))) &
186! CALL this%Error("InitBoundary_one", "All IAMT Physics need periodic" &
187! // " boundary conditions in NORTH/SOUTH direction")
188
189 ! print some information
190#ifdef PARALLEL
191 ! send boundary information to the rank 0 process;
192 ! we only need this to synchronize the output
193 IF (this%GetRank() .EQ. 0 .AND. this%GetRank().EQ.mesh%rank0_boundaries(dir)) THEN
194 ! print output without communication
195#endif
196 CALL this%Info(" BOUNDARY-> condition: " // trim(this%direction%GetName()) &
197 // " " // trim(this%GetName()), this%GetRank())
198#ifdef PARALLEL
199 ELSE IF (this%GetRank().EQ.mesh%rank0_boundaries(dir)) THEN
200 ! send info to root
201 sendbuf = trim(this%direction%GetName())//" "//trim(this%GetName())
202 CALL mpi_send(sendbuf,strlen,mpi_character,0, &
203 0,mpi_comm_world,ierror)
204 ELSE IF (this%GetRank().EQ.0) THEN
205 ! receive input from rank0_boundaries(dir)
206 CALL mpi_recv(recvbuf,strlen,mpi_character,mesh%rank0_boundaries(dir),&
207 mpi_any_tag,mpi_comm_world,status,ierror)
208 CALL this%Info(" BOUNDARY-> condition: " // trim(recvbuf),this%GetRank())
209 END IF
210#endif
211 END SUBROUTINE initboundary
212
215 PURE FUNCTION getdirection(this) RESULT(dir)
216 IMPLICIT NONE
217 !------------------------------------------------------------------------!
218 CLASS(boundary_base), INTENT(IN) :: this
219 INTEGER :: dir
220 !------------------------------------------------------------------------!
221 dir = this%direction%GetType()
222 END FUNCTION getdirection
223
224
225 SUBROUTINE finalize_base(this)
226 IMPLICIT NONE
227 !------------------------------------------------------------------------!
228 CLASS(boundary_base),INTENT(INOUT) :: this
229 !------------------------------------------------------------------------!
230 IF (.NOT.this%Initialized()) &
231 CALL this%Error("CloseBoundary_one","not initialized")
232 DEALLOCATE(this%direction)
233 END SUBROUTINE finalize_base
234
235END MODULE boundary_base_mod
integer, parameter axis
axis
integer, parameter periodic
connects opposite boundaries
integer, parameter custom
user defined
integer, parameter none
pure integer function getdirection(this)
Get the direction number.
integer, parameter no_gradients
copy data from last cell in comp. domain in ghost zones
integer, parameter farfield
uses far-field data and Riemann invariants
integer, parameter extrapolation
linear extrapolation
integer, parameter shearing
periodic with shear for shearing sheet/box
integer, parameter reflecting
reflecting, i.e. wall
subroutine finalize_base(this)
integer, parameter absorbing
vanishing characteristic pseudo-variables for incomming waves
integer, parameter noslip
reflecting, but with moving wall
integer, parameter fixed
set fixed boundary data
subroutine initboundary(this, Mesh, Physics, bctype, bcname, dir, config)
character(len=32), dimension(6), parameter direction_name
string literal for each orientation
Dictionary for generic data types.
Definition: common_dict.f90:61
type(logging_base), save this
Basic fosite module.
subroutine finalize(this)
Destructor of logging_base class.
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.
common data structure
mesh data structure
Definition: mesh_base.f90:122