62 LOGICAL :: addtoenergy
84 CLASS(sources_gravity),
INTENT(INOUT) :: this
85 CLASS(mesh_base),
INTENT(IN) :: Mesh
86 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
87 CLASS(physics_base),
INTENT(IN) :: Physics
88 TYPE(Dict_TYP),
POINTER :: config, IO
90 INTEGER :: err, stype,i, valwrite
92 CALL getattr(config,
"stype",stype)
94 CALL this%InitSources(mesh,fluxes,physics,config,io)
97 this%accel%data1d(:) = 0.
99 this%pot%data1d(:) = 0.
103 CALL getattr(config,
"energy", i, 1)
105 this%addtoenergy = .false.
107 this%addtoenergy = .true.
111 CALL getattr(config,
"update_disk_height", i, 0)
115 IF (physics%VDIM.EQ.2)
THEN 116 this%update_disk_height = .true.
121 this%height%data1d = 0.0
122 this%h_ext%data1d = 0.0
123 this%invheight2%data1d = 0.0
125 CALL this%Error(
"InitGravity",
"DiskHeight is only supported in 2D")
128 this%update_disk_height = .false.
132 CALL new_gravity(this%glist,mesh,fluxes,physics,config,io)
134 CALL getattr(config,
"output/height", valwrite, 0)
135 IF (valwrite .EQ. 1)
THEN 136 CALL setattr(config,
"update_disk_height", 1)
137 IF (.NOT.
ASSOCIATED(this%height%data1d))
THEN 138 ALLOCATE(this%height%data3d(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
140 IF (err.NE.0)
CALL this%Error(
"SetOutput", &
141 "Memory allocation failed for this%height!")
143 CALL setattr(io,
"height", &
144 this%height%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
158 CLASS(sources_gravity),
INTENT(INOUT) :: this
159 CLASS(mesh_base),
INTENT(IN) :: Mesh
160 CLASS(physics_base),
INTENT(INOUT) :: Physics
161 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
162 CLASS(sources_base),
INTENT(INOUT) :: Sources
163 REAL,
INTENT(IN) :: time, dt
164 CLASS(marray_compound),
INTENT(INOUT) :: pvar,cvar,sterm
167 CALL this%UpdateGravity(mesh,physics,fluxes,pvar,time,dt)
170 IF (this%update_disk_height)
THEN 171 SELECT TYPE(phys => physics)
173 CALL this%CalcDiskHeight(mesh,phys,pvar)
178 CALL physics%ExternalSources(this%accel,pvar,cvar,sterm)
184 SELECT TYPE(s => sterm)
186 IF (.NOT.this%addtoenergy) s%energy%data1d(:) = 0.
192 SUBROUTINE updategravity(this,Mesh,Physics,Fluxes,pvar,time,dt)
195 CLASS(sources_gravity),
TARGET,
INTENT(INOUT) :: this
196 CLASS(mesh_base),
INTENT(IN) :: Mesh
197 CLASS(physics_base),
INTENT(INOUT) :: Physics
198 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
199 CLASS(marray_compound),
INTENT(INOUT) :: pvar
200 REAL,
INTENT(IN) :: time, dt
202 CLASS(gravity_base),
POINTER :: gravptr
206 this%pot%data1d(:) = 0.
207 this%accel%data1d(:) = 0.
209 gravptr => this%glist
210 DO WHILE (
ASSOCIATED(gravptr))
212 CALL gravptr%UpdateGravity_single(mesh,physics,fluxes,pvar,time,dt)
215 this%accel = this%accel + gravptr%accel
218 IF(
ASSOCIATED(gravptr%pot)) &
219 this%pot%data4d(:,:,:,:) = this%pot%data4d(:,:,:,:) + gravptr%pot(:,:,:,:)
222 gravptr => gravptr%next
232 CLASS(sources_gravity),
TARGET,
INTENT(INOUT) :: this
233 CLASS(mesh_base),
INTENT(IN) :: Mesh
234 CLASS(physics_eulerisotherm),
INTENT(INOUT) :: Physics
235 CLASS(marray_compound),
INTENT(INOUT) :: pvar
237 CLASS(gravity_base),
POINTER :: grav_ptr,selfgrav_ptr => null()
238 LOGICAL :: has_external_potential = .false.
242 grav_ptr => this%glist
243 DO WHILE(
ASSOCIATED(grav_ptr))
244 SELECT TYPE (grav => grav_ptr)
247 CALL grav%CalcDiskHeight_single(mesh,physics,pvar,physics%bccsound,this%h_ext,this%height)
248 this%invheight2%data1d(:) = this%invheight2%data1d(:) + 1./this%h_ext%data1d(:)**2
249 has_external_potential = .true.
251 selfgrav_ptr => grav_ptr
255 grav_ptr => grav_ptr%next
259 IF (
ASSOCIATED(selfgrav_ptr))
THEN 260 IF (has_external_potential)
THEN 262 this%h_ext%data1d(:) = 1./sqrt(this%invheight2%data1d(:))
264 CALL selfgrav_ptr%CalcDiskHeight_single(mesh,physics,pvar,physics%bccsound,this%h_ext,this%height)
267 this%height%data1d(:) = 1./sqrt(this%invheight2%data1d(:))
277 CLASS(sources_gravity),
INTENT(IN) :: this
278 CLASS(mesh_base),
INTENT(IN) :: Mesh
285 CLASS(sources_gravity),
INTENT(INOUT) :: this
286 CLASS(gravity_base),
POINTER :: gravptr
288 CALL this%pot%Destroy()
289 CALL this%accel%Destroy()
290 CALL this%height%Destroy()
291 CALL this%invheight2%Destroy()
292 CALL this%h_ext%Destroy()
294 gravptr => this%glist
295 DO WHILE (
ASSOCIATED(gravptr))
297 CALL gravptr%Finalize()
299 gravptr => gravptr%next
302 CALL this%sources_c_accel%Finalize()
subroutine finalize(this)
Destructor of common class.
subroutine infosources(this, Mesh)
generic source terms module providing functionaly common to all source terms
subroutine updategravity(this, Mesh, Physics, Fluxes, pvar, time, dt)
Updates gravity of all gravity source modules.
source terms module for constant acceleration
2D poisson solver using spectral methods for direct integration
derived class for compound of mesh arrays
base class for mesh arrays
character(len=32) source_name
generic gravity terms module providing functionaly common to all gravity terms
source terms module for gravitational acceleration due to a point mass at the center of the coordinat...
generic gravity terms module providing functionaly common to all gravity terms
physics module for 1D,2D and 3D isothermal Euler equations
subroutine new_gravity(this, Mesh, Fluxes, Physics, config, IO)
subroutine initsources_gravity(this, Mesh, Physics, Fluxes, config, IO)
subroutine calcdiskheight(this, Mesh, Physics, pvar)
Dictionary for generic data types.
physics module for 1D,2D and 3D non-isothermal Euler equations
base module for numerical flux functions
subroutine externalsources_single(this, Mesh, Physics, Fluxes, Sources, time, dt, pvar, cvar, sterm)