source: CIVL/mods/dev.civl.abc/examples/fortran/flash/block/Eos_wrapped.F90

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 10.8 KB
Line 
1!!****if* source/physics/Eos/EosMain/Eos_wrapped
2!! NAME
3!!
4!! Eos_wrapped
5!!
6!! SYNOPSIS
7!!
8!! call Eos_wrapped( integer(IN) :: mode,
9!! integer(IN) :: range(HIGH, MDIM),
10!! integer(IN) :: blockID,
11!! optional,integer(IN) :: gridDataStruct )
12!!
13!! DESCRIPTION
14!!
15!! This function is provided for the user's convenience and acts as a simple
16!! wrapper to the Eos interface. The Eos interface uses a single, flexible data
17!! structure "eosData" to pass the thermodynamic quantities in and out of the
18!! funtion (see Eos). The wrapper hides formation and use of eosData
19!! from the users.
20!!
21!! While Eos does not know anything about blocks, Eos_wrapped takes its
22!! input thermodynamic state variables from a given block's storage area.
23!! It works by taking a selected section of a block described by array
24!! "range" and translating it to eosData before calling the Eos routine.
25!! Upon return from Eos, Eos_wrapper updates certain state variables in
26!! the same section of the block's storage area. Which variables are taken
27!! as input, and which are updated, depends on the "mode" argument.
28!!
29!! If you want to return the derived quantities defined from EOS_VAR+1:EOS_NUM
30!! in Eos.h, then you must use the direct interface Eos().
31!!
32!!
33!! ARGUMENTS
34!!
35!!
36!! mode : determines which variables are used as Eos input.
37!! Valid values are MODE_DENS_EI (where density and internal
38!! energy are inputs), MODE_DENS_PRES (density and pressure as inputs)
39!! MODE_DENS_TEMP (density and temperature are inputs).
40!! These quantities are defined in constants.h, the argument is
41!! forwarded unchanged to the Eos function call.
42!! Note that internal energy is grid variable EINT_VAR, not ENER_VAR.
43!!
44!!
45!! range: an array that holds the lower and upper indices of the section
46!! of block on which Eos is to be applies. The example shows how
47!! the array describes the block section.
48!!
49!! blockID: current block number
50!!
51!! gridDataStruct : the grid data structure on whose data Eos is to be applied
52!!
53!!
54!! EXAMPLE
55!! if range(LOW,IAXIS)=1,range(HIGH,IAXIS)=iguard,
56!! range(LOW,JAXIS)=1,range(HIGH,JAXIS)=jguard,
57!! range(LOW,KAXIS)=1,range(HIGH,KAXIS)=kguard,
58!! then Eos is applied to the lower left hand corner of the guard
59!! cells in the block.
60!!
61!! However, if the value were
62!! range(LOW,IAXIS)=iguard+1,range(HIGH,IAXIS)=iguard+nxb,
63!! range(LOW,JAXIS)=jguard+1,range(HIGH,JAXIS)=jguard+nyb,
64!! range(LOW,KAXIS)=kguard+1,range(HIGH,KAXIS)=kguard+nzb,
65!! then Eos is applied to all the interior cells in the block.
66!!
67!! NOTES
68!! This interface is defined in Fortran Module
69!! Eos_interface. All functions calling this routine should include
70!! a statement like
71!! use Eos_interface, ONLY : Eos_wrapped
72!!
73!! This routine cannot use "INTERIOR" mode of indexing the range. In the
74!! second example given above, although only the interior cells are being
75!! calculated with EOS, the range indices still must include the guard cells.
76!! See, for example, IsentropicVortex/Simulation_initBlock where the data is
77!! generated on INTERIOR cells with Grid_putRowData, but the same indices can't
78!! be used for the EOS call.
79!!
80!! SEE ALSO
81!!
82!! Eos
83!! Eos.h
84!!
85!!***
86
87! solnData depends on the ordering on unk
88!!REORDER(4): solnData
89
90
91!!$subroutine Eos_wrapped(mode,range,blockID, gridDataStruct)
92!!$
93!!$ use Driver_interface, ONLY : Driver_abortFlash
94!!$ use Grid_interface, ONLY : Grid_getBlkPtr, Grid_releaseBlkPtr
95!!$ use Logfile_interface, ONLY: Logfile_stampMessage
96!!$ use Eos_interface, ONLY : Eos, Eos_putData, Eos_getData, Eos_arrayWrapped
97!!$ use Eos_data, ONLY : eos_threadWithinBlock
98!!$ !$ use omp_lib
99!!$ implicit none
100!!$
101#include "Eos.h"
102#include "constants.h"
103#include "Flash.h"
104!!$
105!!$ integer, intent(in) :: mode
106!!$ integer, dimension(2,MDIM), intent(in) :: range
107!!$ integer,intent(in) :: blockID
108!!$ integer, optional, intent(IN) :: gridDataStruct
109!!$
110!!$ real, pointer:: solnData(:,:,:,:)
111!!$
112!!$#ifndef FIXEDBLOCKSIZE
113!!$ real, allocatable :: eosData(:),massFraction(:)
114!!$#else
115!!$ real, dimension(NSPECIES*MAXCELLS) :: massFraction
116!!$ real, dimension(EOS_NUM*MAXCELLS) :: eosData
117!!$#endif
118!!$
119!!$ logical,target,dimension(EOS_VARS+1:EOS_NUM) :: eosMask
120!!$
121!!$ integer :: ierr, dataStruct
122!!$ integer :: i,j,k, vecLen
123!!$ integer,dimension(MDIM) :: pos
124!!$
125!!$
126!!$
127!!$ call Grid_getBlkPtr(blockID,solnData,gridDataStruct)
128!!$ call Eos_arrayWrapped(mode,range,solnData, gridDataStruct)
129!!$
130!!$ call Grid_releaseBlkPtr(blockID,solnData,gridDataStruct)
131!!$
132!!$ return
133!!$end subroutine Eos_wrapped
134
135!!****if* source/physics/Eos/EosMain/Eos_Wrapped
136!! NAME
137!!
138!! Eos_Wrapped
139!!
140!! SYNOPSIS
141!!
142!! call Eos_Wrapped( integer(IN) :: mode,
143!! integer(IN) :: range(HIGH, MDIM),
144!! real,pointer(IN) :: solnData,
145!! optional,integer(IN) :: gridDataStruct )
146!!
147!! DESCRIPTION
148!!
149!! This function is provided for the user's convenience and acts as a simple
150!! wrapper to the Eos interface. The Eos interface uses a single, flexible data
151!! structure "eosData" to pass the thermodynamic quantities in and out of the
152!! funtion (see Eos). The wrapper hides formation and use of eosData
153!! from the users.
154!!
155!! While Eos does not know anything about blocks, Eos_arrayWrapped takes its
156!! input thermodynamic state variables from a given block's storage area.
157!! It works by taking a selected section of a block
158!! described by array "range" and translating it to eosData
159!! before calling the Eos function.
160!! Upon return from Eos, Eos_wrapper updates certain state variables in
161!! the same section of the block's storage area. Which variables are taken
162!! as input, and which are updated, depends on the "mode" argument.
163!!
164!! If you want to return the derived quantities defined from EOS_VAR+1:EOS_NUM
165!! in Eos.h, then you must use the direct interface Eos(). Note that
166!! entropy EOS_ENTR is considered a derived variable.
167!!
168!!
169!! ARGUMENTS
170!!
171!!
172!! mode : determines which variables are used as Eos input.
173!! The valid values are MODE_DENS_EI (where density and internal
174!! energy are inputs), MODE_DENS_PRES (density and pressure as inputs)
175!! MODE_DENS_TEMP (density and temperature are inputs).
176!! These quantities are defined in constants.h, the argument is
177!! forwarded unchanged to the Eos function call.
178!! Note that internal energy is grid variable EINT_VAR, not ENER_VAR.
179!!
180!!
181!! range: an array that holds the lower and upper indices of the section
182!! of block on which Eos is to be applies. The example shows how
183!! the array describes the block section.
184!!
185!! solnData: pointer to array section of solution data for a block
186!!
187!! gridDataStruct : the grid data structure on whose data Eos is to be applied
188!!
189!!
190!! EXAMPLE
191!! if range(LOW,IAXIS)=1,range(HIGH,IAXIS)=iguard,
192!! range(LOW,JAXIS)=1,range(HIGH,JAXIS)=jguard,
193!! range(LOW,KAXIS)=1,range(HIGH,KAXIS)=kguard,
194!! then Eos is applied to the lower left hand corner of the guard
195!! cells in the block.
196!!
197!! However if the value were
198!! range(LOW,IAXIS)=iguard+1,range(HIGH,IAXIS)=iguard+nxb,
199!! range(LOW,JAXIS)=jguard+1,range(HIGH,JAXIS)=jguard+nyb,
200!! range(LOW,KAXIS)=kguard+1,range(HIGH,KAXIS)=kguard+nzb,
201!! then Eos is applied to all the interior cells in the block.
202!!
203!! NOTES
204!! This interface is defined in Fortran Module
205!! Eos_interface. All functions calling this routine should include
206!! a statement like
207!! use Eos_interface, ONLY : Eos_arrayWrapped
208!!
209!! This routine cannot use "INTERIOR" mode of indexing the range. In the
210!! second example given above, although only the interior cells are being
211!! calculated with EOS, the range indices still must include the guard cells.
212!! See, for example, IsentropicVortex/Simulation_initBlock where the data is
213!! generated on INTERIOR cells with Grid_putRowData, but the same indices can't
214!! be used for the EOS call.
215!!
216!! SEE ALSO
217!!
218!! Eos
219!! Eos.h
220!!
221!!***
222
223! solnData depends on the ordering on unk
224!!REORDER(4): solnData
225
226
227subroutine Eos_wrapped(mode,range,solnData, gridDataStruct)
228
229 use Driver_interface, ONLY : Driver_abortFlash
230 use Grid_interface, ONLY : Grid_getBlkPtr, Grid_releaseBlkPtr
231 use Logfile_interface, ONLY: Logfile_stampMessage
232 use Eos_interface, ONLY : Eos, Eos_putData, Eos_getData
233 use Eos_data, ONLY : eos_threadWithinBlock
234 implicit none
235
236#include "FortranLangFeatures.fh"
237
238 integer, intent(in) :: mode
239 integer, dimension(2,MDIM), intent(in) :: range
240 real, POINTER_INTENT_IN :: solnData(:,:,:,:)
241 integer, optional, intent(IN) :: gridDataStruct
242
243
244 real, allocatable :: eosData(:),massFraction(:)
245
246 logical,target,dimension(EOS_VARS+1:EOS_NUM) :: eosMask
247
248 integer :: ierr, dataStruct
249 integer :: i,j,k, vLen1D, vecLen,offset
250 integer,dimension(MDIM) :: pos
251
252
253!! ---------------------------------------------------------------------------------
254 ! Test calling arguments
255#define DEBUG
256#ifdef DEBUG
257 ierr = 1
258 select case (mode)
259 case (MODE_DENS_PRES)
260 ierr = 0
261 case (MODE_DENS_TEMP)
262 ierr = 0
263 case (MODE_DENS_EI)
264 ierr = 0
265 case (MODE_EOS_NOP)
266 ierr = 0
267 case (MODE_DENS_TEMP_ALL,MODE_DENS_TEMP_EQUI)
268 ierr = 0
269 case (MODE_DENS_EI_ALL,MODE_DENS_EI_SCATTER,MODE_DENS_EI_GATHER)
270 ierr = 0
271 case (MODE_DENS_EI_SELE_GATHER)
272 ierr = 0
273 case (MODE_DENS_ENTR)
274 ierr = 0
275 end select
276
277 if(ierr /= 0) then
278 call Driver_abortFlash("[Eos_arrayWrapped] "//&
279 "invalid mode: must be MODE_DENS_PRES, MODE_DENS_TEMP, MODE_DENS_EI, or variants thereof, or MODE_EOS_NOP")
280 end if
281#endif
282
283 if (mode==MODE_EOS_NOP) return ! * Return immediately for MODE_EOS_NOP! *
284
285 vLen1D = range(HIGH,IAXIS)-range(LOW,IAXIS)+1
286 vecLen=vLen1D*(range(HIGH,JAXIS)-range(LOW,JAXIS)+1)*(range(HIGH,KAXIS)-range(LOW,KAXIS)+1)
287 if (vecLen==0) return ! * Return immediately for empty IAXIS range! (for efficiency and avoiding index range errors)
288
289 ! solnData points to solution data in UNK (or other data structure).
290 ! The length of the data being operated upon is determined from the range input array.
291
292 if(present(gridDataStruct))then
293 dataStruct=gridDataStruct
294 else
295 dataStruct=CENTER
296 end if
297
298 allocate(massFraction(NSPECIES*vecLen))
299 allocate(eosData(EOS_NUM*vecLen))
300
301 eosMask = .FALSE.
302
303 pos(IAXIS)=range(LOW,IAXIS)
304
305 call Eos_getData(range,vecLen,solnData,dataStruct,eosData,massFraction)
306 call Eos(mode,vecLen,eosData,massFraction,mask=eosMask)
307
308 call Eos_putData(range,vecLen,solnData,dataStruct,eosData)
309
310 deallocate(eosData)
311 deallocate(massFraction)
312
313#ifndef _CIVL
314 !$omp end parallel
315#endif
316
317 return
318end subroutine Eos_wrapped
Note: See TracBrowser for help on using the repository browser.