FE-Project
Loading...
Searching...
No Matches
scale_atm_dyn_dgm_globalnonhydro3d_etot_heve.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Fluid dyn solver / Atmosphere / Global nonhydrostatic model / HEVE
3!!
4!! @par Description
5!! HEVE DGM scheme for Global Atmospheric Dynamical process.
6!! The governing equations is a fully compressible nonhydrostatic equations,
7!! which consist of mass, momentum, and thermodynamics (total energy conservation) equations.
8!!
9!! @author Yuta Kawai, Team SCALE
10!<
11!-------------------------------------------------------------------------------
12#include "scaleFElib.h"
14 !-----------------------------------------------------------------------------
15 !
16 !++ Used modules
17 !
18 use scale_precision
19 use scale_io
20 use scale_prc
21 use scale_prof
22 use scale_const, only: &
23 grav => const_grav, &
24 rdry => const_rdry, &
25 cpdry => const_cpdry, &
26 cvdry => const_cvdry, &
27 pres00 => const_pre00
28
30 use scale_element_base, only: &
40
44 dens_vid => prgvar_ddens_id, etot_vid => prgvar_etot_id, &
45 momx_vid => prgvar_momx_id, momy_vid => prgvar_momy_id, &
46 momz_vid => prgvar_momz_id, &
48
49 !-----------------------------------------------------------------------------
50 implicit none
51 private
52 !-----------------------------------------------------------------------------
53 !
54 !++ Public procedures
55 !
59
60 !-----------------------------------------------------------------------------
61 !
62 !++ Public parameters & variables
63 !
64
65 !-----------------------------------------------------------------------------
66 !
67 !++ Private procedures & variables
68 !
69 !-------------------
70
71contains
72!OCL SERIAL
74
75 implicit none
76 class(meshbase3d), intent(in) :: mesh
77 !--------------------------------------------
78
80 return
82
83!OCL SERIAL
85 implicit none
86 !--------------------------------------------
87
89 return
91
92 !-------------------------------
93
94!OCL SERIAL
96 DENS_dt, MOMX_dt, MOMY_dt, MOMZ_dt, EnTot_dt, & ! (out)
97 ddens_, momx_, momy_, momz_, etot_, dpres_, & ! (in)
98 dens_hyd, pres_hyd, pres_hyd_ref, therm_hyd, & ! (in)
99 coriolis, rtot, cvtot, cptot, dphyddx, dphyddy, & ! (in)
100 element3d_operation, dx, dy, dz, sx, sy, sz, lift, & ! (in)
101 lmesh, elem, lmesh2d, elem2d ) ! (in)
102
105 use scale_const, only: &
106 ohm => const_ohm
107 implicit none
108
109 class(localmesh3d), intent(in) :: lmesh
110 class(elementbase3d), intent(in) :: elem
111 class(localmesh2d), intent(in) :: lmesh2d
112 class(elementbase2d), intent(in) :: elem2d
113 class(elementoperationbase3d), intent(in) :: element3d_operation
114 type(sparsemat), intent(in) :: dx, dy, dz, sx, sy, sz, lift
115 real(rp), intent(out) :: dens_dt(elem%np,lmesh%nea)
116 real(rp), intent(out) :: momx_dt(elem%np,lmesh%nea)
117 real(rp), intent(out) :: momy_dt(elem%np,lmesh%nea)
118 real(rp), intent(out) :: momz_dt(elem%np,lmesh%nea)
119 real(rp), intent(out) :: entot_dt(elem%np,lmesh%nea)
120 real(rp), intent(in) :: ddens_(elem%np,lmesh%nea)
121 real(rp), intent(in) :: momx_(elem%np,lmesh%nea)
122 real(rp), intent(in) :: momy_(elem%np,lmesh%nea)
123 real(rp), intent(in) :: momz_(elem%np,lmesh%nea)
124 real(rp), intent(in) :: etot_(elem%np,lmesh%nea)
125 real(rp), intent(in) :: dpres_(elem%np,lmesh%nea)
126 real(rp), intent(in) :: dens_hyd(elem%np,lmesh%nea)
127 real(rp), intent(in) :: pres_hyd(elem%np,lmesh%nea)
128 real(rp), intent(in) :: pres_hyd_ref(elem%np,lmesh%nea)
129 real(rp), intent(in) :: therm_hyd(elem%np,lmesh%nea)
130 real(rp), intent(in) :: coriolis(elem2d%np,lmesh2d%nea)
131 real(rp), intent(in) :: rtot (elem%np,lmesh%nea)
132 real(rp), intent(in) :: cvtot(elem%np,lmesh%nea)
133 real(rp), intent(in) :: cptot(elem%np,lmesh%nea)
134 real(rp), intent(in) :: dphyddx(elem%np,lmesh%nea)
135 real(rp), intent(in) :: dphyddy(elem%np,lmesh%nea)
136
137 real(rp) :: fx(elem%np), fy(elem%np), fz(elem%np), liftdelflx(elem%np)
138 real(rp) :: dpres_hyd(elem%np), gradphyd_x(elem%np), gradphyd_y(elem%np)
139 real(rp) :: del_flux(elem%nfptot,lmesh%ne,prgvar_num)
140 real(rp) :: del_flux_hyd(elem%nfptot,lmesh%ne,2)
141 real(rp) :: rdens_(elem%np), u_(elem%np), v_(elem%np), w_(elem%np), wt_(elem%np), drho(elem%np)
142
143 real(rp) :: g11(elem%np), g12(elem%np), g22(elem%np)
144 real(rp) :: gsqrtv(elem%np), rgsqrtv(elem%np)
145 real(rp) :: x2d(elem2d%np,lmesh2d%ne), y2d(elem2d%np,lmesh2d%ne)
146 real(rp) :: x(elem%np), y(elem%np), twoovdel2(elem%np)
147 real(rp) :: cori(elem%np,2)
148 logical :: is_panel1to4
149 real(rp) :: s
150
151 integer :: ke, ke2d
152 integer :: p, p12, p3
153
154 real(rp) :: gamm, rgamm
155 real(rp) :: rp0
156 real(rp) :: rovp0, p0ovr
157
158 real(rp) :: enthalpy_(elem%np)
159 real(rp) :: u1_(elem%np), u2_(elem%np)
160 !------------------------------------------------------------------------
161
162 call prof_rapstart('cal_dyn_tend_bndflux', 3)
163 call get_ebnd_flux( &
164 del_flux, del_flux_hyd, & ! (out)
165 ddens_, momx_, momy_, momz_, etot_, dpres_, dens_hyd, pres_hyd, & ! (in)
166 rtot, cvtot, cptot, & ! (in)
167 lmesh%Gsqrt, lmesh%GIJ(:,:,1,1), lmesh%GIJ(:,:,1,2), lmesh%GIJ(:,:,2,2), & ! (in)
168 lmesh%G_ij(:,:,1,1), lmesh%G_ij(:,:,1,2), lmesh%G_ij(:,:,2,2), & ! (in)
169 lmesh%GsqrtH, lmesh%GI3(:,:,1), lmesh%GI3(:,:,2), lmesh%zlev(:,:), & ! (in)
170 lmesh%normal_fn(:,:,1), lmesh%normal_fn(:,:,2), lmesh%normal_fn(:,:,3), & ! (in)
171 lmesh%vmapM, lmesh%vmapP, elem%IndexH2Dto3D_bnd, & ! (in)
172 lmesh, elem, lmesh2d, elem2d ) ! (in)
173 call prof_rapend('cal_dyn_tend_bndflux', 3)
174
175 !-----
176 call prof_rapstart('cal_dyn_tend_interior', 3)
177 gamm = cpdry / cvdry
178 rgamm = cvdry / cpdry
179 rp0 = 1.0_rp / pres00
180 rovp0 = rdry * rp0
181 p0ovr = pres00 / rdry
182
183 s = 1.0_rp
184 is_panel1to4 = .true.
185 if ( lmesh%panelID == 5 ) then
186 is_panel1to4 = .false.
187 else if ( lmesh%panelID == 6 ) then
188 is_panel1to4 = .false.
189 s = - 1.0_rp
190 end if
191
192 !$omp parallel private( &
193 !$omp rdens_, u_, v_, w_, wt_, &
194 !$omp enthalpy_, u1_, u2_, &
195 !$omp Fx, Fy, Fz, LiftDelFlx, &
196 !$omp drho, DPRES_hyd, GradPhyd_x, GradPhyd_y, &
197 !$omp G11, G12, G22, GsqrtV, RGsqrtV, &
198 !$omp X, Y, twoOVdel2, &
199 !$omp CORI, ke, ke2D )
200
201 !$omp do
202 do ke2d = lmesh2d%NeS, lmesh2d%NeE
203 x2d(:,ke2d) = tan(lmesh2d%pos_en(:,ke2d,1))
204 y2d(:,ke2d) = tan(lmesh2d%pos_en(:,ke2d,2))
205 end do
206
207 !$omp do
208 do ke = lmesh%NeS, lmesh%NeE
209 !--
210 ke2d = lmesh%EMap3Dto2D(ke)
211 g11(:) = lmesh%GIJ(elem%IndexH2Dto3D,ke2d,1,1)
212 g12(:) = lmesh%GIJ(elem%IndexH2Dto3D,ke2d,1,2)
213 g22(:) = lmesh%GIJ(elem%IndexH2Dto3D,ke2d,2,2)
214 gsqrtv(:) = lmesh%Gsqrt(:,ke) / lmesh%GsqrtH(elem%IndexH2Dto3D,ke2d)
215 rgsqrtv(:) = 1.0_rp / gsqrtv(:)
216
217 !--
218 rdens_(:) = 1.0_rp / ( ddens_(:,ke) + dens_hyd(:,ke) )
219 u_(:) = momx_(:,ke) * rdens_(:)
220 v_(:) = momy_(:,ke) * rdens_(:)
221 w_(:) = momz_(:,ke) * rdens_(:)
222 wt_(:) = w_(:) * rgsqrtv(:) + lmesh%GI3(:,ke,1) * u_(:) + lmesh%GI3(:,ke,2) * v_(:)
223 u1_(:) = lmesh%G_ij(elem%IndexH2Dto3D(:),ke2d,1,1) * u_(:) + lmesh%G_ij(elem%IndexH2Dto3D(:),ke2d,2,1) * v_(:)
224 u2_(:) = lmesh%G_ij(elem%IndexH2Dto3D(:),ke2d,2,1) * u_(:) + lmesh%G_ij(elem%IndexH2Dto3D(:),ke2d,2,2) * v_(:)
225
226 ! DPRES_(:) = ( CPtot(:,ke) / CVtot(:,ke) - 1.0_RP ) &
227 ! * ( ETOT_(:,ke) - Grav * ( DDENS_(:,ke) + DENS_hyd(:,ke) ) * lmesh%zlev(:,ke) &
228 ! - 0.5_RP * ( MOMX_(:,ke) * u1_(:) + MOMY_(:,ke) * u2_(:) + MOMZ_(:,ke) * w_(:) ) ) &
229 ! - PRES_hyd(:,ke)
230
231 enthalpy_(:) = etot_(:,ke) + pres_hyd(:,ke) + dpres_(:,ke)
232
233 x(:) = x2d(elem%IndexH2Dto3D,ke2d)
234 y(:) = y2d(elem%IndexH2Dto3D,ke2d)
235 twoovdel2(:) = 2.0_rp / ( 1.0_rp + x(:)**2 + y(:)**2 )
236
237 cori(:,1) = s * ohm * twoovdel2(:) * ( - x(:) * y(:) * momx_(:,ke) + (1.0_rp + y(:)**2) * momy_(:,ke) )
238 cori(:,2) = s * ohm * twoovdel2(:) * ( - (1.0_rp + x(:)**2) * momx_(:,ke) + x(:) * y(:) * momy_(:,ke) )
239
240 if ( is_panel1to4 ) then
241 cori(:,1) = s * y(:) * cori(:,1)
242 cori(:,2) = s * y(:) * cori(:,2)
243 end if
244
245 drho(:) = matmul(intrpmat_vpordm1, ddens_(:,ke))
246
247 !-- Gradient hydrostatic pressure
248
249 dpres_hyd(:) = pres_hyd(:,ke) - pres_hyd_ref(:,ke)
250
251 call sparsemat_matmul(dx, gsqrtv(:) * dpres_hyd(:), fx)
252 call sparsemat_matmul(dz, gsqrtv(:) * lmesh%GI3(:,ke,1) * dpres_hyd(:), fz)
253 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux_hyd(:,ke,1), liftdelflx)
254 gradphyd_x(:) = lmesh%Escale(:,ke,1,1) * fx(:) &
255 + lmesh%Escale(:,ke,3,3) * fz(:) &
256 + liftdelflx(:)
257
258 call sparsemat_matmul(dy, gsqrtv(:) * dpres_hyd(:), fy)
259 call sparsemat_matmul(dz, gsqrtv(:) * lmesh%GI3(:,ke,2) * dpres_hyd(:), fz)
260 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux_hyd(:,ke,2), liftdelflx)
261 gradphyd_y(:) = lmesh%Escale(:,ke,2,2) * fy(:) &
262 + lmesh%Escale(:,ke,3,3) * fz(:) &
263 + liftdelflx(:)
264
265 !-- DENS
266 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * momx_(:,ke), fx)
267 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * momy_(:,ke), fy)
268 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( ddens_(:,ke) + dens_hyd(:,ke) ) * wt_(:), fz)
269 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,dens_vid), liftdelflx)
270
271 dens_dt(:,ke) = - ( &
272 lmesh%Escale(:,ke,1,1) * fx(:) &
273 + lmesh%Escale(:,ke,2,2) * fy(:) &
274 + lmesh%Escale(:,ke,3,3) * fz(:) &
275 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke)
276
277 !-- MOMX
278 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * ( u_(:) * momx_(:,ke) + g11(:) * dpres_(:,ke) ), fx)
279 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * ( v_(:) * momx_(:,ke) + g12(:) * dpres_(:,ke) ), fy)
280 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( wt_(:) * momx_(:,ke) &
281 + ( lmesh%GI3(:,ke,1) * g11(:) + lmesh%GI3(:,ke,2) * g12(:) ) * dpres_(:,ke) ), fz)
282 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,momx_vid), liftdelflx)
283
284 momx_dt(:,ke) = &
285 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
286 + lmesh%Escale(:,ke,2,2) * fy(:) &
287 + lmesh%Escale(:,ke,3,3) * fz(:) &
288 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke) &
289 + twoovdel2(:) * y(:) * &
290 ( - x(:) * y(:) * u_(:) + (1.0_rp + y(:)**2) * v_(:) ) * momx_(:,ke) &
291 - ( g11(:) * gradphyd_x(:) + g12(:) * gradphyd_y(:) ) * rgsqrtv(:) &
292 + cori(:,1)
293
294 !-- MOMY
295 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * ( u_(:) * momy_(:,ke) + g12(:) * dpres_(:,ke) ), fx)
296 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * ( v_(:) * momy_(:,ke) + g22(:) * dpres_(:,ke) ), fy)
297 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( wt_(:) * momy_(:,ke) &
298 + ( lmesh%GI3(:,ke,1) * g12(:) + lmesh%GI3(:,ke,2) * g22(:) ) * dpres_(:,ke) ), fz)
299 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,momy_vid), liftdelflx)
300
301 momy_dt(:,ke) = &
302 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
303 + lmesh%Escale(:,ke,2,2) * fy(:) &
304 + lmesh%Escale(:,ke,3,3) * fz(:) &
305 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke) &
306 + twoovdel2(:) * x(:) * &
307 ( (1.0_rp + x(:)**2) * u_(:) - x(:) * y(:) * v_(:) ) * momy_(:,ke) &
308 - ( g12(:) * gradphyd_x(:) + g22(:) * gradphyd_y(:) ) * rgsqrtv(:) &
309 + cori(:,2)
310
311 !-- MOMZ
312 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * u_(:) * momz_(:,ke), fx)
313 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * v_(:) * momz_(:,ke), fy)
314 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( wt_(:) * momz_(:,ke) + rgsqrtv(:) * dpres_(:,ke) ), fz)
315 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,momz_vid), liftdelflx)
316
317 momz_dt(:,ke) = &
318 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
319 + lmesh%Escale(:,ke,2,2) * fy(:) &
320 + lmesh%Escale(:,ke,3,3) * fz(:) &
321 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke) &
322 - grav * drho(:)
323
324 !-- EnTot
325 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * u_(:) * enthalpy_(:), fx)
326 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * v_(:) * enthalpy_(:), fy)
327 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * wt_(:) * enthalpy_(:), fz)
328 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,etot_vid), liftdelflx)
329
330 entot_dt(:,ke) = &
331 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
332 + lmesh%Escale(:,ke,2,2) * fy(:) &
333 + lmesh%Escale(:,ke,3,3) * fz(:) &
334 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke)
335 end do
336 !$omp end do
337 !$omp end parallel
338 call prof_rapend('cal_dyn_tend_interior', 3)
339
340 return
342
module FElib / Fluid dyn solver / Atmosphere / Global nonhydrostatic model / HEVE
subroutine, public atm_dyn_dgm_globalnonhydro3d_etot_heve_cal_tend(dens_dt, momx_dt, momy_dt, momz_dt, entot_dt, ddens_, momx_, momy_, momz_, etot_, dpres_, dens_hyd, pres_hyd, pres_hyd_ref, therm_hyd, coriolis, rtot, cvtot, cptot, dphyddx, dphyddy, element3d_operation, dx, dy, dz, sx, sy, sz, lift, lmesh, elem, lmesh2d, elem2d)
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / Common
subroutine, public atm_dyn_dgm_nonhydro3d_common_init(mesh)
Initialize a common module for atmospheric nonhydrostatic dynamical core.
real(rp), dimension(:,:), allocatable, public intrpmat_vpordm1
subroutine, public atm_dyn_dgm_nonhydro3d_common_final()
Finalize a common module for atmospheric nonhydrostatic dynamical core.
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / Numflux
subroutine, public atm_dyn_dgm_nonhydro3d_etot_heve_numflux_get_generalhvc(del_flux, del_flux_hyd, ddens_, momx_, momy_, momz_, etot_, dpres_, dens_hyd, pres_hyd, rtot, cvtot, cptot, gsqrt, g11, g12, g22, g_11, g_12, g_22, gsqrth, g13, g23, zlev, nx, ny, nz, vmapm, vmapp, im2dto3d, lmesh, elem, lmesh2d, elem2d)
module FElib / Element / Base
module FElib / Element / hexahedron
module FElib / Element / Operation / Base
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Data / base
Module common / sparsemat.
Derived type representing a 2D reference element.
Derived type representing a 3D reference element.
Derived type representing a hexahedral element.
Derived type representing a local mesh for 2D domain.
Derived type to manage a local 3D computational domain.
Derived type representing a field with 3D local mesh.
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a computational mesh (base type for 3D domain)
Derived type representing a field with 3D mesh.
Derived type to manage a sparse matrix.