gravity_base.f90
Go to the documentation of this file.
1 !#############################################################################
2 !# #
3 !# fosite - 3D hydrodynamical simulation program #
4 !# module: gravity_base.f90 #
5 !# #
6 !# Copyright (C) 2014-2019 #
7 !# Björn Sperling <sperling@astrophysik.uni-kiel.de> #
8 !# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
9 !# Jannes Klee <jklee@astrophysik.uni-kiel.de> #
10 !# #
11 !# This program is free software; you can redistribute it and/or modify #
12 !# it under the terms of the GNU General Public License as published by #
13 !# the Free Software Foundation; either version 2 of the License, or (at #
14 !# your option) any later version. #
15 !# #
16 !# This program is distributed in the hope that it will be useful, but #
17 !# WITHOUT ANY WARRANTY; without even the implied warranty of #
18 !# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
19 !# NON INFRINGEMENT. See the GNU General Public License for more #
20 !# details. #
21 !# #
22 !# You should have received a copy of the GNU General Public License #
23 !# along with this program; if not, write to the Free Software #
24 !# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
25 !# #
26 !#############################################################################
31 !----------------------------------------------------------------------------!
37 !----------------------------------------------------------------------------!
46 !----------------------------------------------------------------------------!
49  USE mesh_base_mod
51  USE fluxes_base_mod
53  USE marray_base_mod
55  USE common_dict
56  IMPLICIT NONE
57  !--------------------------------------------------------------------------!
58  PRIVATE
59  TYPE, ABSTRACT, EXTENDS(logging_base) :: gravity_base
61  CLASS(logging_base), ALLOCATABLE :: gravitytype
62  CLASS(gravity_base), POINTER :: next => null()
63  CLASS(marray_base), ALLOCATABLE :: accel
64  REAL, DIMENSION(:,:,:,:), POINTER :: pot
65  CONTAINS
66  PROCEDURE :: initgravity
67  PROCEDURE :: setoutput
68  procedure(updategravity_single), DEFERRED :: updategravity_single
69  procedure(calcdiskheight_single), DEFERRED :: calcdiskheight_single
70  PROCEDURE :: getgravitypointer
71  PROCEDURE :: finalize_base
72  procedure(finalize), DEFERRED :: finalize
73  END TYPE gravity_base
74 
75  abstract INTERFACE
76  SUBROUTINE updategravity_single(this,Mesh,Physics,Fluxes,pvar,time,dt)
78  IMPLICIT NONE
79  !------------------------------------------------------------------------!
80  CLASS(gravity_base), INTENT(INOUT) :: this
81  CLASS(mesh_base), INTENT(IN) :: Mesh
82  CLASS(physics_base), INTENT(IN) :: Physics
83  CLASS(fluxes_base), INTENT(IN) :: Fluxes
84  REAL, INTENT(IN) :: time,dt
85  CLASS(marray_compound), INTENT(INOUT) :: pvar
86  END SUBROUTINE
87  SUBROUTINE calcdiskheight_single(this,Mesh,Physics,pvar,bccsound,h_ext,height)
89  IMPLICIT NONE
90  !------------------------------------------------------------------------!
91  CLASS(gravity_base), INTENT(INOUT) :: this
92  CLASS(mesh_base), INTENT(IN) :: Mesh
93  CLASS(physics_base), INTENT(IN) :: Physics
94  CLASS(marray_compound), INTENT(INOUT) :: pvar
95  TYPE(marray_base), INTENT(INOUT) :: bccsound,h_ext,height
96  END SUBROUTINE
97  SUBROUTINE finalize(this)
98  IMPORT gravity_base
99  IMPLICIT NONE
100  CLASS(gravity_base), INTENT(INOUT) :: this
101  END SUBROUTINE
102  END INTERFACE
103  ! flags for source terms
104  INTEGER, PARAMETER :: pointmass = 1
105  INTEGER, PARAMETER :: pointmass_binary = 2
106 ! INTEGER, PARAMETER :: MONOPOL = 3
107 ! INTEGER, PARAMETER :: MULTIGRID = 4
108  INTEGER, PARAMETER :: spectral = 5
109 ! INTEGER, PARAMETER :: POTENTIAL = 6
110  INTEGER, PARAMETER :: sboxspectral = 7
111  !--------------------------------------------------------------------------!
112  PUBLIC :: &
113  ! types
114  gravity_base, &
115  ! constants
118  !--------------------------------------------------------------------------!
119 
120 CONTAINS
121 
122  SUBROUTINE initgravity(this,Mesh,Physics,gravity_name,config,IO)
123  IMPLICIT NONE
124  !------------------------------------------------------------------------!
125  CLASS(gravity_base), INTENT(INOUT) :: this
126  CLASS(mesh_base), INTENT(IN) :: Mesh
127  CLASS(physics_base), INTENT(IN) :: Physics
128  CHARACTER(LEN=*), INTENT(IN) :: gravity_name
129  TYPE(Dict_TYP),POINTER :: config,IO
130  !------------------------------------------------------------------------!
131  INTEGER :: gtype
132  !------------------------------------------------------------------------!
133  ! basic initialization of gravity module
134  CALL getattr(config, "gtype", gtype)
135  ! allocate memory for new gravity term
136  CALL this%InitLogging(gtype,gravity_name)
137  ALLOCATE(this%accel)
138  this%accel = marray_base(physics%VDIM)
139  ! reset acceleration
140  this%accel%data1d(:) = 0.0
141  CALL this%Info(" GRAVITY--> gravity term: " // this%GetName())
142  END SUBROUTINE initgravity
143 
144  SUBROUTINE setoutput(this,Mesh,Physics,config,IO)
145  IMPLICIT NONE
146  !------------------------------------------------------------------------!
147  CLASS(gravity_base), INTENT(INOUT) :: this
148  CLASS(mesh_base), INTENT(IN) :: Mesh
149  CLASS(physics_base), INTENT(IN) :: Physics
150  TYPE(Dict_TYP), POINTER :: config,IO
151  !------------------------------------------------------------------------!
152  CHARACTER(LEN=1) :: xyz(3) = (/"x","y","z"/)
153  INTEGER :: valwrite,k
154  !------------------------------------------------------------------------!
155  CALL getattr(config, "output/accel", valwrite, 1)
156  IF (valwrite .EQ. 1) THEN
157  DO k=1,SIZE(this%accel%data4d,4)
158  CALL setattr(io, ("accel_" // xyz(k)),&
159  this%accel%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,k))
160  END DO
161  END IF
162 
163  CALL getattr(config, "output/potential", valwrite, 1)
164  IF (valwrite .EQ. 1) &
165  CALL setattr(io, "potential",&
166  this%pot(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,1))
167 
168  END SUBROUTINE setoutput
169 
170  FUNCTION getgravitypointer(list,stype) RESULT(gp)
171  IMPLICIT NONE
172  !------------------------------------------------------------------------!
173  CLASS(gravity_base), TARGET :: list
174  INTEGER, INTENT(IN) :: stype
175  CLASS(gravity_base), POINTER :: gp
176  !------------------------------------------------------------------------!
177  gp => list
178  DO
179  IF (ASSOCIATED(gp).EQV..false.) EXIT
180 !CDIR IEXPAND
181  IF (gp%GetType().EQ.stype) RETURN
182  gp => gp%next
183  END DO
184  END FUNCTION getgravitypointer
185 
186  SUBROUTINE finalize_base(this)
187  IMPLICIT NONE
188  !------------------------------------------------------------------------!
189  CLASS(gravity_base) :: this
190  !------------------------------------------------------------------------!
191  ! nothing intializaed
192  CALL this%accel%Destroy()
193  DEALLOCATE(this%accel)
194  END SUBROUTINE finalize_base
195 
196 END MODULE gravity_base_mod
subroutine finalize(this)
Destructor of common class.
derived class for compound of mesh arrays
base class for mesh arrays
Definition: marray_base.f90:36
Basic fosite module.
common data structure
subroutine finalize_base(this)
generic gravity terms module providing functionaly common to all gravity terms
subroutine setoutput(this, Mesh, Physics, config, IO)
basic mesh array class
Definition: marray_base.f90:64
integer, parameter, public pointmass_binary
named integer constants for flavour of state vectors
Basic physics module.
Dictionary for generic data types.
Definition: common_dict.f90:61
integer, parameter, public spectral
class(gravity_base) function, pointer getgravitypointer(list, stype)
subroutine initgravity(this, Mesh, Physics, gravity_name, config, IO)
base module for numerical flux functions
Definition: fluxes_base.f90:39
integer, parameter, public pointmass
integer, parameter, public sboxspectral