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 !----------------------------------------------------------------------------!
43  USE mesh_base_mod
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  PURE 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  enum, bind(c)
111  enumerator :: no_gradients = z'01', &
112  periodic = z'02', &
113  reflecting = z'03', &
114  axis = z'04', &
115 ! FOLDED = Z'05', & !< cuts boundary in half and connects
116 ! !< the two parts (not supported in parallel mode)
117  fixed = z'06', &
118  extrapolation = z'07', &
119 ! NOH2D = Z'08', & !< time-dependent inflow for 2D Noh problem
120 ! NOH3D = Z'09', & !< time-dependent inflow for 3D Noh problem
121  noslip = z'0A', &
122  custom = z'0B', &
123 ! FARFIELD = Z'0C', & !< uses far-field data and Riemann invariants
124  absorbing = z'0D', &
125 ! DMR = Z'0E', & !< ???
126  shearing = z'0F'
127  END enum
128  !--------------------------------------------------------------------------!
129  PUBLIC :: &
130  ! types
131  boundary_base, &
132  ! constants
133 #ifdef PARALLEL
134  none, &
135 #endif
136  no_gradients, periodic, reflecting, axis, &
137 ! FOLDED, &
138  fixed, extrapolation, &
139 ! NOH2D, NOH3D, &
140  noslip, custom, &
141 ! FARFIELD, &
142  absorbing, &
143 ! DMR, &
144  shearing
145  !--------------------------------------------------------------------------!
146 
147 CONTAINS
148 
149  SUBROUTINE initboundary(this,Mesh,Physics,bctype,bcname,dir,config)
150  IMPLICIT NONE
151  !------------------------------------------------------------------------!
152  CLASS(boundary_base), INTENT(INOUT) :: this
153  CLASS(mesh_base), INTENT(IN) :: Mesh
154  CLASS(physics_base), INTENT(IN) :: Physics
155  TYPE(Dict_TYP), INTENT(IN), POINTER :: config
156  INTEGER, INTENT(IN) :: bctype,dir
157  CHARACTER(LEN=32), INTENT(IN) :: bcname
158  !------------------------------------------------------------------------!
159 #ifdef PARALLEL
160  INTEGER, PARAMETER :: strlen = 32
161  CHARACTER(LEN=strlen) :: sendbuf
162  CHARACTER(LEN=strlen) :: recvbuf
163  INTEGER :: status(MPI_STATUS_SIZE)
164  INTEGER :: ierror
165 #endif
166  !------------------------------------------------------------------------!
167  ! set boundary condition
168  CALL this%InitLogging(bctype,bcname)
169  ALLOCATE(this%direction)
170  CALL this%direction%InitLogging(dir,direction_name(dir))
171  ! check for wrong direction
172  SELECT CASE(dir)
173  CASE(west,east,north,south,top,bottom)
174  ! ok
175  CASE DEFAULT
176  CALL this%Error("InitBoundary_common", "Unknown direction")
177  END SELECT
178 
179 ! IF(((Physics%GetType().EQ.EULER2D_ISOIAMT).OR.&
180 ! (Physics%GetType().EQ.EULER2D_IAMT)).AND. &
181 ! ((dir.EQ.NORTH).OR.(dir.EQ.SOUTH)).AND. &
182 ! (.NOT.((bctype.EQ.PERIODIC) &
183 !#ifdef PARALLEL
184 ! .OR.(bctype.EQ.NONE) &
185 !#endif
186 ! ))) &
187 ! CALL this%Error("InitBoundary_one", "All IAMT Physics need periodic" &
188 ! // " boundary conditions in NORTH/SOUTH direction")
189 
190  ! print some information
191 #ifdef PARALLEL
192  ! send boundary information to the rank 0 process;
193  ! we only need this to synchronize the output
194  IF (this%GetRank() .EQ. 0 .AND. this%GetRank().EQ.mesh%rank0_boundaries(dir)) THEN
195  ! print output without communication
196 #endif
197  CALL this%Info(" BOUNDARY-> condition: " // trim(this%direction%GetName()) &
198  // " " // trim(this%GetName()), this%GetRank())
199 #ifdef PARALLEL
200  ELSE IF (this%GetRank().EQ.mesh%rank0_boundaries(dir)) THEN
201  ! send info to root
202  sendbuf = trim(this%direction%GetName())//" "//trim(this%GetName())
203  CALL mpi_send(sendbuf,strlen,mpi_character,0, &
204  0,mpi_comm_world,ierror)
205  ELSE IF (this%GetRank().EQ.0) THEN
206  ! receive input from rank0_boundaries(dir)
207  CALL mpi_recv(recvbuf,strlen,mpi_character,mesh%rank0_boundaries(dir),&
208  mpi_any_tag,mpi_comm_world,status,ierror)
209  CALL this%Info(" BOUNDARY-> condition: " // trim(recvbuf),this%GetRank())
210  END IF
211 #endif
212  END SUBROUTINE initboundary
213 
216  PURE FUNCTION getdirection(this) RESULT(dir)
217  IMPLICIT NONE
218  !------------------------------------------------------------------------!
219  CLASS(boundary_base), INTENT(IN) :: this
220  INTEGER :: dir
221  !------------------------------------------------------------------------!
222  dir = this%direction%GetType()
223  END FUNCTION getdirection
224 
225 
226  SUBROUTINE finalize_base(this)
227  IMPLICIT NONE
228  !------------------------------------------------------------------------!
229  CLASS(boundary_base),INTENT(INOUT) :: this
230  !------------------------------------------------------------------------!
231  IF (.NOT.this%Initialized()) &
232  CALL this%Error("CloseBoundary_one","not initialized")
233  DEALLOCATE(this%direction)
234  END SUBROUTINE finalize_base
235 
236 END MODULE boundary_base_mod
subroutine finalize(this)
Destructor of common class.
pure integer function getdirection(this)
Get the direction number.
type(logging_base), save this
derived class for compound of mesh arrays
subroutine initboundary(this, Mesh, Physics, bctype, bcname, dir, config)
Basic fosite module.
common data structure
subroutine finalize_base(this)
named integer constants for flavour of state vectors
Basic physics module.
Dictionary for generic data types.
Definition: common_dict.f90:61
integer, parameter none
periodic with shear for shearing sheet/box
character(len=32), dimension(6), parameter direction_name
string literal for each orientation