76 INTEGER,
PARAMETER ::
beta = 3
80 "constant viscosity ", &
81 "turbulent Shakura-Sunyaev ", &
82 "turbulent Duschl ", &
83 "power law viscosity ", &
84 "alternative Shakura-Sunyaev "/)
88 CHARACTER(LEN=32) :: source_name =
"viscosity of Newtonian fluid" 90 CLASS(
marray_base),
ALLOCATABLE :: ephir, & !< azimuthal unit vector */ distance to axis
92 dynvis, & !< dynamic viscosity
93 kinvis, & !< kinematic viscosity
95 REAL :: dynconst,bulkconst,power
96 REAL,
DIMENSION(:,:,:),
POINTER :: & !< comp. of stress tensor
97 btxx,btyy,btzz,btxy,btxz,btyz,tmp,tmp2,tmp3
98 REAL,
DIMENSION(:,:),
POINTER :: &
99 sxx,syy,szz,sxy,sxz,syz
127 CLASS(Sources_viscosity) :: this
128 CLASS(Mesh_base) :: Mesh
129 CLASS(Physics_base) :: Physics
130 CLASS(Fluxes_base) :: Fluxes
131 TYPE(Dict_TYP),
POINTER :: config,IO
134 INTEGER :: err, viscosity_number ,k,l
136 INTENT(IN) :: mesh,physics,fluxes
138 CALL getattr(config,
"stype", stype)
139 CALL this%InitLogging(stype,this%source_name)
141 SELECT TYPE(phys => physics)
143 IF (phys%VDIM.EQ.1) &
144 CALL this%Error(
"InitSources_viscosity",
"viscosity is currently not supported in 1D physics")
146 CALL this%Error(
"InitSources_viscosity", &
147 "viscosity is currently only supported in eulerisotherm/euler physics")
151 CALL getattr(config,
"vismodel", viscosity_number)
153 CALL this%viscosity%InitLogging(viscosity_number,
viscosity_name(viscosity_number))
156 CALL getattr(config,
"dynconst", this%dynconst, 0.1)
162 CALL getattr(config,
"bulkconst", this%bulkconst, -2./3.*this%dynconst)
166 CALL getattr(config,
"exponent", this%power, 0.0)
169 CALL getattr(config,
"cvis", this%cvis, 0.5)
171 ALLOCATE(this%dynvis,this%kinvis,this%bulkvis, &
172 this%btxx(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
173 this%btyy(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
174 this%btzz(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
175 this%btxy(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
176 this%btxz(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
177 this%btyz(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
180 CALL this%Error(
"InitSources_viscosity",
"Memory allocation failed.")
186 this%dynvis%data1d(:) = this%dynconst
187 this%kinvis%data1d(:) = 0.0
188 this%bulkvis%data1d(:) = this%bulkconst
191 SELECT CASE(this%viscosity%GetType())
197 SELECT TYPE(phys => physics)
199 ALLOCATE(this%ephir,this%ephir_tmp,stat=err)
201 CALL this%Error(
"InitSources_viscosity",
"Memory allocation failed.")
206 this%ephir%data4d(:,:,:,1) = -mesh%cart%bcenter(:,:,:,2) / mesh%radius%bcenter(:,:,:)**2
207 this%ephir%data4d(:,:,:,2) = mesh%cart%bcenter(:,:,:,1) / mesh%radius%bcenter(:,:,:)**2
208 this%ephir%data4d(:,:,:,3) = 0.0
210 CALL mesh%geometry%Convert2Curvilinear(mesh%curv%bcenter,this%ephir%data4d,this%ephir_tmp%data4d)
212 IF (phys%VDIM.LT.3)
THEN 213 CALL this%ephir%Destroy()
219 IF (btest(mesh%VECTOR_COMPONENTS,k-1))
THEN 220 this%ephir%data2d(:,l) = this%ephir_tmp%data2d(:,k)
225 CALL this%ephir_tmp%Destroy()
226 DEALLOCATE(this%ephir_tmp)
228 CALL this%Error(
"InitSources_viscosity",&
229 "Physics not supported for alpha-/beta-viscosity")
233 CALL this%Error(
"InitSources_viscosity",&
234 "alternative alpha-viscosity currently not supported")
241 CALL this%Error(
"InitSources_viscosity",&
242 "Viscosity prescription not supported.")
248 this%btxx(:,:,:) = 0.0
249 this%btyy(:,:,:) = 0.0
250 this%btzz(:,:,:) = 0.0
251 this%btxy(:,:,:) = 0.0
252 this%btxz(:,:,:) = 0.0
253 this%btyz(:,:,:) = 0.0
255 CALL this%SetOutput(mesh,physics,config,io)
256 IF (this%GetType().EQ.
alpha_alt) this%update_disk_height = .true.
258 CALL this%InitSources(mesh,fluxes,physics,config,io)
262 SUBROUTINE setoutput(this,Mesh,Physics,config,IO)
265 CLASS(Sources_viscosity),
INTENT(IN) :: this
266 CLASS(Mesh_base) ,
INTENT(IN) :: Mesh
267 CLASS(Physics_base),
INTENT(IN) :: Physics
268 TYPE(Dict_TYP),
POINTER :: config,IO
274 CALL getattr(config,
"output/stress", valwrite, 0)
275 IF (valwrite .EQ. 1)
THEN 276 CALL setattr(io,
"stress:xx", this%btxx(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
277 CALL setattr(io,
"stress:xy", this%btxy(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
278 CALL setattr(io,
"stress:xz", this%btxz(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
279 CALL setattr(io,
"stress:yy", this%btyy(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
280 CALL setattr(io,
"stress:yz", this%btyz(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
281 CALL setattr(io,
"stress:zz", this%btzz(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
284 CALL getattr(config,
"output/dynvis", valwrite, 0)
285 IF (valwrite .EQ. 1) &
286 CALL setattr(io,
"dynvis", this%dynvis%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
288 CALL getattr(config,
"output/kinvis", valwrite, 0)
289 IF (valwrite .EQ. 1) &
290 CALL setattr(io,
"kinvis", this%kinvis%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
292 CALL getattr(config,
"output/bulkvis", valwrite, 0)
293 IF (valwrite .EQ. 1) &
294 CALL setattr(io,
"bulkvis", this%bulkvis%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
302 CLASS(Sources_viscosity),
INTENT(IN) :: this
303 CLASS(Mesh_base),
INTENT(IN) :: Mesh
305 CHARACTER(LEN=32) :: dynconst_str,bulkconst_str
307 WRITE (dynconst_str,
'(ES9.2)') this%dynconst
308 CALL this%Info(
" viscosity model: " // this%viscosity%GetName())
309 SELECT CASE(this%viscosity%GetType())
311 WRITE (bulkconst_str,
'(ES9.2)') this%bulkconst
312 CALL this%Info(
" dynamic viscosity: " // trim(dynconst_str))
313 CALL this%Info(
" bulk viscosity: " // trim(bulkconst_str))
315 CALL this%Info(
" alpha: " // trim(dynconst_str))
317 CALL this%Info(
" beta: " // trim(dynconst_str))
319 WRITE (bulkconst_str,
'(ES9.2)') this%power
320 CALL this%Info(
" coupling constant: " // trim(dynconst_str))
321 CALL this%Info(
" exponent: " // trim(bulkconst_str))
365 CLASS(Sources_viscosity),
INTENT(INOUT) :: this
366 CLASS(Mesh_base),
INTENT(IN) :: Mesh
367 CLASS(Physics_base),
INTENT(INOUT) :: Physics
368 CLASS(Fluxes_base),
INTENT(IN) :: Fluxes
369 REAL,
INTENT(IN) :: time
370 CLASS(marray_compound),
INTENT(INOUT) :: pvar,cvar
375 IF ((time.NE.this%time) .OR. (time .EQ. 0.))
THEN 377 SELECT CASE(this%viscosity%GetType())
384 SELECT TYPE(p => pvar)
386 SELECT TYPE(phys => physics)
388 this%dynvis%data1d(:) =
etafkt_alpha(this%dynconst,p%density%data1d(:),&
389 phys%bccsound%data1d(:),
omega(this%ephir,p%velocity)+mesh%Omega)
395 SELECT TYPE(p => pvar)
397 this%dynvis%data1d(:) =
etafkt_beta(this%dynconst,mesh%radius%data2d(:,2), &
398 p%density%data1d(:),
omega(this%ephir,p%velocity)+mesh%Omega)
403 SELECT TYPE(p => pvar)
406 mesh%radius%data2d(:,2),p%density%data1d(:),
omega(this%ephir,p%velocity)+mesh%Omega)
418 SELECT CASE(this%viscosity%GetType())
425 this%bulkvis%data1d(:) = -2./3.*this%dynvis%data1d(:)
435 PURE FUNCTION omega(ephir,velocity)
439 REAL,
DIMENSION(SIZE(ephir%data2d,DIM=1)) ::
omega 445 omega(:) = ephir%data2d(:,1) * velocity%data2d(:,1)
447 omega(:) =
omega(:) + ephir%data2d(:,l) * velocity%data2d(:,l)
452 ELEMENTAL FUNCTION etafkt_alpha(alpha,density,cs,omega)
RESULT(eta)
462 ELEMENTAL FUNCTION etafkt_beta(beta,r,density,omega)
RESULT(eta)
477 REAL,
INTENT(IN) ::
beta,q,r,density,
omega 480 eta =
beta * density * (r**2 * abs(
omega))**q
491 CLASS(sources_viscosity),
INTENT(INOUT) :: this
492 CLASS(mesh_base),
INTENT(IN) :: Mesh
493 CLASS(physics_base),
INTENT(INOUT) :: Physics
494 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
495 CLASS(sources_base),
INTENT(INOUT) :: Sources
496 REAL,
INTENT(IN) :: time, dt
497 CLASS(marray_compound),
INTENT(INOUT) :: pvar,cvar,sterm
499 CALL this%UpdateViscosity(mesh,physics,fluxes,time,pvar,cvar)
500 SELECT TYPE(phys => physics)
502 CALL phys%CalcStresses(mesh,pvar,this%dynvis,this%bulkvis, &
503 this%btxx,this%btxy,this%btxz,this%btyy,this%btyz,this%btzz)
504 CALL phys%ViscositySources(mesh,pvar,this%btxx,this%btxy,this%btxz, &
505 this%btyy,this%btyz,this%btzz,sterm)
515 CLASS(Sources_viscosity),
INTENT(INOUT) :: this
516 CLASS(Mesh_base),
INTENT(IN) :: Mesh
517 CLASS(Physics_base),
INTENT(INOUT) :: Physics
518 CLASS(Fluxes_base),
INTENT(IN) :: Fluxes
519 CLASS(marray_compound),
INTENT(INOUT) :: pvar,cvar
520 REAL,
INTENT(IN) :: time
521 REAL,
INTENT(OUT) :: dt
523 REAL :: invdt_x, invdt_y,invdt_z
526 CALL this%UpdateViscosity(mesh,physics,fluxes,time,pvar,cvar)
529 SELECT TYPE(p => pvar)
531 this%kinvis%data1d(:) = this%dynvis%data1d(:) / p%density%data1d(:)
535 IF (mesh%INUM.GT.1)
THEN 536 invdt_x = maxval(this%kinvis%data1d(:) / mesh%dlx%data1d(:)**2, &
537 mask=mesh%without_ghost_zones%mask1d(:))
543 IF (mesh%JNUM.GT.1)
THEN 544 invdt_y = maxval(this%kinvis%data1d(:) / mesh%dly%data1d(:)**2, &
545 mask=mesh%without_ghost_zones%mask1d(:))
551 IF (mesh%KNUM.GT.1)
THEN 552 invdt_z = maxval(this%kinvis%data1d(:) / mesh%dlz%data1d(:)**2, &
553 mask=mesh%without_ghost_zones%mask1d(:))
559 invdt_x = max(invdt_x, invdt_y,invdt_z)
560 IF (invdt_x.GT.tiny(invdt_x))
THEN 561 dt = this%cvis / invdt_x
571 CLASS(Sources_viscosity),
INTENT(INOUT) :: this
573 IF (
ALLOCATED(this%ephir))
THEN 574 CALL this%ephir%Destroy()
575 DEALLOCATE(this%ephir)
577 CALL this%dynvis%Destroy()
578 CALL this%kinvis%Destroy()
579 CALL this%bulkvis%Destroy()
580 DEALLOCATE(this%dynvis,this%kinvis,this%bulkvis, &
581 this%btxx,this%btyy,this%btzz,this%btxy,this%btxz,this%btyz)
subroutine finalize(this)
Destructor of common class.
elemental real function etafkt_powerlaw(beta, q, r, density, omega)
generic source terms module providing functionaly common to all source terms
integer, parameter, public powerlaw
integer, parameter, public alpha_alt
integer, parameter, public molecular
pure real function, dimension(size(ephir%data2d, dim=1)) omega(ephir, velocity)
derived class for compound of mesh arrays
base class for mesh arrays
character(len=32), dimension(5), parameter, public viscosity_name
subroutine setoutput(this, Mesh, Physics, config, IO)
defines properties of a 3D logcylindrical mesh
computes momentum and energy sources due to shear stresses
defines properties of a 3D cylindrical mesh
subroutine initsources_viscosity(this, Mesh, Physics, Fluxes, config, IO)
subroutine calctimestep_single(this, Mesh, Physics, Fluxes, pvar, cvar, time, dt)
base class for geometrical properties
physics module for 1D,2D and 3D isothermal Euler equations
elemental real function etafkt_alpha(alpha, density, cs, omega)
subroutine infosources(this, Mesh)
integer, parameter, public viscosity
Dictionary for generic data types.
physics module for 1D,2D and 3D non-isothermal Euler equations
subroutine externalsources_single(this, Mesh, Physics, Fluxes, Sources, time, dt, pvar, cvar, sterm)
integer, parameter, public alpha
elemental real function etafkt_beta(beta, r, density, omega)
integer, parameter, public beta
base module for numerical flux functions
subroutine updateviscosity(this, Mesh, Physics, Fluxes, time, pvar, cvar)
updates dynamic and bulk viscosity