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-2018 #
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 !----------------------------------------------------------------------------!
46  USE fluxes_base_mod
47  USE mesh_base_mod
48  USE marray_base_mod
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  !--------------------------------------------------------------------------!
66 
68  REAL :: sign1, sign2
69  INTEGER :: vel1, vel2
70  INTEGER :: i1, i2
71  INTEGER :: momentum1, momentum2
72  CONTAINS
73  PROCEDURE :: initsources_shearbox
74  PROCEDURE :: infosources
76  PROCEDURE :: finalize
77  END TYPE
78 
79  PUBLIC :: &
80  ! classes
82 
83 CONTAINS
84 
90  SUBROUTINE initsources_shearbox(this,Mesh,Physics,Fluxes,config,IO)
94  IMPLICIT NONE
95  !------------------------------------------------------------------------!
96  CLASS(sources_shearbox) :: this
97  CLASS(mesh_base), INTENT(IN) :: Mesh
98  CLASS(physics_base), INTENT(IN) :: Physics
99  CLASS(fluxes_base), INTENT(IN) :: Fluxes
100  TYPE(Dict_TYP), POINTER :: config, IO
101  !------------------------------------------------------------------------!
102  INTEGER :: stype
103  !------------------------------------------------------------------------!
104  CALL getattr(config,"stype",stype)
105  CALL this%InitLogging(stype,source_name)
106  CALL this%InitSources(mesh,fluxes,physics,config,io)
107 
108  SELECT TYPE(physics)
109  TYPE IS(physics_euler)
110  ! do nothing
111  TYPE IS(physics_eulerisotherm)
112  ! do nothing
113  CLASS DEFAULT
114  CALL this%Error("InitSources_shearbox","physics not supported")
115  END SELECT
116 
117  SELECT TYPE(geo=>mesh%Geometry)
118  TYPE IS(geometry_cartesian)
119  ! do nothing
120  CLASS DEFAULT
121  CALL this%Error("InitSources_shearbox","mesh not supported")
122  END SELECT
123 
124  this%accel = marray_base(physics%VDIM)
125  this%accel%data1d(:) = 0.
126 
127  IF(mesh%shear_dir.EQ.2) THEN
128  this%Vel1=physics%YVELOCITY
129  this%Vel2=physics%XVELOCITY
130  this%SIGN1 = 1.0
131  this%SIGN2 = -1.0
132  this%I1 = 1
133  this%I2 = 2
134  this%MOMENTUM1 = physics%XMOMENTUM
135  this%MOMENTUM2 = physics%YMOMENTUM
136  ELSE IF(mesh%shear_dir.EQ.1) THEN
137  this%Vel1=physics%XVELOCITY
138  this%Vel2=physics%YVELOCITY
139  this%SIGN1 = -1.0
140  this%SIGN2 = 1.0
141  this%I1 = 2
142  this%I2 = 1
143  this%MOMENTUM1 = physics%YMOMENTUM
144  this%MOMENTUM2 = physics%XMOMENTUM
145  END IF
146 
147  END SUBROUTINE initsources_shearbox
148 
150  SUBROUTINE infosources(this,Mesh)
151  IMPLICIT NONE
152  !------------------------------------------------------------------------!
153  CLASS(sources_shearbox), INTENT(IN) :: this
154  CLASS(mesh_base), INTENT(IN) :: Mesh
155  !------------------------------------------------------------------------!
156  CHARACTER(LEN=32) :: omega_str,q_str
157  !------------------------------------------------------------------------!
158  WRITE (omega_str,'(ES8.2)') mesh%OMEGA
159  WRITE (q_str,'(ES8.2)') mesh%Q
160  CALL this%Info(" angular velocity: " // trim(omega_str))
161  CALL this%Info(" shearing parameter:" // trim(q_str))
162  END SUBROUTINE infosources
163 
172  SUBROUTINE externalsources_single(this,Mesh,Physics,Fluxes,Sources,time,dt,pvar,cvar,sterm)
173  IMPLICIT NONE
174  !------------------------------------------------------------------------!
175  CLASS(sources_shearbox), INTENT(INOUT) :: this
176  CLASS(mesh_base), INTENT(IN) :: Mesh
177  CLASS(physics_base), INTENT(INOUT) :: Physics
178  CLASS(fluxes_base), INTENT(IN) :: Fluxes
179  CLASS(sources_base), INTENT(INOUT) :: Sources
180  REAL, INTENT(IN) :: time, dt
181  CLASS(marray_compound),INTENT(INOUT) :: pvar,cvar,sterm
182  !------------------------------------------------------------------------!
183  SELECT CASE(mesh%FARGO)
184  CASE(0)
185  ! fargo transport disabled
186 !NEC$ IVDEP
187  this%accel%data4d(:,:,:,this%I1) = 2*mesh%OMEGA &
188  * (mesh%Q*mesh%OMEGA*mesh%bcenter(:,:,:,this%I1) &
189  + this%SIGN1*pvar%data4d(:,:,:,this%VEL1))
190  this%accel%data4d(:,:,:,this%I2) = 2*mesh%OMEGA*this%SIGN2 &
191  * pvar%data4d(:,:,:,this%VEL2)
192  ! shearingsheet inertial forces source terms
193  CALL physics%ExternalSources(this%accel,pvar,cvar,sterm)
194  CASE(3)
195  ! fargo transport type 3 enabled
196  sterm%data2d(:,physics%DENSITY) = 0.0
197 !NEC$ IVDEP
198  sterm%data2d(:,this%MOMENTUM1) = pvar%data2d(:,physics%DENSITY) &
199  *mesh%OMEGA*2.0*this%SIGN1*pvar%data2d(:,this%VEL1)
200  sterm%data2d(:,this%MOMENTUM2) = pvar%data2d(:,physics%DENSITY) &
201  *mesh%OMEGA*(2.0-mesh%Q)*this%SIGN2*pvar%data2d(:,this%VEL2)
202  IF (physics%PRESSURE .GT. 0) THEN
203  sterm%data2d(:,physics%ENERGY) = &
204  this%SIGN1*pvar%data2d(:,physics%DENSITY)*mesh%Q*mesh%OMEGA* &
205  pvar%data2d(:,this%VEL2)*pvar%data2d(:,this%VEL1)
206  END IF
207  CASE DEFAULT
208  ! other fargo transport schemes are not supported
209  CALL this%Error("sources_shearbox::ExternalSources_single", &
210  "currently only Fargo transport type 3 is supported")
211  END SELECT
212  END SUBROUTINE externalsources_single
213 
215  SUBROUTINE finalize(this)
216  IMPLICIT NONE
217  !------------------------------------------------------------------------!
218  CLASS(sources_shearbox), INTENT(INOUT) :: this
219  !------------------------------------------------------------------------!
220  CALL this%accel%Destroy()
221  END SUBROUTINE finalize
222 
223 END MODULE sources_shearbox_mod
subroutine infosources(this, Mesh)
generic source terms module providing functionaly common to all source terms
source terms module for constant acceleration
derived class for compound of mesh arrays
base class for mesh arrays
Definition: marray_base.f90:36
character(len=32) source_name
basic mesh array class
Definition: marray_base.f90:64
physics module for 1D,2D and 3D isothermal Euler equations
Source terms module for fictious forces in a shearingsheet.
subroutine finalize(this)
defines properties of a 3D cartesian mesh
Basic physics module.
Dictionary for generic data types.
Definition: common_dict.f90:61
physics module for 1D,2D and 3D non-isothermal Euler equations
base module for numerical flux functions
Definition: fluxes_base.f90:39
subroutine externalsources_single(this, Mesh, Physics, Fluxes, Sources, time, dt, pvar, cvar, sterm)
subroutine initsources_shearbox(this, Mesh, Physics, Fluxes, config, IO)
Constructor of sources shearbox module.