63 CLASS(reconstruction_base),
ALLOCATABLE &
68 cons, & !< state vectors on cell faces
72 REAL,
DIMENSION(:,:,:,:),
POINTER,
CONTIGUOUS &
78 procedure(calculatefluxes),
DEFERRED :: calculatefluxes
86 SUBROUTINE calculatefluxes(this,Mesh,Physics,pvar,cvar, &
87 xfluxdydz,yfluxdzdx,zfluxdxdy)
90 CLASS(fluxes_base),
INTENT(INOUT) :: this
91 CLASS(mesh_base),
INTENT(IN) :: Mesh
92 CLASS(physics_base),
INTENT(INOUT) :: Physics
93 CLASS(marray_compound),
INTENT(INOUT):: pvar,cvar
94 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX,Physics%VNUM), &
95 INTENT(OUT) :: xfluxdydz,yfluxdzdx,zfluxdxdy
100 CLASS(fluxes_base),
INTENT(INOUT) :: this
103 INTEGER,
PARAMETER ::
kt = 1
118 SUBROUTINE initfluxes(this,Mesh,Physics,config,IO,ftype,fname)
121 CLASS(fluxes_base),
INTENT(INOUT) :: this
122 CLASS(mesh_base),
INTENT(IN) :: Mesh
123 CLASS(physics_base),
INTENT(IN) :: Physics
124 TYPE(Dict_TYP),
POINTER :: config,IO
127 CHARACTER(LEN=*) :: fname
129 TYPE(Dict_TYP),
POINTER :: IOrec => null()
130 INTEGER :: valwrite,i
131 CHARACTER(LEN=60) :: key
133 CALL this%InitLogging(ftype,fname)
136 IF (.NOT.mesh%Initialized().OR..NOT.physics%Initialized()) &
137 CALL this%Error(
"InitFluxes",
"mesh and/or physics module uninitialized")
140 ALLOCATE(this%minwav,this%maxwav, &
141 this%bxflux(mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,2,physics%VNUM), &
142 this%byflux(mesh%KGMIN:mesh%KGMAX,mesh%IGMIN:mesh%IGMAX,2,physics%VNUM), &
143 this%bzflux(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,2,physics%VNUM), &
144 this%bxfold(mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,2,physics%VNUM), &
145 this%byfold(mesh%KGMIN:mesh%KGMAX,mesh%IGMIN:mesh%IGMAX,2,physics%VNUM), &
146 this%bzfold(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,2,physics%VNUM), &
149 CALL this%Error(
"InitFluxes",
"Unable to allocate memory.")
157 CALL physics%new_statevector(this%prim,primitive,mesh%NFACES)
158 CALL physics%new_statevector(this%cons,conservative,mesh%NFACES)
161 CALL physics%new_statevector(this%pfluxes,conservative,mesh%NFACES)
164 CALL this%Info(
" FLUXES---> fluxes type " // trim(this%GetName()))
167 CALL getattr(config,
"output/pstates", valwrite,0)
168 IF(valwrite.EQ.1)
THEN 170 key = trim(physics%pvarname(i)) //
"_pstates" 171 CALL setattr(io, trim(key), &
172 this%prim%data5d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,:,i))
175 CALL getattr(config,
"output/cstates", valwrite, 0)
176 IF(valwrite.EQ.1)
THEN 178 key = trim(physics%cvarname(i)) //
"_cstates" 179 CALL setattr(io, trim(key), &
180 this%cons%data5d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,:,i))
183 CALL getattr(config,
"output/pfluxes", valwrite, 0)
184 IF(valwrite.EQ.1)
THEN 186 key = trim(physics%pvarname(i)) //
"_pfluxes" 187 CALL setattr(io, trim(key), &
188 this%pfluxes%data5d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,:,i))
192 CALL getattr(config,
"output/wave_speeds", valwrite, 0)
193 IF(valwrite.EQ.1)
THEN 194 CALL setattr(io,
"minwav", &
195 this%minwav%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,1:mesh%NDIMS))
196 CALL setattr(io,
"maxwav", &
197 this%maxwav%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,1:mesh%NDIMS))
204 IF(
ASSOCIATED(iorec))
CALL setattr(io,
"reconstruction",iorec)
208 this%bxflux(:,:,:,:) = 0.
209 this%byflux(:,:,:,:) = 0.
210 this%bzflux(:,:,:,:) = 0.
211 this%bxfold(:,:,:,:) = 0.
212 this%byfold(:,:,:,:) = 0.
213 this%bzfold(:,:,:,:) = 0.
219 FUNCTION getboundaryflux(this,Mesh,Physics,direction,comm)
RESULT(bflux)
226 REAL,
DIMENSION(Physics%VNUM) :: bflux
227 INTEGER,
OPTIONAL :: comm
230 REAL,
DIMENSION(Physics%VNUM) :: bflux_local
231 INTEGER :: sender_rank(1),dest_ranks(1),rank0(1)
232 INTEGER :: dest_comm,union_comm
233 INTEGER :: world_group,dest_group,union_group,sender_group
237 INTENT(IN) :: direction
240 IF (
PRESENT(comm))
THEN 243 dest_comm = mpi_comm_null
246 SELECT CASE(direction)
249 IF (mesh%mycoords(1).EQ.0)
THEN 250 bflux_local(:) = sum(sum(
this%bxflux(mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,1,:),1),1)
255 bflux = sum(sum(
this%bxflux(mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,1,:),1),1)
259 IF (mesh%mycoords(1).EQ.mesh%dims(1)-1)
THEN 260 bflux_local(:) = sum(sum(
this%bxflux(mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,2,:),1),1)
265 bflux = sum(sum(
this%bxflux(mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,2,:),1),1)
269 IF (mesh%mycoords(2).EQ.0)
THEN 270 bflux_local(:) = sum(sum(
this%byflux(mesh%KMIN:mesh%KMAX,mesh%IMIN:mesh%IMAX,1,:),1),1)
275 bflux = sum(sum(
this%byflux(mesh%KMIN:mesh%KMAX,mesh%IMIN:mesh%IMAX,1,:),1),1)
279 IF (mesh%mycoords(2).EQ.mesh%dims(2)-1)
THEN 280 bflux_local(:) = sum(sum(
this%byflux(mesh%KMIN:mesh%KMAX,mesh%IMIN:mesh%IMAX,2,:),1),1)
285 bflux = sum(sum(
this%byflux(mesh%KMIN:mesh%KMAX,mesh%IMIN:mesh%IMAX,2,:),1),1)
289 IF (mesh%mycoords(3).EQ.0)
THEN 290 bflux_local(:) = sum(sum(
this%bzflux(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,1,:),1),1)
295 bflux = sum(sum(
this%bzflux(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,1,:),1),1)
299 IF (mesh%mycoords(3).EQ.mesh%dims(3)-1)
THEN 300 bflux_local(:) = sum(sum(
this%bzflux(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,2,:),1),1)
305 bflux = sum(sum(
this%bzflux(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,2,:),1),1)
308 CALL this%Error(
"GetBoundaryFlux",
"wrong direction")
313 IF(dest_comm.EQ.mpi_comm_world)
THEN 315 mpi_sum,mpi_comm_world,ierror)
318 CALL mpi_comm_group(mpi_comm_world,world_group,ierror)
320 IF(dest_comm.NE.mpi_comm_null)
THEN 323 CALL mpi_comm_group(dest_comm,dest_group,ierror)
328 CALL mpi_group_incl(world_group,1,dest_ranks,dest_group,ierror)
332 IF (mesh%comm_boundaries(direction).NE.mpi_comm_null)
THEN 334 mpi_sum,0,mesh%comm_boundaries(direction),ierror)
339 rank0(1) = mesh%rank0_boundaries(direction)
340 CALL mpi_group_incl(world_group,1,rank0,sender_group,ierror)
342 CALL mpi_group_union(sender_group,dest_group,union_group,ierror)
344 CALL mpi_comm_create(mpi_comm_world,union_group,union_comm,ierror)
345 IF (union_comm.NE.mpi_comm_null)
THEN 348 CALL mpi_group_translate_ranks(sender_group,1,rank0,union_group,sender_rank,ierror)
349 IF (sender_rank(1).EQ.mpi_undefined) &
350 CALL this%Error(
"GetBoundaryFlux",
"sender rank undefined")
352 CALL mpi_bcast(bflux,physics%VNUM,
default_mpi_real,sender_rank(1),union_comm,ierror)
354 CALL mpi_comm_free(union_comm,ierror)
357 CALL mpi_group_free(union_group,ierror)
358 CALL mpi_group_free(sender_group,ierror)
359 CALL mpi_group_free(world_group,ierror)
360 CALL mpi_group_free(dest_group,ierror)
377 IF (
this%Reconstruction%PrimRecon())
THEN 378 CALL this%Reconstruction%CalculateStates(mesh,physics,pvar,
this%prim)
379 CALL physics%Convert2Conservative(
this%prim,
this%cons)
381 CALL this%Reconstruction%CalculateStates(mesh,physics,cvar,
this%cons)
382 CALL physics%Convert2Primitive(
this%cons,
this%prim)
386 SELECT TYPE(phys => physics)
388 SELECT TYPE(prim =>
this%prim)
390 CALL phys%UpdateSoundSpeed(prim)
395 CALL physics%CalculateWaveSpeeds(mesh,
this%prim%data5d,
this%cons%data5d,
this%minwav,
this%maxwav)
402 CLASS(fluxes_base),
INTENT(INOUT) :: this
404 IF (.NOT.this%Initialized()) &
405 CALL this%Error(
"CloseFluxes",
"not initialized")
406 CALL this%minwav%Destroy()
407 CALL this%maxwav%Destroy()
408 CALL this%prim%Destroy()
409 CALL this%cons%Destroy()
410 CALL this%pfluxes%Destroy()
411 DEALLOCATE(this%cons,this%prim,this%pfluxes,this%minwav,this%maxwav, &
412 this%bxflux,this%byflux,this%bzflux,this%bxfold,this%byfold,this%bzfold)
413 CALL this%Reconstruction%Finalize()
414 DEALLOCATE(this%Reconstruction)
subroutine finalize(this)
Destructor of common class.
real function, dimension(physics%vnum) getboundaryflux(this, Mesh, Physics, direction, comm)
Get fluxes at boundaries.
integer, save default_mpi_real
default real type for MPI
type(logging_base), save this
derived class for compound of mesh arrays
base class for mesh arrays
subroutine new_reconstruction(Reconstruction, Mesh, Physics, config, IO)
pure subroutine calculatefacedata(this, Mesh, Physics, pvar, cvar)
Calcualtes face data with reconstruction methods (e. g. limiters)
subroutine initfluxes(this, Mesh, Physics, config, IO, ftype, fname)
Initialize Fluxes.
constructor for physics class
subroutine finalize_base(this)
Destructor.
integer, parameter, public kt
named integer constants for flavour of state vectors
Dictionary for generic data types.
physics module for 1D,2D and 3D non-isothermal Euler equations
base module for numerical flux functions
constructor for reconstruction class