FE-Project
Loading...
Searching...
No Matches
scale_atm_dyn_dgm_globalnonhydro3d_rhot_heve_gpu.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 (density * potential temperature conservation) equations.
8!!
9!! @author Yuta Kawai, Xuanzhengbo Ren, and 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 rplanet => const_radius
29
31 use scale_element_base, only: &
41
45 dens_vid => prgvar_ddens_id, rhot_vid => prgvar_drhot_id, &
46 momx_vid => prgvar_momx_id, momy_vid => prgvar_momy_id, &
47 momz_vid => prgvar_momz_id, &
49
50 !-----------------------------------------------------------------------------
51 implicit none
52 private
53 !-----------------------------------------------------------------------------
54 !
55 !++ Public procedures
56 !
61
62 !-----------------------------------------------------------------------------
63 !
64 !++ Public parameters & variables
65 !
66
67 !-----------------------------------------------------------------------------
68 !
69 !++ Private procedures & variables
70 !
71 !-------------------
72
73contains
74!OCL SERIAL
76 implicit none
77 class(meshbase3d), intent(in) :: mesh
78 !--------------------------------------------
79
81
82 return
84
85!OCL SERIAL
87 implicit none
88 !--------------------------------------------
89
91 return
93
94 !-------------------------------
95
96 !OCL SERIAL
98 DENS_dt, MOMX_dt, MOMY_dt, MOMZ_dt, RHOT_dt, & ! (out)
99 ddens_, momx_, momy_, momz_, drhot_, dpres_, & ! (in)
100 dens_hyd, pres_hyd, pres_hyd_ref, therm_hyd, & ! (in)
101 coriolis, rtot, cvtot, cptot, dphyddx, dphyddy, & ! (in)
102 element3d_operation, dx, dy, dz, sx, sy, sz, lift, & ! (in)
103 lmesh, elem, lmesh2d, elem2d ) ! (in)
104
109 implicit none
110
111 class(localmesh3d), intent(in) :: lmesh
112 class(elementbase3d), intent(in) :: elem
113 class(localmesh2d), intent(in) :: lmesh2d
114 class(elementbase2d), intent(in) :: elem2d
115 class(elementoperationbase3d), intent(in) :: element3d_operation
116 type(sparsemat), intent(in) :: dx, dy, dz, sx, sy, sz, lift
117 real(rp), intent(out) :: dens_dt(elem%np,lmesh%nea)
118 real(rp), intent(out) :: momx_dt(elem%np,lmesh%nea)
119 real(rp), intent(out) :: momy_dt(elem%np,lmesh%nea)
120 real(rp), intent(out) :: momz_dt(elem%np,lmesh%nea)
121 real(rp), intent(out) :: rhot_dt(elem%np,lmesh%nea)
122 real(rp), intent(in) :: ddens_(elem%np,lmesh%nea)
123 real(rp), intent(in) :: momx_(elem%np,lmesh%nea)
124 real(rp), intent(in) :: momy_(elem%np,lmesh%nea)
125 real(rp), intent(in) :: momz_(elem%np,lmesh%nea)
126 real(rp), intent(in) :: drhot_(elem%np,lmesh%nea)
127 real(rp), intent(in) :: dpres_(elem%np,lmesh%nea)
128 real(rp), intent(in) :: dens_hyd(elem%np,lmesh%nea)
129 real(rp), intent(in) :: pres_hyd(elem%np,lmesh%nea)
130 real(rp), intent(in) :: pres_hyd_ref(elem%np,lmesh%nea)
131 real(rp), intent(in) :: therm_hyd(elem%np,lmesh%nea)
132 real(rp), intent(in) :: coriolis(elem2d%np,lmesh2d%nea)
133 real(rp), intent(in) :: rtot (elem%np,lmesh%nea)
134 real(rp), intent(in) :: cvtot(elem%np,lmesh%nea)
135 real(rp), intent(in) :: cptot(elem%np,lmesh%nea)
136 real(rp), intent(in) :: dphyddx(elem%np,lmesh%nea)
137 real(rp), intent(in) :: dphyddy(elem%np,lmesh%nea)
138
139 type(elementoperationgpudriver) :: element3d_operation_driver
140 real(rp) :: tend_tmp(elem%nnode_h1d**2,5,elem%nnode_v,lmesh%ne)
141 real(rp) :: flux2d(elem%nnode_h1d**2,5,elem%nnode_v,lmesh%ne,2)
142 real(rp) :: fluxz_store(elem%nnode_h1d**2,5,elem%nnode_v,lmesh%ne)
143 real(rp) :: del_flux(elem%nfptot,prgvar_num,lmesh%ne)
144 real(rp) :: drho(elem%np,lmesh%ne)
145
146 integer :: indexh2dto3d(elem%np)
147
148 integer :: nes, nee, nnode_h1d, nnode_v
149 !------------------------------------------------------------------------
150
151 indexh2dto3d(:) = elem%IndexH2Dto3D(:)
152 call element3d_operation_driver%Init( element3d_operation )
153 nes = lmesh%NeS
154 nee = lmesh%NeE
155 nnode_h1d = elem%Nnode_h1D
156 nnode_v = elem%Nnode_v
157
158 !$acc data present(DDENS_,MOMX_,MOMY_,MOMZ_,DRHOT_,DPRES_, &
159 !$acc DENS_hyd,PRES_hyd,THERM_hyd, &
160 !$acc CORIOLIS,Rtot,CVtot,CPtot,DPhydDx,DPhydDy, &
161 !$acc DENS_dt,MOMX_dt,MOMY_dt,MOMZ_dt,RHOT_dt, lmesh,elem) &
162 !$acc create(del_flux,Flux2D,FluxZ_store,tend_tmp,drho) copyin(IndexH2Dto3D)
163
164 call prof_rapstart('cal_dyn_tend_bndflux', 3)
165 call get_ebnd_flux( &
166 del_flux, & ! (out)
167 ddens_, momx_, momy_, momz_, drhot_, dpres_, & ! (in)
168 dens_hyd, pres_hyd, therm_hyd, rtot, cvtot, cptot, & ! (in)
169 lmesh%Gsqrt, lmesh%GIJ(:,:,1,1), lmesh%GIJ(:,:,1,2), lmesh%GIJ(:,:,2,2), & ! (in)
170 lmesh%GsqrtH, lmesh%gam, lmesh%GI3(:,:,1), lmesh%GI3(:,:,2), & ! (in)
171 lmesh%normal_fn(:,:,1), lmesh%normal_fn(:,:,2), lmesh%normal_fn(:,:,3), & ! (in)
172 lmesh%vmapM, lmesh%vmapP, elem%IndexH2Dto3D_bnd, & ! (in)
173 lmesh, elem, lmesh2d, elem2d ) ! (in)
174 !$acc wait(1)
175 call prof_rapend('cal_dyn_tend_bndflux', 3)
176
177 !-----
178 call prof_rapstart('cal_dyn_tend_interior', 3)
179 call cal_tend_interior_gpu( &
180 dens_dt, momx_dt, momy_dt, momz_dt, rhot_dt, & ! (out)
181 ddens_, momx_, momy_, momz_, drhot_, dpres_, del_flux, & ! (in)
182 dens_hyd, therm_hyd, dphyddx, dphyddy, & ! (in)
183 lmesh%Gsqrt,lmesh%GsqrtH,lmesh%GI3(:,:,1),lmesh%GI3(:,:,2), & ! (in)
184 lmesh%Escale(:,:,1,1), lmesh%Escale(:,:,2,2), lmesh%Escale(:,:,3,3), & ! (in)
185 lmesh2d%pos_en(:,:,1), lmesh2d%pos_en(:,:,2), & ! (in)
186 flux2d, fluxz_store, tend_tmp, drho, & ! (in)
187 element3d_operation_driver, lmesh%EMap3Dto2D, indexh2dto3d, & ! (in)
188 lmesh,elem, lmesh%NeS, lmesh%NeE, lmesh%NeA, lmesh%Ne2DA, elem%Nnode_h1D, elem%Nnode_v ) ! (in) ! (in)
189 !$acc wait(1)
190 call prof_rapend('cal_dyn_tend_interior', 3)
191
192 !$acc end data
193
194 call element3d_operation_driver%Final()
195 return
197
198 subroutine cal_tend_interior_gpu( &
199 DENS_dt, MOMX_dt, MOMY_dt, MOMZ_dt, RHOT_dt, & ! (out)
200 ddens_, momx_, momy_, momz_, drhot_, dpres_, del_flux, & ! (in)
201 dens_hyd, therm_hyd, dphyddx, dphyddy, & ! (in)
202 gsqrt,gsqrth,g13,g23, e11,e22,e33, alph2d, beta2d, & ! (in)
203 flux2d, fluxz_store, tend_tmp, drho, & ! (in)
204 element3d_operation_driver, & ! (in)
205 emap3dto2d, indexh2dto3d, lmesh,elem, nes, nee, nea, ne2da, nnode_h1d, nnode_v ) ! (in)
206 use scale_const, only: &
207 ohm => const_ohm
210 div_kplane => elementoperationgpu_div_kplane, &
211 divvar5_kplane => elementoperationgpu_divvar5_kplane2, &
212 divvar5_z_lift => elementoperationgpu_divvar5_z_lift, &
213 divvar5 => elementoperationgpu_divvar5, &
215 implicit none
216 class(localmesh3d), intent(in) :: lmesh
217 class(elementbase3d), intent(in) :: elem
218 integer, intent(in) :: nes, nee, nea, ne2da
219 integer, intent(in) :: nnode_h1d, nnode_v
220 real(rp), intent(out) :: dens_dt(nnode_h1d**2,nnode_v,nea)
221 real(rp), intent(out) :: momx_dt(nnode_h1d**2,nnode_v,nea)
222 real(rp), intent(out) :: momy_dt(nnode_h1d**2,nnode_v,nea)
223 real(rp), intent(out) :: momz_dt(nnode_h1d**2,nnode_v,nea)
224 real(rp), intent(out) :: rhot_dt(nnode_h1d**2,nnode_v,nea)
225 real(rp), intent(in) :: ddens_(nnode_h1d**2,nnode_v,nea)
226 real(rp), intent(in) :: momx_(nnode_h1d**2,nnode_v,nea)
227 real(rp), intent(in) :: momy_(nnode_h1d**2,nnode_v,nea)
228 real(rp), intent(in) :: momz_(nnode_h1d**2,nnode_v,nea)
229 real(rp), intent(in) :: drhot_(nnode_h1d**2,nnode_v,nea)
230 real(rp), intent(in) :: dpres_(nnode_h1d**2,nnode_v,nea)
231 real(rp), intent(in) :: del_flux(elem%nfptot,prgvar_num,lmesh%ne)
232 real(rp), intent(in) :: dens_hyd(nnode_h1d**2,nnode_v,nea)
233 real(rp), intent(in) :: therm_hyd(nnode_h1d**2,nnode_v,nea)
234 real(rp), intent(in) :: dphyddx(nnode_h1d**2,nnode_v,nea)
235 real(rp), intent(in) :: dphyddy(nnode_h1d**2,nnode_v,nea)
236 real(rp), intent(in) :: gsqrt(nnode_h1d**2,nnode_v,nea)
237 real(rp), intent(in) :: gsqrth(nnode_h1d**2,lmesh%ne2d)
238 real(rp), intent(in) :: g13(nnode_h1d**2,nnode_v,nea)
239 real(rp), intent(in) :: g23(nnode_h1d**2,nnode_v,nea)
240 real(rp), intent(in) :: e11(nnode_h1d**2,nnode_v,lmesh%ne)
241 real(rp), intent(in) :: e22(nnode_h1d**2,nnode_v,lmesh%ne)
242 real(rp), intent(in) :: e33(nnode_h1d**2,nnode_v,lmesh%ne)
243 real(rp), intent(in) :: alph2d(nnode_h1d**2,lmesh%ne2d)
244 real(rp), intent(in) :: beta2d(nnode_h1d**2,lmesh%ne2d)
245 real(rp), intent(out) :: flux2d(elem%nnode_h1d**2,5,elem%nnode_v,lmesh%ne,2)
246 real(rp), intent(out) :: fluxz_store(elem%nnode_h1d**2,5,elem%nnode_v,lmesh%ne)
247 real(rp), intent(out) :: tend_tmp(elem%nnode_h1d**2,5,elem%nnode_v,lmesh%ne)
248 real(rp), intent(out) :: drho(nnode_h1d**2,nnode_v,lmesh%ne)
249 type(elementoperationgpudriver), intent(in) :: element3d_operation_driver
250 integer, intent(in) :: emap3dto2d(lmesh%ne)
251 integer, intent(in) :: indexh2dto3d(elem%nnode_h1d**2,nnode_v)
252
253 integer :: ke, ke2d
254 integer :: ph, pz
255
256 real(rp) :: mflxx, mflxy, mflxz
257 real(rp) :: u_, v_, w_, pt_
258 real(rp) :: cor_x, cor_y
259 real(rp) :: rdens_, gsqrtv, rgsqrtv, rgsqrt
260 real(rp) :: gsqrt_, gsqrtdpres_
261
262 real(rp) :: g11, g12, g22
263 real(rp) :: x, y
264 real(rp) :: twoovdel2
265
266 real(rp) :: s
267 logical :: is_panel1to4
268 !----------------------------
269
270 s = 1.0_rp
271 is_panel1to4 = .true.
272 if ( lmesh%panelID == 5 ) then
273 is_panel1to4 = .false.
274 else if ( lmesh%panelID == 6 ) then
275 is_panel1to4 = .false.
276 s = - 1.0_rp
277 end if
278
279 !$acc parallel loop gang collapse(2) &
280 !$acc present(DDENS_,MOMX_,MOMY_,MOMZ_,DRHOT_,DPRES_,DENS_hyd,THERM_hyd,Flux2D,FluxZ_store, EMap3Dto2D) async(1)
281 do ke = nes, nee
282 do pz=1, nnode_v
283 ke2d = emap3dto2d(ke)
284
285 !$acc loop vector
286 do ph=1, nnode_h1d**2
287 gsqrt_ = gsqrt(ph,pz,ke)
288 gsqrtv = gsqrt_ / gsqrth(ph,ke2d)
289 rgsqrtv = 1.0_rp / gsqrtv
290 rgsqrt = 1.0_rp / gsqrt_
291 rdens_ = 1.0_rp / ( ddens_(ph,pz,ke) + dens_hyd(ph,pz,ke) )
292
293 g11 = lmesh%GIJ(ph,ke2d,1,1)
294 g12 = lmesh%GIJ(ph,ke2d,1,2)
295 g22 = lmesh%GIJ(ph,ke2d,2,2)
296
297 !-
298 mflxx = gsqrt_ * momx_(ph,pz,ke)
299 mflxy = gsqrt_ * momy_(ph,pz,ke)
300 mflxz = gsqrt_ * ( &
301 momz_(ph,pz,ke) * rgsqrtv &
302 + g13(ph,pz,ke) * momx_(ph,pz,ke) &
303 + g23(ph,pz,ke) * momy_(ph,pz,ke) )
304
305 flux2d(ph,dens_vid,pz,ke,1) = mflxx
306 flux2d(ph,dens_vid,pz,ke,2) = mflxy
307 fluxz_store(ph,dens_vid,pz,ke) = mflxz
308
309 !-
310 pt_ = ( therm_hyd(ph,pz,ke) + drhot_(ph,pz,ke) ) * rdens_
311
312 flux2d(ph,rhot_vid,pz,ke,1) = mflxx * pt_
313 flux2d(ph,rhot_vid,pz,ke,2) = mflxy * pt_
314 fluxz_store(ph,rhot_vid,pz,ke) = mflxz * pt_
315
316 !-
317 gsqrtdpres_ = gsqrt_ * dpres_(ph,pz,ke)
318 w_ = momz_(ph,pz,ke) * rdens_
319 flux2d(ph,momz_vid,pz,ke,1) = mflxx * w_
320 flux2d(ph,momz_vid,pz,ke,2) = mflxy * w_
321 fluxz_store(ph,momz_vid,pz,ke) = mflxz * w_ + gsqrtdpres_ * rgsqrtv
322
323 !-
324 u_ = momx_(ph,pz,ke) * rdens_
325 flux2d(ph,momx_vid,pz,ke,1) = mflxx * u_ + g11 * gsqrtdpres_
326 flux2d(ph,momx_vid,pz,ke,2) = mflxy * u_ + g12 * gsqrtdpres_
327 fluxz_store(ph,momx_vid,pz,ke) = mflxz * u_ + gsqrtdpres_ * ( g11 * g13(ph,pz,ke) + g12 * g23(ph,pz,ke) )
328
329 v_ = momy_(ph,pz,ke) * rdens_
330 flux2d(ph,momy_vid,pz,ke,1) = mflxx * v_ + g12 * gsqrtdpres_
331 flux2d(ph,momy_vid,pz,ke,2) = mflxy * v_ + g22 * gsqrtdpres_
332 fluxz_store(ph,momy_vid,pz,ke) = mflxz * v_ + gsqrtdpres_ * ( g12 * g13(ph,pz,ke) + g22 * g23(ph,pz,ke) )
333 end do
334 end do
335 end do
336
337 call divvar5( element3d_operation_driver, flux2d(:,:,:,:,1), flux2d(:,:,:,:,2), fluxz_store, del_flux, &
338 e11, e22, e33, gsqrt, lmesh%Ne, tend_tmp )
339
340 call vfilterpm1( element3d_operation_driver, ddens_, lmesh%NeA, lmesh%Ne, &
341 drho )
342
343
344 !$acc parallel loop gang collapse(2) &
345 !$acc present(DENS_dt,MOMX_dt,MOMY_dt,MOMZ_dt,RHOT_dt, DPhydDx,DPhydDy, tend_tmp, drho, EMap3Dto2D) async(1)
346 do ke = nes, nee
347 do pz=1, nnode_v
348 ke2d = emap3dto2d(ke)
349 !$acc loop vector
350 do ph=1, nnode_h1d**2
351 dens_dt(ph,pz,ke) = - tend_tmp(ph,dens_vid,pz,ke)
352 rhot_dt(ph,pz,ke) = - tend_tmp(ph,rhot_vid,pz,ke)
353
354
355 momz_dt(ph,pz,ke) = - tend_tmp(ph,momz_vid,pz,ke) &
356 - grav * drho(ph,pz,ke)
357 end do
358 !$acc loop vector
359 do ph=1, nnode_h1d**2
360 !-
361 x = tan(alph2d(ph,ke2d))
362 y = tan(beta2d(ph,ke2d))
363 twoovdel2 = 2.0_rp / ( 1.0_rp + x**2 + y**2 )
364
365 cor_x = s * ohm * twoovdel2 * ( - x * y * momx_(ph,pz,ke) + ( 1.0_rp + y**2 ) * momy_(ph,pz,ke) )
366 cor_y = s * ohm * twoovdel2 * ( - ( 1.0_rp + x**2 ) * momx_(ph,pz,ke) + x * y * momy_(ph,pz,ke) )
367 if ( is_panel1to4 ) then
368 cor_x = s * y * cor_x
369 cor_y = s * y * cor_y
370 end if
371
372 g11 = lmesh%GIJ(ph,ke2d,1,1)
373 g12 = lmesh%GIJ(ph,ke2d,1,2)
374 g22 = lmesh%GIJ(ph,ke2d,2,2)
375
376 rdens_ = 1.0_rp / ( ddens_(ph,pz,ke) + dens_hyd(ph,pz,ke) )
377 u_ = momx_(ph,pz,ke) * rdens_
378 v_ = momy_(ph,pz,ke) * rdens_
379
380
381 momx_dt(ph,pz,ke) = - tend_tmp(ph,momx_vid,pz,ke) &
382 - ( g11 * dphyddx(ph,pz,ke) + g12 * dphyddy(ph,pz,ke) ) &
383 - twoovdel2 * y * &
384 ( x * y * u_ + ( 1.0_rp + y**2 ) * v_ ) * momx_(ph,pz,ke) &
385 + cor_x
386 momy_dt(ph,pz,ke) = - tend_tmp(ph,momy_vid,pz,ke) &
387 - ( g12 * dphyddx(ph,pz,ke) + g22 * dphyddy(ph,pz,ke) ) &
388 - twoovdel2 * y * &
389 ( - ( 1.0_rp + x**2 ) * u_ + x * y * v_ ) * momy_(ph,pz,ke) &
390 - cor_y
391 end do
392 end do
393 end do
394 !$acc end parallel
395 return
396 end subroutine cal_tend_interior_gpu
397
398!OCL SERIAL
400 DENS_dt, MOMX_dt, MOMY_dt, MOMZ_dt, RHOT_dt, & ! (out)
401 ddens_, momx_, momy_, momz_, drhot_, dpres_, & ! (in)
402 dens_hyd, pres_hyd, pres_hyd_ref, therm_hyd, & ! (in)
403 coriolis, rtot, cvtot, cptot, dphyddx, dphyddy, & ! (in)
404 element3d_operation, dx, dy, dz, sx, sy, sz, lift, & ! (in)
405 lmesh, elem, lmesh2d, elem2d ) ! (in)
406
409 use scale_const, only: &
410 ohm => const_ohm
411 implicit none
412
413 class(localmesh3d), intent(in) :: lmesh
414 class(elementbase3d), intent(in) :: elem
415 class(localmesh2d), intent(in) :: lmesh2d
416 class(elementbase2d), intent(in) :: elem2d
417 class(elementoperationbase3d), intent(in) :: element3d_operation
418 type(sparsemat), intent(in) :: dx, dy, dz, sx, sy, sz, lift
419 real(rp), intent(out) :: dens_dt(elem%np,lmesh%nea)
420 real(rp), intent(out) :: momx_dt(elem%np,lmesh%nea)
421 real(rp), intent(out) :: momy_dt(elem%np,lmesh%nea)
422 real(rp), intent(out) :: momz_dt(elem%np,lmesh%nea)
423 real(rp), intent(out) :: rhot_dt(elem%np,lmesh%nea)
424 real(rp), intent(in) :: ddens_(elem%np,lmesh%nea)
425 real(rp), intent(in) :: momx_(elem%np,lmesh%nea)
426 real(rp), intent(in) :: momy_(elem%np,lmesh%nea)
427 real(rp), intent(in) :: momz_(elem%np,lmesh%nea)
428 real(rp), intent(in) :: drhot_(elem%np,lmesh%nea)
429 real(rp), intent(in) :: dpres_(elem%np,lmesh%nea)
430 real(rp), intent(in) :: dens_hyd(elem%np,lmesh%nea)
431 real(rp), intent(in) :: pres_hyd(elem%np,lmesh%nea)
432 real(rp), intent(in) :: pres_hyd_ref(elem%np,lmesh%nea)
433 real(rp), intent(in) :: therm_hyd(elem%np,lmesh%nea)
434 real(rp), intent(in) :: coriolis(elem2d%np,lmesh2d%nea)
435 real(rp), intent(in) :: rtot (elem%np,lmesh%nea)
436 real(rp), intent(in) :: cvtot(elem%np,lmesh%nea)
437 real(rp), intent(in) :: cptot(elem%np,lmesh%nea)
438 real(rp), intent(in) :: dphyddx(elem%np,lmesh%nea)
439 real(rp), intent(in) :: dphyddy(elem%np,lmesh%nea)
440
441 real(rp) :: fx(elem%np), fy(elem%np), fz(elem%np), liftdelflx(elem%np)
442 real(rp) :: dpres_hyd(elem%np), gradphyd_x(elem%np), gradphyd_y(elem%np)
443 real(rp) :: del_flux(elem%nfptot,lmesh%ne,prgvar_num)
444 real(rp) :: del_flux_hyd(elem%nfptot,lmesh%ne,2)
445 real(rp) :: rhot_(elem%np)
446 real(rp) :: rdens_(elem%np), u_(elem%np), v_(elem%np), w_(elem%np), wt_(elem%np), drho(elem%np)
447
448 real(rp) :: g11(elem%np), g12(elem%np), g22(elem%np)
449 real(rp) :: gsqrtv(elem%np), rgsqrtv(elem%np), rgam2(elem%np)
450 real(rp) :: x2d(elem2d%np,lmesh2d%ne), y2d(elem2d%np,lmesh2d%ne)
451 real(rp) :: x(elem%np), y(elem%np), twoovdel2(elem%np)
452 real(rp) :: om1(elem%np), om2(elem%np), om3(elem%np), del(elem%np), r(elem%np)
453 logical :: is_panel1to4
454 real(rp) :: s
455
456 integer :: ke, ke2d
457 integer :: p
458
459 real(rp) :: rgamm
460 real(rp) :: rp0
461 real(rp) :: p0ovr
462 !------------------------------------------------------------------------
463
464 call prof_rapstart('cal_dyn_tend_bndflux', 3)
465 call get_ebnd_flux( &
466 del_flux, del_flux_hyd, & ! (out)
467 ddens_, momx_, momy_, momz_, drhot_, dpres_, dens_hyd, pres_hyd, & ! (in)
468 rtot, cvtot, cptot, & ! (in)
469 lmesh%Gsqrt, lmesh%GIJ(:,:,1,1), lmesh%GIJ(:,:,1,2), lmesh%GIJ(:,:,2,2), & ! (in)
470 lmesh%GsqrtH, lmesh%gam, lmesh%GI3(:,:,1), lmesh%GI3(:,:,2), & ! (in)
471 lmesh%normal_fn(:,:,1), lmesh%normal_fn(:,:,2), lmesh%normal_fn(:,:,3), & ! (in)
472 lmesh%vmapM, lmesh%vmapP, elem%IndexH2Dto3D_bnd, & ! (in)
473 lmesh, elem, lmesh2d, elem2d ) ! (in)
474 call prof_rapend('cal_dyn_tend_bndflux', 3)
475
476 !-----
477 call prof_rapstart('cal_dyn_tend_interior', 3)
478 rgamm = cvdry / cpdry
479 rp0 = 1.0_rp / pres00
480 p0ovr = pres00 / rdry
481
482 s = 2.0_rp * ohm
483 is_panel1to4 = .true.
484 if ( lmesh%panelID == 5 ) then
485 is_panel1to4 = .false.
486 else if ( lmesh%panelID == 6 ) then
487 is_panel1to4 = .false.
488 s = - s
489 end if
490
491 !$omp parallel private( &
492 !$omp RHOT_, rdens_, u_, v_, w_, wt_, &
493 !$omp Fx, Fy, Fz, LiftDelFlx, &
494 !$omp drho, DPRES_hyd, GradPhyd_x, GradPhyd_y, &
495 !$omp G11, G12, G22, Rgam2, GsqrtV, RGsqrtV, &
496 !$omp X, Y, twoOVdel2, &
497 !$omp OM1, OM2, OM3, DEL, R, ke, ke2D )
498
499 !$omp do
500 do ke2d = lmesh2d%NeS, lmesh2d%NeE
501 x2d(:,ke2d) = tan(lmesh2d%pos_en(:,ke2d,1))
502 y2d(:,ke2d) = tan(lmesh2d%pos_en(:,ke2d,2))
503 end do
504
505 !$omp do
506 do ke = lmesh%NeS, lmesh%NeE
507 !--
508 ke2d = lmesh%EMap3Dto2D(ke)
509 rgam2(:) = 1.0_rp / lmesh%gam(:,ke)**2
510 g11(:) = lmesh%GIJ(elem%IndexH2Dto3D,ke2d,1,1) * rgam2(:)
511 g12(:) = lmesh%GIJ(elem%IndexH2Dto3D,ke2d,1,2) * rgam2(:)
512 g22(:) = lmesh%GIJ(elem%IndexH2Dto3D,ke2d,2,2) * rgam2(:)
513 gsqrtv(:) = lmesh%Gsqrt(:,ke) * rgam2(:) / lmesh%GsqrtH(elem%IndexH2Dto3D,ke2d)
514 rgsqrtv(:) = 1.0_rp / gsqrtv(:)
515
516 !--
517 rhot_(:) = p0ovr * ( pres_hyd(:,ke) * rp0 )**rgamm + drhot_(:,ke)
518 ! DPRES_(:) = PRES00 * ( Rtot(:,ke) * rP0 * RHOT_(:) )**( CPtot(:,ke) / CVtot(:,ke) ) &
519 ! - PRES_hyd(:,ke)
520
521 rdens_(:) = 1.0_rp / ( ddens_(:,ke) + dens_hyd(:,ke) )
522 u_(:) = momx_(:,ke) * rdens_(:)
523 v_(:) = momy_(:,ke) * rdens_(:)
524 w_(:) = momz_(:,ke) * rdens_(:)
525 wt_(:) = w_(:) * rgsqrtv(:) + lmesh%GI3(:,ke,1) * u_(:) + lmesh%GI3(:,ke,2) * v_(:)
526
527 x(:) = x2d(elem%IndexH2Dto3D,ke2d)
528 y(:) = y2d(elem%IndexH2Dto3D,ke2d)
529 del(:) = sqrt( 1.0_rp + x(:)**2 + y(:)**2 )
530 twoovdel2(:) = 2.0_rp / ( 1.0_rp + x(:)**2 + y(:)**2 )
531
532 r(:) = rplanet * lmesh%gam(:,ke)
533
534 !- pnl=1~4: OM1: 0, OM2: s del / (r (1+Y^2)) , s OM3 : Y /del
535 !- pnl=5,6: OM1: - s X del/(r (1+X^2)), OM2: - s Y del/(r(1+Y^2)), OM3 : s/del
536 if ( is_panel1to4 ) then
537 om1(:) = 0.0_rp
538 om2(:) = s * del(:) / ( r(:) * ( 1.0_rp + y(:)**2 ) )
539 om3(:) = s * y(:) / del(:)
540 else
541 om1(:) = - s * x(:) * del(:) / ( r(:) * ( 1.0_rp + x(:)**2 ) )
542 om2(:) = - s * y(:) * del(:) / ( r(:) * ( 1.0_rp + y(:)**2 ) )
543 om3(:) = s / del(:)
544 end if
545
546 drho(:) = matmul(intrpmat_vpordm1, ddens_(:,ke))
547
548 !-- Gradient hydrostatic pressure
549
550 dpres_hyd(:) = pres_hyd(:,ke) - pres_hyd_ref(:,ke)
551
552 call sparsemat_matmul(dx, gsqrtv(:) * dpres_hyd(:), fx)
553 call sparsemat_matmul(dz, gsqrtv(:) * lmesh%GI3(:,ke,1) * dpres_hyd(:), fz)
554 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux_hyd(:,ke,1), liftdelflx)
555 gradphyd_x(:) = lmesh%Escale(:,ke,1,1) * fx(:) &
556 + lmesh%Escale(:,ke,3,3) * fz(:) &
557 + liftdelflx(:)
558
559 call sparsemat_matmul(dy, gsqrtv(:) * dpres_hyd(:), fy)
560 call sparsemat_matmul(dz, gsqrtv(:) * lmesh%GI3(:,ke,2) * dpres_hyd(:), fz)
561 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux_hyd(:,ke,2), liftdelflx)
562 gradphyd_y(:) = lmesh%Escale(:,ke,2,2) * fy(:) &
563 + lmesh%Escale(:,ke,3,3) * fz(:) &
564 + liftdelflx(:)
565
566 !-- DENS
567 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * momx_(:,ke), fx)
568 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * momy_(:,ke), fy)
569 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( ddens_(:,ke) + dens_hyd(:,ke) ) * wt_(:), fz)
570 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,dens_vid), liftdelflx)
571
572 dens_dt(:,ke) = - ( &
573 lmesh%Escale(:,ke,1,1) * fx(:) &
574 + lmesh%Escale(:,ke,2,2) * fy(:) &
575 + lmesh%Escale(:,ke,3,3) * fz(:) &
576 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke)
577
578 !-- MOMX
579 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * ( u_(:) * momx_(:,ke) + g11(:) * dpres_(:,ke) ), fx)
580 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * ( v_(:) * momx_(:,ke) + g12(:) * dpres_(:,ke) ), fy)
581 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( wt_(:) * momx_(:,ke) &
582 + ( lmesh%GI3(:,ke,1) * g11(:) + lmesh%GI3(:,ke,2) * g12(:) ) * dpres_(:,ke) ), fz)
583 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,momx_vid), liftdelflx)
584
585 momx_dt(:,ke) = &
586 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
587 + lmesh%Escale(:,ke,2,2) * fy(:) &
588 + lmesh%Escale(:,ke,3,3) * fz(:) &
589 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke) &
590 - twoovdel2(:) * y(:) * & !-> metric terms
591 ( x(:) * y(:) * u_(:) - ( 1.0_rp + y(:)**2 ) * v_(:) ) * momx_(:,ke) & !
592 - 2.0_rp * u_(:) * momz_(:,ke) / r(:) & !<-
593 - ( g11(:) * gradphyd_x(:) + g12(:) * gradphyd_y(:) ) * rgsqrtv(:) & !-> gradient hydrostatic pressure
594 - lmesh%Gsqrt(:,ke) * ( g11(:) * ( om2(:) * momz_(:,ke) - om3(:) * momy_(:,ke) ) & !-> Coriolis term
595 - g12(:) * ( om1(:) * momz_(:,ke) - om3(:) * momx_(:,ke) ) )
596
597 !-- MOMY
598 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * ( u_(:) * momy_(:,ke) + g12(:) * dpres_(:,ke) ), fx)
599 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * ( v_(:) * momy_(:,ke) + g22(:) * dpres_(:,ke) ), fy)
600 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( wt_(:) * momy_(:,ke) &
601 + ( lmesh%GI3(:,ke,1) * g12(:) + lmesh%GI3(:,ke,2) * g22(:) ) * dpres_(:,ke) ), fz)
602 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,momy_vid), liftdelflx)
603
604 momy_dt(:,ke) = &
605 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
606 + lmesh%Escale(:,ke,2,2) * fy(:) &
607 + lmesh%Escale(:,ke,3,3) * fz(:) &
608 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke) &
609 - twoovdel2(:) * x(:) * & !-> metric terms
610 ( - (1.0_rp + x(:)**2) * u_(:) + x(:) * y(:) * v_(:) ) * momy_(:,ke) & !
611 - 2.0_rp * v_(:) * momz_(:,ke) / r(:) & !<-
612 - ( g12(:) * gradphyd_x(:) + g22(:) * gradphyd_y(:) ) * rgsqrtv(:) & !-> gradient hydrostatic pressure
613 - lmesh%Gsqrt(:,ke) * ( g12(:) * ( om2(:) * momz_(:,ke) - om3(:) * momy_(:,ke) ) & !-> Coriolis term
614 - g22(:) * ( om1(:) * momz_(:,ke) - om3(:) * momx_(:,ke) ) )
615
616 !-- MOMZ
617 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * u_(:) * momz_(:,ke), fx)
618 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * v_(:) * momz_(:,ke), fy)
619 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * ( wt_(:) * momz_(:,ke) + rgsqrtv(:) * dpres_(:,ke) ), fz)
620 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,momz_vid), liftdelflx)
621
622 momz_dt(:,ke) = &
623 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
624 + lmesh%Escale(:,ke,2,2) * fy(:) &
625 + lmesh%Escale(:,ke,3,3) * fz(:) &
626 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke) &
627 - 0.25_rp * r(:) * twoovdel2(:)**2 * ( 1.0_rp * x(:)**2 ) * ( 1.0_rp * y(:)**2 ) & !-> metric terms
628 * ( - ( 1.0_rp + x(:)**2 ) * momx_(:,ke) * u_(:) & !
629 + 2.0_rp * x(:) * y(:) * momx_(:,ke) * v_(:) & !
630 - ( 1.0_rp + y(:)**2 ) * momy_(:,ke) * v_(:) ) & !<-
631 + 2.0_rp * dpres_(:,ke) / r(:) & !-> metric term with gradient of pressure deviaition
632 - lmesh%Gsqrt(:,ke) * ( om1(:) * momy_(:,ke) - om2(:) * momx_(:,ke) ) & !-> Coriolis term
633 - grav * rgam2(:) * drho(:) !-> buoyancy term
634
635 !-- RHOT
636 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * u_(:) * rhot_(:), fx)
637 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * v_(:) * rhot_(:), fy)
638 call sparsemat_matmul(dz, lmesh%Gsqrt(:,ke) * wt_(:) * rhot_(:), fz)
639 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,rhot_vid), liftdelflx)
640
641 rhot_dt(:,ke) = &
642 - ( lmesh%Escale(:,ke,1,1) * fx(:) &
643 + lmesh%Escale(:,ke,2,2) * fy(:) &
644 + lmesh%Escale(:,ke,3,3) * fz(:) &
645 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke)
646 end do
647 !$omp end do
648 !$omp end parallel
649 call prof_rapend('cal_dyn_tend_interior', 3)
650
651 return
653
module FElib / Fluid dyn solver / Atmosphere / Global nonhydrostatic model / HEVE
subroutine, public atm_dyn_dgm_globalnonhydro3d_rhot_heve_gpu_cal_tend_deep_atm(dens_dt, momx_dt, momy_dt, momz_dt, rhot_dt, ddens_, momx_, momy_, momz_, drhot_, 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)
subroutine, public atm_dyn_dgm_globalnonhydro3d_rhot_heve_gpu_cal_tend_shallow_atm(dens_dt, momx_dt, momy_dt, momz_dt, rhot_dt, ddens_, momx_, momy_, momz_, drhot_, 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 / HEVE / Numflux
subroutine, public atm_dyn_dgm_nonhydro3d_rhot_heve_numflux_get_generalhvc_gpu(del_flux, ddens_, momx_, momy_, momz_, drhot_, dpres, dens_hyd, pres_hyd, therm_hyd, rtot, cvtot, cptot, gsqrt, g11, g12, g22, gsqrth, gam, g13, g23, nx, ny, nz, vmapm, vmapp, im2dto3d, lmesh, elem, lmesh2d, elem2d)
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / HEVE / Numflux
subroutine, public atm_dyn_dgm_nonhydro3d_rhot_heve_numflux_get_generalhvc_asis(del_flux, del_flux_hyd, ddens_, momx_, momy_, momz_, drhot_, dpres_, dens_hyd, pres_hyd, rtot, cvtot, cptot, gsqrt, g11, g12, g22, gsqrth, gam, g13, g23, 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 / Element / Driver for operation with 3D tensor product elements using GPU
subroutine, public elementoperationgpu_divvar5_z_lift(this, fluxz, ebnd_flux, e33, gsqrt, div3d)
subroutine, public elementoperationgpu_divvar5(this, flux_x, flux_y, flux_z, ebnd_flux, e11, e22, e33, gsqrt, ne, div3d)
subroutine, public elementoperationgpu_div_kplane(this, flux2d_kplane, e11, e22, k, div_xy)
subroutine, public elementoperationgpu_vfilterpm1(this, vec_in, ne_in, ne_out, vec_out)
subroutine, public elementoperationgpu_divvar5_kplane2(this, flux2d_kplane_x, flux2d_kplane_y, e11, e22, k, div_xy)
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.
Driver for element operation with 3D tensor product elements using GPU.
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.