sources_base.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: sources_generic.f90 #
5!# #
6!# Copyright (C) 2007-2021 #
7!# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
8!# Björn Sperling <sperling@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 this program; if not, write to the Free Software #
23!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
24!# #
25!#############################################################################
26!----------------------------------------------------------------------------!
33!----------------------------------------------------------------------------!
41!----------------------------------------------------------------------------!
50 USE common_dict
51#if defined(HAVE_FFTW)
52 USE fftw
53#endif
54 IMPLICIT NONE
55 !--------------------------------------------------------------------------!
56 PRIVATE
57 TYPE, ABSTRACT, EXTENDS(logging_base) :: sources_base
59 CLASS(sources_base), POINTER :: next => null()
60 REAL :: time
61 REAL :: cvis
62! REAL :: gparam !< geometry parameter
63! REAL, DIMENSION(:,:,:), POINTER :: invr !< 1./radius
64! INTEGER :: use_envelope !< enable vicosity envelope
65
66 CONTAINS
67
68 PROCEDURE :: initsources_base
69 procedure(initsources), DEFERRED :: initsources
70 procedure(externalsources), DEFERRED :: externalsources
71 procedure(calctimestep), DEFERRED :: calctimestep
72 PROCEDURE :: getsourcespointer
73 END TYPE sources_base
74 abstract INTERFACE
75 SUBROUTINE initsources(this,Mesh,Physics,Fluxes,config,IO)
77 IMPLICIT NONE
78 CLASS(sources_base), INTENT(INOUT) :: this
79 CLASS(mesh_base), INTENT(IN) :: Mesh
80 CLASS(physics_base), INTENT(IN) :: Physics
81 CLASS(fluxes_base), INTENT(IN) :: Fluxes
82 TYPE(dict_typ), POINTER :: config, IO
83 END SUBROUTINE
84 SUBROUTINE calctimestep(this,Mesh,Physics,Fluxes,pvar,cvar,time,dt,dtcause)
86 IMPLICIT NONE
87 !------------------------------------------------------------------------!
88 CLASS(sources_base),INTENT(INOUT) :: this
89 CLASS(mesh_base),INTENT(IN) :: Mesh
90 CLASS(physics_base),INTENT(INOUT) :: Physics
91 CLASS(fluxes_base),INTENT(IN) :: Fluxes
92 CLASS(marray_compound),INTENT(INOUT):: pvar,cvar
93 REAL,INTENT(IN) :: time
94 REAL, INTENT(INOUT) :: dt
95 INTEGER, INTENT(OUT) :: dtcause
96 END SUBROUTINE
97 SUBROUTINE externalsources(this,Mesh,Physics,Fluxes,Sources,time,dt,pvar,cvar,sterm)
99 IMPLICIT NONE
100 !------------------------------------------------------------------------!
101 CLASS(sources_base),INTENT(INOUT) :: this
102 CLASS(mesh_base),INTENT(IN) :: Mesh
103 CLASS(physics_base),INTENT(INOUT) :: Physics
104 CLASS(fluxes_base),INTENT(IN) :: Fluxes
105 CLASS(sources_base), INTENT(INOUT) :: Sources
106 REAL,INTENT(IN) :: time, dt
107 CLASS(marray_compound),INTENT(INOUT):: pvar,cvar,sterm
108 END SUBROUTINE
109 SUBROUTINE finalize(this)
110 IMPORT sources_base
111 IMPLICIT NONE
112 !------------------------------------------------------------------------!
113 CLASS(sources_base),INTENT(INOUT) :: this
114 END SUBROUTINE
115 END INTERFACE
116 !--------------------------------------------------------------------------!
117 PUBLIC :: &
118 ! types
120 !--------------------------------------------------------------------------!
121
122CONTAINS
123
125 SUBROUTINE initsources_base(this,stype,sname)
126 IMPLICIT NONE
127 !------------------------------------------------------------------------!
128 CLASS(sources_base), INTENT(INOUT) :: this
129 INTEGER, INTENT(IN) :: stype
130 CHARACTER(LEN=*), INTENT(IN) :: sname
131 !------------------------------------------------------------------------!
132 IF (this%Initialized()) &
133 CALL this%Error("sources_base::InitSources_base","source term already initialized")
134 CALL this%InitLogging(stype,sname)
135 CALL this%Info(" SOURCES--> source term: " // this%GetName())
136! CALL this%InfoSources(Mesh)
137 END SUBROUTINE initsources_base
138
139
141 FUNCTION getsourcespointer(this,stype) RESULT(sp)
142 IMPLICIT NONE
143 !------------------------------------------------------------------------!
144 CLASS(sources_base), TARGET, INTENT(IN) :: this
145 CLASS(sources_base), POINTER :: sp
146 INTEGER, INTENT(IN) :: stype
147 !------------------------------------------------------------------------!
148 sp => this
149 DO WHILE (ASSOCIATED(sp))
150!CDIR IEXPAND
151 IF (sp%GetType().EQ.stype) EXIT
152 sp => sp%next
153 END DO
154 END FUNCTION getsourcespointer
155
156
157! !> Destructor
158! SUBROUTINE Finalize_base(this)
159! IMPLICIT NONE
160! !------------------------------------------------------------------------!
161! CLASS(sources_base), INTENT(INOUT) :: this
162! !------------------------------------------------------------------------!
163! IF (.NOT.this%Initialized()) &
164! CALL this%Error("sources_base::Finalize_base"," called for uninitialized sources")
165! IF(ASSOCIATED(temp_sterm)) DEALLOCATE(temp_sterm)
166! END SUBROUTINE Finalize_base
167
168END MODULE sources_base_mod
Dictionary for generic data types.
Definition: common_dict.f90:61
type(logging_base), save this
fftw module
Definition: fftw.f90:29
base module for numerical flux functions
Definition: fluxes_base.f90:39
generic gravity terms module providing functionaly common to all gravity terms
Basic fosite module.
subroutine finalize(this)
Destructor of logging_base class.
base class for mesh arrays
Definition: marray_base.f90:36
derived class for compound of mesh arrays
basic mesh module
Definition: mesh_base.f90:72
Basic physics module.
generic source terms module providing functionaly common to all source terms
class(sources_base) function, pointer getsourcespointer(this, stype)
return pointer to requested source term
subroutine initsources_base(this, stype, sname)
Initialize data in sources.
common data structure
mesh data structure
Definition: mesh_base.f90:122