sources_shearbox.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: sources_shearbox.f90 #
5!# #
6!# Copyright (C) 2010-2024 #
7!# Jannes Klee <jklee@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 this program; if not, write to the Free Software #
23!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
24!# #
25!#############################################################################
26!----------------------------------------------------------------------------!
34!----------------------------------------------------------------------------!
41!----------------------------------------------------------------------------!
50 USE common_dict
51#ifdef PARALLEL
52#ifdef HAVE_MPI_MOD
53 USE mpi
54#endif
55#endif
56 IMPLICIT NONE
57#ifdef PARALLEL
58#ifdef HAVE_MPIF_H
59 include 'mpif.h'
60#endif
61#endif
62 !--------------------------------------------------------------------------!
63 PRIVATE
64 CHARACTER(LEN=32) :: source_name = "forces in shearing-box"
65 !--------------------------------------------------------------------------!
67 REAL :: sign1, sign2
68 INTEGER :: vel1, vel2
69 INTEGER :: i1, i2
70 INTEGER :: momentum1, momentum2
71 CONTAINS
72 PROCEDURE :: initsources
73 PROCEDURE :: infosources
74 PROCEDURE :: externalsources
75 END TYPE
76
77 PUBLIC :: &
78 ! classes
80
81CONTAINS
82
88 SUBROUTINE initsources(this,Mesh,Physics,Fluxes,config,IO)
92 IMPLICIT NONE
93 !------------------------------------------------------------------------!
94 CLASS(sources_shearbox),INTENT(INOUT) :: this
95 CLASS(mesh_base), INTENT(IN) :: Mesh
96 CLASS(physics_base), INTENT(IN) :: Physics
97 CLASS(fluxes_base), INTENT(IN) :: Fluxes
98 TYPE(dict_typ), POINTER :: config, IO
99 !------------------------------------------------------------------------!
100 INTEGER :: stype
101 !------------------------------------------------------------------------!
102 CALL getattr(config,"stype",stype)
103 CALL this%InitSources_base(stype,source_name)
104
105 SELECT TYPE(physics)
106 TYPE IS(physics_euler)
107 ! do nothing
108 TYPE IS(physics_eulerisotherm)
109 ! do nothing
110 CLASS DEFAULT
111 CALL this%Error("InitSources_shearbox","physics not supported")
112 END SELECT
113
114 SELECT TYPE(geo=>mesh%Geometry)
115 TYPE IS(geometry_cartesian)
116 ! do nothing
117 CLASS DEFAULT
118 CALL this%Error("InitSources_shearbox","mesh not supported")
119 END SELECT
120
121 ALLOCATE(this%accel)
122 this%accel = marray_base(physics%VDIM)
123 this%accel%data1d(:) = 0.
124
125 IF(mesh%shear_dir.EQ.2) THEN
126 this%Vel1=physics%YVELOCITY
127 this%Vel2=physics%XVELOCITY
128 this%SIGN1 = 1.0
129 this%SIGN2 = -1.0
130 this%I1 = 1
131 this%I2 = 2
132 this%MOMENTUM1 = physics%XMOMENTUM
133 this%MOMENTUM2 = physics%YMOMENTUM
134 ELSE IF(mesh%shear_dir.EQ.1) THEN
135 this%Vel1=physics%XVELOCITY
136 this%Vel2=physics%YVELOCITY
137 this%SIGN1 = -1.0
138 this%SIGN2 = 1.0
139 this%I1 = 2
140 this%I2 = 1
141 this%MOMENTUM1 = physics%YMOMENTUM
142 this%MOMENTUM2 = physics%XMOMENTUM
143 END IF
144
145 ! set vertical gravitational acceleration for 3D shearing
146 ! box simulations using bary center cartesian z-coordinate
147 IF (mesh%KNUM.GT.1) THEN
148 this%accel%data2d(:,3) = -mesh%OMEGA**2 * mesh%cart%data3d(:,2,3)
149 END IF
150
151 ! print some information
152 CALL this%InfoSources(mesh)
153 END SUBROUTINE initsources
154
156 SUBROUTINE infosources(this,Mesh)
157 IMPLICIT NONE
158 !------------------------------------------------------------------------!
159 CLASS(sources_shearbox), INTENT(IN) :: this
160 CLASS(mesh_base), INTENT(IN) :: Mesh
161 !------------------------------------------------------------------------!
162 CHARACTER(LEN=32) :: omega_str,q_str
163 !------------------------------------------------------------------------!
164 WRITE (omega_str,'(ES10.2)') mesh%OMEGA
165 WRITE (q_str,'(ES10.2)') mesh%Q
166 CALL this%Info(" angular velocity: " // trim(omega_str))
167 CALL this%Info(" shearing parameter:" // trim(q_str))
168 END SUBROUTINE infosources
169
178 SUBROUTINE externalsources(this,Mesh,Physics,Fluxes,Sources,time,dt,pvar,cvar,sterm)
179 IMPLICIT NONE
180 !------------------------------------------------------------------------!
181 CLASS(sources_shearbox), INTENT(INOUT) :: this
182 CLASS(mesh_base), INTENT(IN) :: Mesh
183 CLASS(physics_base), INTENT(INOUT) :: Physics
184 CLASS(fluxes_base), INTENT(IN) :: Fluxes
185 CLASS(sources_base), INTENT(INOUT) :: Sources
186 REAL, INTENT(IN) :: time, dt
187 CLASS(marray_compound),INTENT(INOUT) :: pvar,cvar,sterm
188 !------------------------------------------------------------------------!
189 SELECT CASE(mesh%fargo%GetType())
190 CASE(0)
191 ! fargo transport disabled
192!NEC$ IVDEP
193 this%accel%data4d(:,:,:,this%I1) = 2*mesh%OMEGA &
194 * (mesh%Q*mesh%OMEGA*mesh%bcenter(:,:,:,this%I1) &
195 + this%SIGN1*pvar%data4d(:,:,:,this%VEL1))
196 this%accel%data4d(:,:,:,this%I2) = 2*mesh%OMEGA*this%SIGN2 &
197 * pvar%data4d(:,:,:,this%VEL2)
198 ! shearingsheet inertial forces source terms
199 CALL physics%ExternalSources(this%accel,pvar,cvar,sterm)
200 CASE(3)
201 ! fargo transport type 3 enabled
202 sterm%data2d(:,physics%DENSITY) = 0.0
203!NEC$ IVDEP
204 sterm%data2d(:,this%MOMENTUM1) = pvar%data2d(:,physics%DENSITY) &
205 *mesh%OMEGA*2.0*this%SIGN1*pvar%data2d(:,this%VEL1)
206 sterm%data2d(:,this%MOMENTUM2) = pvar%data2d(:,physics%DENSITY) &
207 *mesh%OMEGA*(2.0-mesh%Q)*this%SIGN2*pvar%data2d(:,this%VEL2)
208 IF (mesh%KNUM.GT.1) &
209 sterm%data2d(:,physics%ZMOMENTUM) = pvar%data2d(:,physics%DENSITY) &
210 *this%accel%data2d(:,3)
211 IF (physics%PRESSURE .GT. 0) THEN
212 sterm%data2d(:,physics%ENERGY) = &
213 this%SIGN1*pvar%data2d(:,physics%DENSITY)*mesh%Q*mesh%OMEGA* &
214 pvar%data2d(:,this%VEL2)*pvar%data2d(:,this%VEL1)
215 IF (mesh%KNUM.GT.1) &
216 sterm%data2d(:,physics%ENERGY) = sterm%data2d(:,physics%ENERGY) &
217 + cvar%data2d(:,physics%ZMOMENTUM)*this%accel%data2d(:,3)
218 END IF
219 CASE DEFAULT
220 ! other fargo transport schemes are not supported
221 CALL this%Error("sources_shearbox::ExternalSources_single", &
222 "currently only Fargo transport type 3 is supported")
223 END SELECT
224 END SUBROUTINE externalsources
225
226END MODULE sources_shearbox_mod
Dictionary for generic data types.
Definition: common_dict.f90:61
base module for numerical flux functions
Definition: fluxes_base.f90:39
defines properties of a 3D cartesian mesh
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.
physics module for 1D,2D and 3D non-isothermal Euler equations
physics module for 1D,2D and 3D isothermal Euler equations
generic source terms module providing functionaly common to all source terms
source terms module for constant acceleration
character(len=32), parameter source_name
subroutine externalsources(this, Mesh, Physics, Fluxes, Sources, time, dt, pvar, cvar, sterm)
subroutine initsources(this, Mesh, Physics, Fluxes, config, IO)
Source terms module for fictious forces in a shearingsheet.
subroutine infosources(this, Mesh)
Write shearbox fictious forces parameters to screen.
basic mesh array class
Definition: marray_base.f90:69
mesh data structure
Definition: mesh_base.f90:122