sources_viscosity.f90
Go to the documentation of this file.
1 !#############################################################################
2 !# #
3 !# fosite - 3D hydrodynamical simulation program #
4 !# module: sources_viscosity.f90 #
5 !# #
6 !# Copyright (C) 2008-2019 #
7 !# Bjoern Sperling <sperling@astrophysik.uni-kiel.de> #
8 !# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
9 !# #
10 !# This program is free software; you can redistribute it and/or modify #
11 !# it under the terms of the GNU General Public License as published by #
12 !# the Free Software Foundation; either version 2 of the License, or (at #
13 !# your option) any later version. #
14 !# #
15 !# This program is distributed in the hope that it will be useful, but #
16 !# WITHOUT ANY WARRANTY; without even the implied warranty of #
17 !# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
18 !# NON INFRINGEMENT. See the GNU General Public License for more #
19 !# details. #
20 !# #
21 !# You should have received a copy of the GNU General Public License #
22 !# along with Mesh program; if not, write to the Free Software #
23 !# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
24 !# #
25 !#############################################################################
37 !----------------------------------------------------------------------------!
60 !----------------------------------------------------------------------------!
64  USE fluxes_base_mod
65  USE mesh_base_mod
66  USE marray_base_mod
69  USE common_dict
70  IMPLICIT NONE
71  !--------------------------------------------------------------------------!
72  PRIVATE
73  ! flags for viscosity model
74  INTEGER,PARAMETER :: molecular = 1 ! constant viscosity
75  INTEGER,PARAMETER :: alpha = 2 ! Shakura-Sunyaev prescription
76  INTEGER,PARAMETER :: beta = 3 ! Duschl prescription
77  INTEGER,PARAMETER :: powerlaw = 4 ! power law depending on spec. angular momentum
78  INTEGER,PARAMETER :: alpha_alt = 5 ! alternative Shakura-Sunyaev
79  CHARACTER(LEN=32),PARAMETER, DIMENSION(5) :: viscosity_name = (/ &
80  "constant viscosity ", &
81  "turbulent Shakura-Sunyaev ", &
82  "turbulent Duschl ", &
83  "power law viscosity ", &
84  "alternative Shakura-Sunyaev "/)
85 
86 
87  TYPE, EXTENDS(sources_base) :: sources_viscosity
88  CHARACTER(LEN=32) :: source_name = "viscosity of Newtonian fluid"
89  CLASS(logging_base), ALLOCATABLE :: viscosity
90  CLASS(marray_base), ALLOCATABLE :: ephir, & !< azimuthal unit vector */ distance to axis
91  ephir_tmp, &
92  dynvis, & !< dynamic viscosity
93  kinvis, & !< kinematic viscosity
94  bulkvis
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
100  CONTAINS
102  PROCEDURE :: infosources
103  PROCEDURE :: setoutput
104  PROCEDURE :: updateviscosity
106  PROCEDURE :: calctimestep_single
107 
108  PROCEDURE :: finalize
109  END TYPE
110  !--------------------------------------------------------------------------!
111  PUBLIC :: &
112  ! types
114  ! constants
116  !--------------------------------------------------------------------------!
117 
118 CONTAINS
119 
120  SUBROUTINE initsources_viscosity(this,Mesh,Physics,Fluxes,config,IO)
125  IMPLICIT NONE
126  !------------------------------------------------------------------------!
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
132  INTEGER :: stype
133  !------------------------------------------------------------------------!
134  INTEGER :: err, viscosity_number ,k,l
135  !------------------------------------------------------------------------!
136  INTENT(IN) :: mesh,physics,fluxes
137  !------------------------------------------------------------------------!
138  CALL getattr(config, "stype", stype)
139  CALL this%InitLogging(stype,this%source_name)
140 
141  SELECT TYPE(phys => physics)
142  CLASS IS(physics_eulerisotherm)
143  IF (phys%VDIM.EQ.1) &
144  CALL this%Error("InitSources_viscosity","viscosity is currently not supported in 1D physics")
145  CLASS DEFAULT
146  CALL this%Error("InitSources_viscosity", &
147  "viscosity is currently only supported in eulerisotherm/euler physics")
148  END SELECT
149 
150  ! viscosity model
151  CALL getattr(config, "vismodel", viscosity_number)
152  ALLOCATE(logging_base::this%viscosity)
153  CALL this%viscosity%InitLogging(viscosity_number,viscosity_name(viscosity_number))
154 
155  ! dynamic viscosity constant
156  CALL getattr(config, "dynconst", this%dynconst, 0.1)
157  ! bulk viscosity constant
158  ! At the moment this only affects the molecular viscosity. The default
159  ! value refers to a trace free viscosity tensor.
160  ! All other viscosity models should always be trace free. Therefore this
161  ! is hard coded and cannot be changed.
162  CALL getattr(config, "bulkconst", this%bulkconst, -2./3.*this%dynconst)
163 
164  ! power law exponent used for POWERLAW viscosity;
165  ! defaults to constant kinematic viscosity, i.e. nu ~ l^0 = const
166  CALL getattr(config, "exponent", this%power, 0.0)
167 
168  ! set viscous courant number
169  CALL getattr(config, "cvis", this%cvis, 0.5)
170 
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), &
178  stat=err)
179  IF (err.NE.0) &
180  CALL this%Error("InitSources_viscosity","Memory allocation failed.")
181 
182  ! initialize mesh arrays
183  this%dynvis = marray_base()
184  this%kinvis = marray_base()
185  this%bulkvis = marray_base()
186  this%dynvis%data1d(:) = this%dynconst
187  this%kinvis%data1d(:) = 0.0
188  this%bulkvis%data1d(:) = this%bulkconst
189 
190  ! do the model specific initialization
191  SELECT CASE(this%viscosity%GetType())
192  CASE(molecular)
193  ! do nothing
194  CASE(alpha,beta,powerlaw)
195  ! compute the projector to determine the local angular velocity
196  ! ATTENTION: it is always assumed that the fluid rotates around the z-axis
197  SELECT TYPE(phys => physics)
198  CLASS IS(physics_eulerisotherm)
199  ALLOCATE(this%ephir,this%ephir_tmp,stat=err)
200  IF (err.NE.0) &
201  CALL this%Error("InitSources_viscosity","Memory allocation failed.")
202  this%ephir_tmp = marray_base(3)
203  this%ephir = marray_base(3)
204  ! compute ephi/r (r: distance to z-axis, ephi: azimuthal unit vector)
205  ! set cartesian vector components using cartesian coordinates
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
209  ! convert to curvilinear vector components
210  CALL mesh%geometry%Convert2Curvilinear(mesh%curv%bcenter,this%ephir%data4d,this%ephir_tmp%data4d)
211  ! reduce vector components to match Physics%VDIM
212  IF (phys%VDIM.LT.3) THEN
213  CALL this%ephir%Destroy()
214  this%ephir = marray_base(phys%VDIM)
215  END IF
216  ! copy vector components actually used
217  l = 1
218  DO k=1,3
219  IF (btest(mesh%VECTOR_COMPONENTS,k-1)) THEN
220  this%ephir%data2d(:,l) = this%ephir_tmp%data2d(:,k)
221  l = l + 1
222  END IF
223  END DO
224  ! destroy temporary marray
225  CALL this%ephir_tmp%Destroy()
226  DEALLOCATE(this%ephir_tmp)
227  CLASS DEFAULT
228  CALL this%Error("InitSources_viscosity",&
229  "Physics not supported for alpha-/beta-viscosity")
230  END SELECT
231  CASE(alpha_alt)
233  CALL this%Error("InitSources_viscosity",&
234  "alternative alpha-viscosity currently not supported")
235 ! IF (Physics%VDIM.NE.2) &
236 ! CALL this%Error("InitSources_viscosity",&
237 ! "alternative alpha-viscosity works only for flat disks")
238  ! IF (.NOT.Timedisc%always_update_bccsound) &
239  ! CALL Error(this,"InitSources_viscosity","always_update_bccsound must be enabled in timedisc")
240  CASE DEFAULT
241  CALL this%Error("InitSources_viscosity",&
242  "Viscosity prescription not supported.")
243  END SELECT
244  ! set initial time to negative value;
245  ! this guarantees update of viscosity for time t=0.0
246  this%time = -1.0
247  ! set stress tensor arrays to zero
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
254 
255  CALL this%SetOutput(mesh,physics,config,io)
256  IF (this%GetType().EQ.alpha_alt) this%update_disk_height = .true.
257 
258  CALL this%InitSources(mesh,fluxes,physics,config,io)
259 
260  END SUBROUTINE initsources_viscosity
261 
262  SUBROUTINE setoutput(this,Mesh,Physics,config,IO)
263  IMPLICIT NONE
264  !------------------------------------------------------------------------!
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
269  !------------------------------------------------------------------------!
270  INTEGER :: valwrite
271  !------------------------------------------------------------------------!
272  ! Hier wird der Stresstensor per default in 3D ausgegeben! Vorher nur in 2D plus abhängig
273  ! von der Physik auch die Komponenten der dritten Dimension
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))
282  END IF
283 
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))
287 
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))
291 
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))
295 
296  END SUBROUTINE setoutput
297 
298 
299  SUBROUTINE infosources(this,Mesh)
300  IMPLICIT NONE
301  !------------------------------------------------------------------------!
302  CLASS(Sources_viscosity),INTENT(IN) :: this
303  CLASS(Mesh_base),INTENT(IN) :: Mesh
304  !------------------------------------------------------------------------!
305  CHARACTER(LEN=32) :: dynconst_str,bulkconst_str
306  !------------------------------------------------------------------------!
307  WRITE (dynconst_str,'(ES9.2)') this%dynconst
308  CALL this%Info(" viscosity model: " // this%viscosity%GetName())
309  SELECT CASE(this%viscosity%GetType())
310  CASE(molecular)
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))
314  CASE(alpha,alpha_alt)
315  CALL this%Info(" alpha: " // trim(dynconst_str))
316  CASE(beta)
317  CALL this%Info(" beta: " // trim(dynconst_str))
318  CASE(powerlaw)
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))
322  END SELECT
323  END SUBROUTINE infosources
324 
325 
360  SUBROUTINE updateviscosity(this,Mesh,Physics,Fluxes,time,pvar,cvar)
363  IMPLICIT NONE
364  !------------------------------------------------------------------------!
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
371  !------------------------------------------------------------------------!
372  INTEGER :: l
373  !------------------------------------------------------------------------!
374  ! only update viscosity if time has changed
375  IF ((time.NE.this%time) .OR. (time .EQ. 0.)) THEN
376  ! Set the dynamic viscosity
377  SELECT CASE(this%viscosity%GetType())
378  CASE(molecular)
379  ! do nothing, since it has already been initialized
380  ! in InitSources_viscosity
381  CASE(alpha)
382  ! compute Shakura-Sunyaev type alpha viscosity
383  ! account for non-inertial frames by adding the frame angular velocity
384  SELECT TYPE(p => pvar)
385  CLASS IS(statevector_eulerisotherm)
386  SELECT TYPE(phys => physics)
387  CLASS IS(physics_eulerisotherm)
388  this%dynvis%data1d(:) = etafkt_alpha(this%dynconst,p%density%data1d(:),&
389  phys%bccsound%data1d(:),omega(this%ephir,p%velocity)+mesh%Omega)
390  END SELECT
391  END SELECT
392  CASE(beta)
393  ! compute Duschl type beta viscosity
394  ! account for non-inertial frames by adding the frame angular velocity
395  SELECT TYPE(p => pvar)
396  CLASS IS(statevector_eulerisotherm)
397  this%dynvis%data1d(:) = etafkt_beta(this%dynconst,mesh%radius%data2d(:,2), &
398  p%density%data1d(:),omega(this%ephir,p%velocity)+mesh%Omega)
399  END SELECT
400  CASE(powerlaw)
401  ! kinematic viscosity scales with power of specific angular momentum
402  ! account for non-inertial frames by adding the frame angular velocity
403  SELECT TYPE(p => pvar)
404  CLASS IS(statevector_eulerisotherm)
405  this%dynvis%data1d(:) = etafkt_powerlaw(this%dynconst,this%power, &
406  mesh%radius%data2d(:,2),p%density%data1d(:),omega(this%ephir,p%velocity)+mesh%Omega)
407  END SELECT
408 ! TODO: height of the disk is calculated in another source module, which is not translated yet. Therefore, ALPHA_ALT is not
409 ! working
410 ! CASE(ALPHA_ALT)
411 ! ! eta = nu*rho = alpha*cs*h * rho
412 ! ! compute dynamic viscosity
413 ! this%dynvis(:,:,:) = this%dynconst * Physics%bccsound%data3d(:,:,:) &
414 ! * Physics%sources%height(:,:,:) * pvar(:,:,:,Physics%DENSITY)
415  END SELECT
416 
417  ! Set the bulk viscosity
418  SELECT CASE(this%viscosity%GetType())
419  CASE(molecular)
420  ! do nothing, since it has already been initialized
421  ! in InitSources_viscosity
423  ! All available parametrized viscosities should be trace free.
424  ! This can be achieved by setting the following:
425  this%bulkvis%data1d(:) = -2./3.*this%dynvis%data1d(:)
426  END SELECT
427 
428  ! update time
429  this%time = time
430  END IF
431  CONTAINS
432  ! some elemental functions for computation of the viscosity
433 
434  ! compute angular velocity
435  PURE FUNCTION omega(ephir,velocity)
436  IMPLICIT NONE
437  !----------------------------------------------------------------------!
438  CLASS(marray_base), INTENT(IN) :: ephir,velocity
439  REAL, DIMENSION(SIZE(ephir%data2d,DIM=1)) :: omega
440  !----------------------------------------------------------------------!
441  INTEGER :: l
442  !----------------------------------------------------------------------!
443  ! project velocity on ephi/r -> local angular velocity
444  ! use dynvis as temporary storage
445  omega(:) = ephir%data2d(:,1) * velocity%data2d(:,1)
446  DO l=2,ephir%DIMS(1)
447  omega(:) = omega(:) + ephir%data2d(:,l) * velocity%data2d(:,l)
448  END DO
449  END FUNCTION omega
450 
451  ! Alpha viscosity
452  ELEMENTAL FUNCTION etafkt_alpha(alpha,density,cs,omega) RESULT(eta)
453  IMPLICIT NONE
454  !----------------------------------------------------------------------!
455  REAL, INTENT(IN) :: alpha,density,cs,omega
456  REAL :: eta
457  !----------------------------------------------------------------------!
458  eta = alpha * density * cs**2 / abs(omega)
459  END FUNCTION etafkt_alpha
460 
461  ! Beta viscosity
462  ELEMENTAL FUNCTION etafkt_beta(beta,r,density,omega) RESULT(eta)
463  IMPLICIT NONE
464  !----------------------------------------------------------------------!
465  REAL, INTENT(IN) :: beta,r,density,omega
466  REAL :: eta
467  !----------------------------------------------------------------------!
468  ! nu = beta * r * v_phi = beta * r^2 * omega
469  ! eta = rho * nu
470  eta = beta * density * r**2 * abs(omega)
471  END FUNCTION etafkt_beta
472 
473  ! power law viscosity
474  ELEMENTAL FUNCTION etafkt_powerlaw(beta,q,r,density,omega) RESULT(eta)
475  IMPLICIT NONE
476  !----------------------------------------------------------------------!
477  REAL, INTENT(IN) :: beta,q,r,density,omega
478  REAL :: eta
479  !----------------------------------------------------------------------!
480  eta = beta * density * (r**2 * abs(omega))**q
481  END FUNCTION etafkt_powerlaw
482 
483  END SUBROUTINE updateviscosity
484 
485 
486  SUBROUTINE externalsources_single(this,Mesh,Physics,Fluxes,Sources,time,dt,pvar,cvar,sterm)
488  USE physics_euler_mod, ONLY : physics_euler
489  IMPLICIT NONE
490  !------------------------------------------------------------------------!
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
498  !------------------------------------------------------------------------!
499  CALL this%UpdateViscosity(mesh,physics,fluxes,time,pvar,cvar)
500  SELECT TYPE(phys => physics)
501  CLASS IS(physics_eulerisotherm)
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)
506  END SELECT
507  END SUBROUTINE externalsources_single
508 
509 
510  SUBROUTINE calctimestep_single(this,Mesh,Physics,Fluxes,pvar,cvar,time,dt)
513  IMPLICIT NONE
514  !------------------------------------------------------------------------!
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
522  !------------------------------------------------------------------------!
523  REAL :: invdt_x, invdt_y,invdt_z
524  !------------------------------------------------------------------------!
525  ! update dynamic and bulk viscosity
526  CALL this%UpdateViscosity(mesh,physics,fluxes,time,pvar,cvar)
527 
528  ! compute kinematic viscosity
529  SELECT TYPE(p => pvar)
530  CLASS IS(statevector_eulerisotherm)
531  this%kinvis%data1d(:) = this%dynvis%data1d(:) / p%density%data1d(:)
532  END SELECT
533 
534  ! x-direction
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(:))
538  ELSE
539  ! set to zero, i.e. no limit in x-direction due to diffusion
540  invdt_x = 0.0
541  END IF
542  ! y-direction
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(:))
546  ELSE
547  ! set to zero, i.e. no limit in y-direction due to diffusion
548  invdt_y = 0.0
549  END IF
550  ! z-direction
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(:))
554  ELSE
555  ! set to zero, i.e. no limit in z-direction due to diffusion
556  invdt_z = 0.0
557  END IF
558  ! largest time step due to diffusion
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
562  ELSE
563  dt = huge(dt)
564  END IF
565  END SUBROUTINE calctimestep_single
566 
567 
568  SUBROUTINE finalize(this)
569  IMPLICIT NONE
570  !------------------------------------------------------------------------!
571  CLASS(Sources_viscosity),INTENT(INOUT) :: this
572  !------------------------------------------------------------------------!
573  IF (ALLOCATED(this%ephir)) THEN
574  CALL this%ephir%Destroy()
575  DEALLOCATE(this%ephir)
576  END IF
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)
582  END SUBROUTINE finalize
583 
584 
585 END MODULE sources_viscosity_mod
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
Definition: marray_base.f90:36
Basic fosite module.
common data structure
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
basic mesh array class
Definition: marray_base.f90:64
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
Basic physics module.
Dictionary for generic data types.
Definition: common_dict.f90:61
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
Definition: fluxes_base.f90:39
subroutine updateviscosity(this, Mesh, Physics, Fluxes, time, pvar, cvar)
updates dynamic and bulk viscosity