sources_generic.f90
Go to the documentation of this file.
1 !#############################################################################
2 !# #
3 !# fosite - 3D hydrodynamical simulation program #
4 !# module: mesh_generic.f90 #
5 !# #
6 !# Copyright (C) 2016-2018 #
7 !# Manuel Jung <mjung@astrophysik.uni-kiel.de> #
8 !# #
9 !# This program is free software; you can redistribute it and/or modify #
10 !# it under the terms of the GNU General Public License as published by #
11 !# the Free Software Foundation; either version 2 of the License, or (at #
12 !# your option) any later version. #
13 !# #
14 !# This program is distributed in the hope that it will be useful, but #
15 !# WITHOUT ANY WARRANTY; without even the implied warranty of #
16 !# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
17 !# NON INFRINGEMENT. See the GNU General Public License for more #
18 !# details. #
19 !# #
20 !# You should have received a copy of the GNU General Public License #
21 !# along with this program; if not, write to the Free Software #
22 !# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
23 !# #
24 !#############################################################################
25 !----------------------------------------------------------------------------!
34 !----------------------------------------------------------------------------!
43  USE mesh_base_mod
44  USE fluxes_base_mod
46  USE common_dict
47 
48 CONTAINS
49 
50  SUBROUTINE new_sources(this,Mesh,Fluxes,Physics,config,IO)
51  IMPLICIT NONE
52  !------------------------------------------------------------------------!
53  CLASS(sources_base), POINTER :: this
54  CLASS(mesh_base) :: Mesh
55  CLASS(fluxes_base) :: Fluxes
56  CLASS(physics_base) :: Physics
57  TYPE(DICT_TYP), POINTER :: config, IO
58  !------------------------------------------------------------------------!
59  CLASS(sources_base), POINTER :: newsrc => null(), tmpsrc => null()
60  TYPE(Dict_TYP), POINTER :: dir,src,IOsrc,gsrc => null(),gdir => null()
61  INTEGER :: update_disk_height = 0
62  INTEGER :: stype
63  !------------------------------------------------------------------------!
64  IF (.NOT.physics%Initialized().OR..NOT.mesh%Initialized()) &
65  CALL this%Error("InitSources","physics and/or mesh module uninitialized")
66 
67  dir => config
68  DO WHILE(ASSOCIATED(dir))
69  NULLIFY(iosrc)
70  IF(haschild(dir)) THEN
71  src => getchild(dir)
72  CALL getattr(src, "stype", stype)
73 
74  ! object creation
75  SELECT CASE(stype)
76  CASE(gravity)
77  ! skip initialization of gravity modules here and initialize them
78  ! at the end to make sure gravity is the first source term in the list
79  gsrc => src
80  gdir => dir
81  newsrc => null()
82  CASE(c_accel)
83  ALLOCATE(sources_c_accel::newsrc)
84  CASE(disk_cooling)
85  ALLOCATE(sources_diskcooling::newsrc)
86  CASE(rotating_frame)
87  ALLOCATE(sources_rotframe::newsrc)
88  CASE(shearbox)
89  ALLOCATE(sources_shearbox::newsrc)
90  CASE(viscosity)
91  ALLOCATE(sources_viscosity::newsrc)
92  CASE DEFAULT
93  CALL this%Error("new_sources","Unknown source type")
94  END SELECT
95 
96  ! basic initialization of all source terms except gravity
97  IF (ASSOCIATED(newsrc)) THEN
98  SELECT TYPE(obj => newsrc)
99  TYPE IS (sources_c_accel)
100  CALL obj%InitSources_c_accel(mesh,physics,fluxes,src,iosrc)
101  TYPE IS (sources_diskcooling)
102  CALL obj%InitSources_diskcooling(mesh,physics,fluxes,src,iosrc)
103  IF (obj%cooling%GetType().EQ.gray) update_disk_height = 1
104  TYPE IS (sources_rotframe)
105  CALL obj%InitSources_rotframe(mesh,physics,fluxes,src,iosrc)
106  TYPE IS (sources_shearbox)
107  CALL obj%InitSources_shearbox(mesh,physics,fluxes,src,iosrc)
108  TYPE IS (sources_viscosity)
109  CALL obj%InitSources_viscosity(mesh,physics,fluxes,src,iosrc)
110  IF (obj%viscosity%GetType().EQ.alpha_alt) update_disk_height = 1
111  END SELECT
112  ! check if list of source terms is empty
113  IF (.NOT.ASSOCIATED(this)) THEN
114  ! first entry is the new source term
115  this => newsrc
116  NULLIFY(this%next)
117  ELSE
118  ! prepend new source term to the list of source terms
119  tmpsrc => this
120  this => newsrc
121  this%next => tmpsrc
122  END IF
123  END IF
124 
125  ! process the output dictionary
126  IF(ASSOCIATED(iosrc)) CALL setattr(io, getkey(dir), iosrc)
127 
128  END IF
129  dir => getnext(dir)
130  END DO
131 
132  ! finally initialize gravity
133  IF(ASSOCIATED(gsrc)) THEN
134  NULLIFY(iosrc)
135  ALLOCATE(sources_gravity::newsrc)
136 
137  tmpsrc => this
138  this => newsrc
139  this%next => tmpsrc
140 
141  CALL setattr(gsrc,"update_disk_height", update_disk_height)
142  SELECT TYPE(obj => newsrc)
143  TYPE IS(sources_gravity)
144  CALL obj%InitSources_gravity(mesh,physics,fluxes,gsrc,iosrc)
145  END SELECT
146 
147  IF(ASSOCIATED(iosrc)) CALL setattr(io, getkey(gdir), iosrc)
148  END IF
149 
150  END SUBROUTINE new_sources
151 
152  SUBROUTINE destroy_sources(this)
153  IMPLICIT NONE
154  !------------------------------------------------------------------------!
155  CLASS(sources_base), POINTER :: this
156  !------------------------------------------------------------------------!
157  CLASS(sources_base), POINTER :: srcptr
158  !------------------------------------------------------------------------!
159  ! loop over all source terms and call finalization subroutines
160  IF (ASSOCIATED(this)) THEN
161  CALL this%Finalize_base()
162  DO
163  srcptr => this
164  IF (.NOT.ASSOCIATED(srcptr)) EXIT
165  this => srcptr%next
166  CALL srcptr%Finalize()
167  DEALLOCATE(srcptr)
168  END DO
169  END IF
170  END SUBROUTINE destroy_sources
171 
172 END MODULE sources_generic_mod
integer, parameter, public disk_cooling
integer, parameter, public gray
generic source terms module providing functionaly common to all source terms
source terms module for constant acceleration
integer, parameter, public alpha_alt
subroutine new_sources(this, Mesh, Fluxes, Physics, config, IO)
type(dict_typ) function, pointer, public getchild(root)
Get the pointer to a direct child of the pointer &#39;root&#39;.
computes momentum and energy sources due to shear stresses
logical function, public haschild(root)
Check if the node &#39;root&#39; has one or more children.
function, public getkey(root)
Get the key of pointer &#39;root&#39;.
integer, parameter, public rotating_frame
generic gravity terms module providing functionaly common to all gravity terms
constructor for sources class
integer, parameter, public gravity
integer, parameter, public viscosity
Source terms module for fictious forces in a shearingsheet.
type(dict_typ) function, pointer, public getnext(root)
Get the pointer to the next child.
source terms module for inertial forces caused by a rotating grid
subroutine destroy_sources(this)
Basic physics module.
Dictionary for generic data types.
Definition: common_dict.f90:61
integer, parameter, public shearbox
base module for numerical flux functions
Definition: fluxes_base.f90:39
integer, parameter, public c_accel
source terms module for cooling of geometrically thin accretion disks