FE-Project
Loading...
Searching...
No Matches
scale_atm_dyn_dgm_bnd.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
9!-------------------------------------------------------------------------------
10#include "scaleFElib.h"
12 !-----------------------------------------------------------------------------
13 !
14 !++ Used modules
15 !
16 use scale_precision
17 use scale_io
18 use scale_prc
19 use scale_prof
20 use scale_const, only: &
21 grav => const_grav, &
22 rdry => const_rdry, &
23 cpdry => const_cpdry, &
24 cvdry => const_cvdry, &
25 pres00 => const_pre00
26
27 use scale_element_base, only: &
29 use scale_mesh_base, only: meshbase
31
36
39
41
43 dens_vid => prgvar_ddens_id, rhot_vid => prgvar_drhot_id, &
44 momx_vid => prgvar_momx_id, momy_vid => prgvar_momy_id, &
45 momz_vid => prgvar_momz_id, &
47
48 !-----------------------------------------------------------------------------
49 implicit none
50 private
51 !-----------------------------------------------------------------------------
52 !
53 !++ Public parameter & type & procedures
54 !
55 type, public :: atmdynbnd
56 type(meshbndinfo), allocatable :: velbc_list(:)
57 type(meshbndinfo), allocatable :: thermalbc_list(:)
58
59 integer, allocatable:: velbc_ids(:)
60 integer, allocatable :: thermalbc_ids(:)
61 real(rp), allocatable :: thermal_fixval(:)
62 contains
63 procedure :: init => atmos_dyn_bnd_setup
64 procedure :: final => atmos_dyn_bnd_finalize
65 procedure :: setbcinfo => atmos_dyn_bnd_setbcinfo
66 procedure :: applybc_progvars_lc => atmos_dyn_bnd_applybc_prgvars_lc
67 procedure :: applybc_numdiff_odd_lc => atmos_dyn_bnd_applybc_numdiff_odd_lc
68 procedure :: applybc_numdiff_even_lc => atmos_dyn_bnd_applybc_numdiff_even_lc
69 procedure :: applybc_grad_tbvars_lc => atmos_dyn_bnd_applybc_tbvars_lc
70 procedure :: applybc_grad_tbstress_lc => atmos_dyn_bnd_applybc_tbstress_lc
71 procedure :: inquire_bound_flag => atmos_dyn_bnd_inquire_bound_flag
72 end type
73
74 !-----------------------------------------------------------------------------
75 !
76 !++ Private procedures
77 !
78 !-------------------
79
80
81 integer, parameter :: dombnd_south_id = 1
82 integer, parameter :: dombnd_east_id = 2
83 integer, parameter :: dombnd_north_id = 3
84 integer, parameter :: dombnd_west_id = 4
85 integer, parameter :: dombnd_btm_id = 5
86 integer, parameter :: dombnd_top_id = 6
87 integer, parameter :: dom_bnd_num = 6
88
89contains
90
91!OCL SERIAL
92 subroutine atmos_dyn_bnd_setup( this )
93 use scale_const, only: &
94 undef8 => const_undef8
95 use scale_mesh_bndinfo, only: &
99 implicit none
100
101 class(atmdynbnd), intent(inout) :: this
102
103 character(len=H_SHORT) :: btm_vel_bc, top_vel_bc
104 character(len=H_SHORT) :: north_vel_bc, south_vel_bc
105 character(len=H_SHORT) :: east_vel_bc, west_vel_bc
106 character(len=H_SHORT) :: btm_thermal_bc, top_thermal_bc
107 character(len=H_SHORT) :: north_thermal_bc, south_thermal_bc
108 character(len=H_SHORT) :: east_thermal_bc, west_thermal_bc
109
110 real(rp) :: btm_thermal_fixval, top_thermal_fixval
111 real(rp) :: north_thermal_fixval, south_thermal_fixval
112 real(rp) :: east_thermal_fixval, west_thermal_fixval
113
114 namelist /param_atmos_dyn_bnd/ &
115 btm_vel_bc, top_vel_bc, north_vel_bc, south_vel_bc, east_vel_bc, west_vel_bc, &
116 btm_thermal_bc, top_thermal_bc, north_thermal_bc, south_thermal_bc, east_thermal_bc, west_thermal_bc, &
117 btm_thermal_fixval, top_thermal_fixval, north_thermal_fixval, south_thermal_fixval, east_thermal_fixval, west_thermal_fixval
118
119 integer :: ierr
120 !-----------------------------------------------
121
122 btm_vel_bc = bnd_type_nospec_name
123 top_vel_bc = bnd_type_nospec_name
124 north_vel_bc = bnd_type_nospec_name
125 south_vel_bc = bnd_type_nospec_name
126 east_vel_bc = bnd_type_nospec_name
127 west_vel_bc = bnd_type_nospec_name
128
129 btm_thermal_bc = bnd_type_nospec_name
130 top_thermal_bc = bnd_type_nospec_name
131 north_thermal_bc = bnd_type_nospec_name
132 south_thermal_bc = bnd_type_nospec_name
133 east_thermal_bc = bnd_type_nospec_name
134 west_thermal_bc = bnd_type_nospec_name
135
136 btm_thermal_fixval = undef8
137 top_thermal_fixval = undef8
138 north_thermal_fixval = undef8
139 south_thermal_fixval = undef8
140 east_thermal_fixval = undef8
141 west_thermal_fixval = undef8
142
143 rewind(io_fid_conf)
144 read(io_fid_conf,nml=param_atmos_dyn_bnd,iostat=ierr)
145 if( ierr < 0 ) then !--- missing
146 log_info("ATMOS_dyn_bnd_setup",*) 'Not found namelist. Default used.'
147 elseif( ierr > 0 ) then !--- fatal error
148 log_error("ATMOS_dyn_bnd_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_DYN_BND. Check!'
149 call prc_abort
150 endif
151 log_nml(param_atmos_dyn_bnd)
152
153 !--
154 allocate( this%velBC_ids(dom_bnd_num) )
155 this%velBC_ids(dombnd_btm_id) = bndtype_nametoid(btm_vel_bc)
156 this%velBC_ids(dombnd_top_id) = bndtype_nametoid(top_vel_bc)
157 this%velBC_ids(dombnd_north_id) = bndtype_nametoid(north_vel_bc)
158 this%velBC_ids(dombnd_south_id) = bndtype_nametoid(south_vel_bc)
159 this%velBC_ids(dombnd_east_id) = bndtype_nametoid(east_vel_bc)
160 this%velBC_ids(dombnd_west_id) = bndtype_nametoid(west_vel_bc)
161
162 allocate( this%thermalBC_ids(dom_bnd_num) )
163 this%thermalBC_ids(dombnd_btm_id) = bndtype_nametoid(btm_thermal_bc)
164 this%thermalBC_ids(dombnd_top_id) = bndtype_nametoid(top_thermal_bc)
165 this%thermalBC_ids(dombnd_north_id) = bndtype_nametoid(north_thermal_bc)
166 this%thermalBC_ids(dombnd_south_id) = bndtype_nametoid(south_thermal_bc)
167 this%thermalBC_ids(dombnd_east_id) = bndtype_nametoid(east_thermal_bc)
168 this%thermalBC_ids(dombnd_west_id) = bndtype_nametoid(west_thermal_bc)
169
170 allocate( this%thermal_fixval(dom_bnd_num) )
171 this%thermal_fixval(dombnd_btm_id) = btm_thermal_fixval
172 this%thermal_fixval(dombnd_top_id) = top_thermal_fixval
173 this%thermal_fixval(dombnd_north_id) = north_thermal_fixval
174 this%thermal_fixval(dombnd_south_id) = south_thermal_fixval
175 this%thermal_fixval(dombnd_east_id) = east_thermal_fixval
176 this%thermal_fixval(dombnd_west_id) = west_thermal_fixval
177
178 !------
179
180 return
181 end subroutine atmos_dyn_bnd_setup
182
183!OCL SERIAL
184 subroutine atmos_dyn_bnd_finalize( this )
185 implicit none
186 class(atmdynbnd), intent(inout) :: this
187
188 integer :: n
189 !--------------------------------------
190
191 if ( allocated(this%VelBC_list) ) then
192 do n=1, size(this%VelBC_list)
193 call this%VelBC_list(n)%Final()
194 call this%ThermalBC_list(n)%Final()
195 end do
196 deallocate( this%VelBC_list, this%ThermalBC_list )
197
198 deallocate( this%velBC_ids, this%thermalBC_ids )
199 end if
200
201 return
202 end subroutine atmos_dyn_bnd_finalize
203
204!OCL SERIAL
205 subroutine atmos_dyn_bnd_setbcinfo( this, mesh )
206
207 implicit none
208
209 class(atmdynbnd), intent(inout) :: this
210 class(meshbase), target, intent(in) :: mesh
211
212 integer :: n
213 integer :: b
214 class(localmeshbase), pointer :: ptr_lcmesh
215 class(localmesh3d), pointer :: lcmesh3d
216 !--------------------------------------------------
217
218
219 allocate( this%VelBC_list(mesh%LOCAL_MESH_NUM) )
220 allocate( this%ThermalBC_list(mesh%LOCAL_MESH_NUM) )
221
222 nullify( lcmesh3d )
223
224 do n=1, mesh%LOCAL_MESH_NUM
225 call mesh%GetLocalMesh( n, ptr_lcmesh )
226 select type (ptr_lcmesh)
227 type is (localmesh3d)
228 lcmesh3d => ptr_lcmesh
229 end select
230
231 call bnd_init_lc( &
232 this%VelBC_list(n), this%ThermalBC_list(n), & ! (inout)
233 this%velBC_ids(:), this%thermalBC_ids(:), & ! (in)
234 this%thermal_fixval(:), & ! (in)
235 lcmesh3d%VMapB, mesh, lcmesh3d, lcmesh3d%refElem3D ) ! (in)
236 end do
237
238 return
239 end subroutine atmos_dyn_bnd_setbcinfo
240
243!OCL SERIAL
244 subroutine atmos_dyn_bnd_applybc_prgvars_lc( this, &
245 domID, & ! (in)
246 ddens, momx, momy, momz, therm, & ! (inout)
247 dens_hyd, pres_hyd, & ! (in)
248 gsqrt, gsqrth, g11, g12, g22, g13, g23, nx, ny, nz, & ! (in)
249 vmapm, vmapp, vmapb, lmesh, elem, lmesh2d, elem2d ) ! (in)
250
251 use scale_mesh_bndinfo, only: &
254
255 implicit none
256
257 class(atmdynbnd), intent(in) :: this
258 integer, intent(in) :: domid
259 class(localmesh3d), intent(in) :: lmesh
260 class(elementbase3d), intent(in) :: elem
261 class(localmesh2d), intent(in) :: lmesh2d
262 class(elementbase2d), intent(in) :: elem2d
263 real(rp), intent(inout) :: ddens(elem%np*lmesh%nea)
264 real(rp), intent(inout) :: momx(elem%np*lmesh%nea)
265 real(rp), intent(inout) :: momy(elem%np*lmesh%nea)
266 real(rp), intent(inout) :: momz(elem%np*lmesh%nea)
267 real(rp), intent(inout) :: therm(elem%np*lmesh%nea)
268 real(rp), intent(in) :: dens_hyd(elem%np*lmesh%nea)
269 real(rp), intent(in) :: pres_hyd(elem%np*lmesh%nea)
270 real(rp), intent(in) :: gsqrt(elem%np*lmesh%nea)
271 real(rp), intent(in) :: gsqrth(elem2d%np,lmesh2d%ne)
272 real(rp), intent(in) :: g11(elem2d%np,lmesh2d%ne)
273 real(rp), intent(in) :: g12(elem2d%np,lmesh2d%ne)
274 real(rp), intent(in) :: g22(elem2d%np,lmesh2d%ne)
275 real(rp), intent(in) :: g13(elem%np*lmesh%nea)
276 real(rp), intent(in) :: g23(elem%np*lmesh%nea)
277 real(rp), intent(in) :: nx(elem%nfptot*lmesh%ne)
278 real(rp), intent(in) :: ny(elem%nfptot*lmesh%ne)
279 real(rp), intent(in) :: nz(elem%nfptot*lmesh%ne)
280 integer, intent(in) :: vmapm(elem%nfptot*lmesh%ne)
281 integer, intent(in) :: vmapp(elem%nfptot*lmesh%ne)
282 integer, intent(in) :: vmapb(:)
283
284 integer :: p, ke, ke2d
285 integer :: i, i_, im, ip
286 real(rp) :: mom_normal
287
288 real(rp) :: momw
289 real(rp) :: gsqrtv, g11_, g12_, g22_
290 real(rp) :: fac
291 !-----------------------------------------------
292
293 !$omp parallel do collapse(2) private( &
294 !$omp ke, p, ke2D, i, i_, iM, iP, &
295 !$omp mom_normal, MOMW, GsqrtV, G11_, G12_, G22_, fac )
296 do ke=lmesh%NeS, lmesh%NeE
297 do p=1, elem%NfpTot
298 i = p + (ke-1)*elem%NfpTot
299 ip = vmapp(i)
300 i_ = ip - elem%Np*lmesh%NeE
301
302 if (i_ > 0) then
303 im = vmapm(i)
304
305 select case( this%VelBC_list(domid)%list(i_) )
306 case ( bnd_type_slip_id)
307 ke2d = lmesh%EMap3Dto2D(ke)
308
309 gsqrtv = gsqrt(im) / gsqrth(elem%IndexH2Dto3D_bnd(p),ke2d)
310 g11_ = g11(elem%IndexH2Dto3D_bnd(p),ke2d)
311 g12_ = g12(elem%IndexH2Dto3D_bnd(p),ke2d)
312 g22_ = g22(elem%IndexH2Dto3D_bnd(p),ke2d)
313
314 momw = momz(im) / gsqrtv &
315 + g13(im) * momx(im) + g23(im) * momy(im)
316 fac = nz(i) * gsqrtv**2 / ( 1.0_rp + g11_ * ( gsqrtv * g13(im) )**2 + 2.0_rp * g12_ * ( gsqrtv**2 * g13(im) * g23(im) ) + g22_ * ( gsqrtv * g23(im) )**2 )
317
318 mom_normal = momx(im) * nx(i) + momy(im) * ny(i) + momw * nz(i)
319 momx(ip) = momx(im) - 2.0_rp * mom_normal * ( nx(i) + fac * ( g11_ * g13(im) + g12_ * g23(im) ) )
320 momy(ip) = momy(im) - 2.0_rp * mom_normal * ( ny(i) + fac * ( g12_ * g13(im) + g22_ * g23(im) ) )
321 momz(ip) = momz(im) - 2.0_rp * mom_normal * fac / gsqrtv
322
323 case ( bnd_type_noslip_id )
324 momx(ip) = - momx(im)
325 momy(ip) = - momy(im)
326 momz(ip) = - momz(im)
327 end select
328 end if
329
330 end do
331 end do
332
333 return
334 end subroutine atmos_dyn_bnd_applybc_prgvars_lc
335
336!OCL SERIAL
337 subroutine atmos_dyn_bnd_applybc_numdiff_odd_lc( this, & ! (in)
338 gxvar, gyvar, gzvar, & ! (inout)
339 is_bound, & ! (out)
340 varid, domid, & ! (in)
341 nx, ny, nz, vmapm, vmapp, vmapb, lmesh, elem ) ! (in)
342
343 use scale_mesh_bndinfo, only: &
346
347 implicit none
348
349 class(atmdynbnd), intent(in) :: this
350 class(localmesh3d), intent(in) :: lmesh
351 class(elementbase3d), intent(in) :: elem
352 real(rp), intent(inout) :: gxvar(elem%np*lmesh%nea)
353 real(rp), intent(inout) :: gyvar(elem%np*lmesh%nea)
354 real(rp), intent(inout) :: gzvar(elem%np*lmesh%nea)
355 logical, intent(out) :: is_bound(elem%nfptot*lmesh%ne)
356 integer, intent(in) :: varid
357 integer, intent(in) :: domid
358 real(rp), intent(in) :: nx(elem%nfptot*lmesh%ne)
359 real(rp), intent(in) :: ny(elem%nfptot*lmesh%ne)
360 real(rp), intent(in) :: nz(elem%nfptot*lmesh%ne)
361 integer, intent(in) :: vmapm(elem%nfptot*lmesh%ne)
362 integer, intent(in) :: vmapp(elem%nfptot*lmesh%ne)
363 integer, intent(in) :: vmapb(:)
364
365 integer :: i, i_, im, ip
366 real(rp) :: grad_normal
367 !-----------------------------------------------
368
369 do i=1, elem%NfpTot*lmesh%Ne
370 ip = vmapp(i)
371 i_ = ip - elem%Np*lmesh%NeE
372 is_bound(i) = .false.
373
374 if (i_ > 0) then
375 im = vmapm(i)
376 grad_normal = gxvar(im) * nx(i) + gyvar(im) * ny(i) + gzvar(im) * nz(i)
377
378 if ( this%VelBC_list(domid)%list(i_) == bnd_type_slip_id ) then
379 select case(varid)
380 case(momx_vid)
381 gyvar(ip) = gyvar(im) - 2.0_rp * grad_normal * ny(i)
382 gzvar(ip) = gzvar(im) - 2.0_rp * grad_normal * nz(i)
383 case(momy_vid)
384 gxvar(ip) = gxvar(im) - 2.0_rp * grad_normal * nx(i)
385 gzvar(ip) = gzvar(im) - 2.0_rp * grad_normal * nz(i)
386 case(momz_vid)
387 gxvar(ip) = gxvar(im) - 2.0_rp * grad_normal * nx(i)
388 gyvar(ip) = gyvar(im) - 2.0_rp * grad_normal * ny(i)
389 end select
390 is_bound(i) = .true.
391
392 end if
393 if ( this%ThermalBC_list(domid)%list(i_) == bnd_type_adiabat_id ) then
394 select case(varid)
395 case(dens_vid, rhot_vid)
396 gxvar(ip) = gxvar(im) - 2.0_rp * grad_normal * nx(i)
397 gyvar(ip) = gyvar(im) - 2.0_rp * grad_normal * ny(i)
398 gzvar(ip) = gzvar(im) - 2.0_rp * grad_normal * nz(i)
399 end select
400 is_bound(i) = .true.
401
402 end if
403
404 end if
405
406 end do
407
408 return
409 end subroutine atmos_dyn_bnd_applybc_numdiff_odd_lc
410
411!OCL SERIAL
412 subroutine atmos_dyn_bnd_applybc_numdiff_even_lc( this, & ! (in)
413 var, & ! (inout)
414 is_bound, & ! (out)
415 varid, domid, & ! (in)
416 nx, ny, nz, vmapm, vmapp, vmapb, lmesh, elem ) ! (in)
417
418 use scale_mesh_bndinfo, only: &
421 implicit none
422
423 class(atmdynbnd), intent(in) :: this
424 class(localmesh3d), intent(in) :: lmesh
425 class(elementbase3d), intent(in) :: elem
426 real(rp), intent(inout) :: var(elem%np*lmesh%nea)
427 logical, intent(out) :: is_bound(elem%nfptot*lmesh%ne)
428 integer, intent(in) :: varid
429 integer, intent(in) :: domid
430 real(rp), intent(in) :: nx(elem%nfptot*lmesh%ne)
431 real(rp), intent(in) :: ny(elem%nfptot*lmesh%ne)
432 real(rp), intent(in) :: nz(elem%nfptot*lmesh%ne)
433 integer, intent(in) :: vmapm(elem%nfptot*lmesh%ne)
434 integer, intent(in) :: vmapp(elem%nfptot*lmesh%ne)
435 integer, intent(in) :: vmapb(:)
436
437 integer :: i, i_, im, ip
438 real(rp) :: grad_normal
439 !-----------------------------------------------
440
441 do i=1, elem%NfpTot*lmesh%Ne
442 ip = vmapp(i)
443 i_ = ip - elem%Np*lmesh%NeE
444 is_bound(i) = .false.
445
446 if (i_ > 0) then
447 im = vmapm(i)
448
449 if ( this%VelBC_list(domid)%list(i_) == bnd_type_slip_id ) then
450 select case(varid)
451 case(momx_vid)
452 grad_normal = var(im) * nx(i)
453 var(ip) = var(im) - 2.0_rp * grad_normal * nx(i)
454 case(momy_vid)
455 grad_normal = var(im) * ny(i)
456 var(ip) = var(im) - 2.0_rp * grad_normal * ny(i)
457 case(momz_vid)
458 grad_normal = var(im) * nz(i)
459 var(ip) = var(im) - 2.0_rp * grad_normal * nz(i)
460 end select
461 is_bound(i) = .true.
462
463 else if ( this%VelBC_list(domid)%list(i_) == bnd_type_noslip_id ) then
464 select case(varid)
465 case( momx_vid, momy_vid, momz_vid )
466 var(ip) = - var(im)
467 end select
468 is_bound(i) = .true.
469 end if
470
471 end if
472 end do
473
474 return
475 end subroutine atmos_dyn_bnd_applybc_numdiff_even_lc
476
477
480!OCL SERIAL
481 subroutine atmos_dyn_bnd_applybc_tbvars_lc( this, &
482 domID, & ! (in)
483 ddens, momx, momy, momz, pt, pres, & ! (inout)
484 dens_hyd, pres_hyd, rtot, cptot, & ! (in)
485 gsqrt, gsqrth, g11, g12, g22, g13, g23, nx, ny, nz, & ! (in)
486 vmapm, vmapp, vmapb, lmesh, elem, lmesh2d, elem2d ) ! (in)
487
488 use scale_const, only: &
489 pres00 => const_pre00
490 use scale_mesh_bndinfo, only: &
493
494 implicit none
495
496 class(atmdynbnd), intent(in) :: this
497 integer, intent(in) :: domid
498 class(localmesh3d), intent(in) :: lmesh
499 class(elementbase3d), intent(in) :: elem
500 class(localmesh2d), intent(in) :: lmesh2d
501 class(elementbase2d), intent(in) :: elem2d
502 real(rp), intent(inout) :: ddens(elem%np*lmesh%nea)
503 real(rp), intent(inout) :: momx(elem%np*lmesh%nea)
504 real(rp), intent(inout) :: momy(elem%np*lmesh%nea)
505 real(rp), intent(inout) :: momz(elem%np*lmesh%nea)
506 real(rp), intent(inout) :: pt(elem%np*lmesh%nea)
507 real(rp), intent(inout) :: pres(elem%np*lmesh%nea)
508 real(rp), intent(in) :: dens_hyd(elem%np*lmesh%nea)
509 real(rp), intent(in) :: pres_hyd(elem%np*lmesh%nea)
510 real(rp), intent(in) :: rtot(elem%np*lmesh%nea)
511 real(rp), intent(in) :: cptot(elem%np*lmesh%nea)
512 real(rp), intent(in) :: gsqrt(elem%np*lmesh%nea)
513 real(rp), intent(in) :: gsqrth(elem2d%np,lmesh2d%ne)
514 real(rp), intent(in) :: g11(elem2d%np,lmesh2d%ne)
515 real(rp), intent(in) :: g12(elem2d%np,lmesh2d%ne)
516 real(rp), intent(in) :: g22(elem2d%np,lmesh2d%ne)
517 real(rp), intent(in) :: g13(elem%np*lmesh%nea)
518 real(rp), intent(in) :: g23(elem%np*lmesh%nea)
519 real(rp), intent(in) :: nx(elem%nfptot*lmesh%ne)
520 real(rp), intent(in) :: ny(elem%nfptot*lmesh%ne)
521 real(rp), intent(in) :: nz(elem%nfptot*lmesh%ne)
522 integer, intent(in) :: vmapm(elem%nfptot*lmesh%ne)
523 integer, intent(in) :: vmapp(elem%nfptot*lmesh%ne)
524 integer, intent(in) :: vmapb(:)
525
526 integer :: p, ke, ke2d
527 integer :: i, i_, im, ip
528 real(rp) :: mom_normal
529
530 real(rp) :: momw
531 real(rp) :: temp_p, temp_b
532 real(rp) :: gsqrtv, g11_, g12_, g22_
533 real(rp) :: fac
534 !-----------------------------------------------
535
536 !$omp parallel do collapse(2) private( &
537 !$omp ke, p, ke2D, i, i_, iM, iP, &
538 !$omp mom_normal, MOMW, GsqrtV, G11_, G12_, G22_, fac, &
539 !$omp TEMP_P, TEMP_B )
540 do ke=lmesh%NeS, lmesh%NeE
541 do p=1, elem%NfpTot
542 i = p + (ke-1)*elem%NfpTot
543 ip = vmapp(i)
544 i_ = ip - elem%Np*lmesh%NeE
545
546 if (i_ > 0) then
547 im = vmapm(i)
548
549 select case( this%VelBC_list(domid)%list(i_) )
550 case ( bnd_type_slip_id)
551 ke2d = lmesh%EMap3Dto2D(ke)
552
553 gsqrtv = gsqrt(im) / gsqrth(elem%IndexH2Dto3D_bnd(p),ke2d)
554 g11_ = g11(elem%IndexH2Dto3D_bnd(p),ke2d)
555 g12_ = g12(elem%IndexH2Dto3D_bnd(p),ke2d)
556 g22_ = g22(elem%IndexH2Dto3D_bnd(p),ke2d)
557
558 momw = momz(im) / gsqrtv &
559 + g13(im) * momx(im) + g23(im) * momy(im)
560 fac = nz(i) * gsqrtv**2 / ( 1.0_rp + g11_ * ( gsqrtv * g13(im) )**2 + 2.0_rp * g12_ * ( gsqrtv**2 * g13(im) * g23(im) ) + g22_ * ( gsqrtv * g23(im) )**2 )
561
562 mom_normal = momx(im) * nx(i) + momy(im) * ny(i) + momw * nz(i)
563 momx(ip) = momx(im) - 2.0_rp * mom_normal * ( nx(i) + fac * ( g11_ * g13(im) + g12_ * g23(im) ) )
564 momy(ip) = momy(im) - 2.0_rp * mom_normal * ( ny(i) + fac * ( g12_ * g13(im) + g22_ * g23(im) ) )
565 momz(ip) = momz(im) - 2.0_rp * mom_normal * fac / gsqrtv
566
567 case ( bnd_type_noslip_id )
568 momx(ip) = - momx(im)
569 momy(ip) = - momy(im)
570 momz(ip) = - momz(im)
571 end select
572
573 select case( this%ThermalBC_list(domid)%list(i_) )
574 case ( bnd_type_fixval_id )
575 temp_b = this%ThermalBC_list(domid)%val(i_)
576 temp_p = 2.0_rp * temp_b - pres(im) / ( ( dens_hyd(im) + ddens(im) ) * rtot(im) )
577 pt(ip) = temp_p * ( pres00 / pres(im) )**(rtot(im)/cptot(im))
578 ddens(ip) = pres(im) / ( rtot(im) * temp_p ) - dens_hyd(im)
579 end select
580 end if
581
582 end do
583 end do
584
585 return
586 end subroutine atmos_dyn_bnd_applybc_tbvars_lc
587
592!OCL SERIAL
593 subroutine atmos_dyn_bnd_applybc_tbstress_lc( this, &
594 domID, & ! (in)
595 t11, t12, t13, t21, t22, t23, t31, t32, t33, & ! (inout)
596 df1, df2, df3, & ! (in)
597 gsqrt, gsqrth, g11, g12, g22, g13, g23, nx, ny, nz, & ! (in)
598 vmapm, vmapp, vmapb, lmesh, elem, lmesh2d, elem2d ) ! (in)
599
600 use scale_mesh_bndinfo, only: &
603
604 implicit none
605
606 class(atmdynbnd), intent(in) :: this
607 integer, intent(in) :: domid
608 class(localmesh3d), intent(in) :: lmesh
609 class(elementbase3d), intent(in) :: elem
610 class(localmesh2d), intent(in) :: lmesh2d
611 class(elementbase2d), intent(in) :: elem2d
612 real(rp), intent(inout) :: t11(elem%np*lmesh%nea), t12(elem%np*lmesh%nea), t13(elem%np*lmesh%nea)
613 real(rp), intent(inout) :: t21(elem%np*lmesh%nea), t22(elem%np*lmesh%nea), t23(elem%np*lmesh%nea)
614 real(rp), intent(inout) :: t31(elem%np*lmesh%nea), t32(elem%np*lmesh%nea), t33(elem%np*lmesh%nea)
615 real(rp), intent(inout) :: df1(elem%np*lmesh%nea), df2(elem%np*lmesh%nea), df3(elem%np*lmesh%nea)
616 real(rp), intent(in) :: gsqrt(elem%np*lmesh%nea)
617 real(rp), intent(in) :: gsqrth(elem2d%np,lmesh2d%ne)
618 real(rp), intent(in) :: g11(elem2d%np,lmesh2d%ne)
619 real(rp), intent(in) :: g12(elem2d%np,lmesh2d%ne)
620 real(rp), intent(in) :: g22(elem2d%np,lmesh2d%ne)
621 real(rp), intent(in) :: g13(elem%np*lmesh%nea)
622 real(rp), intent(in) :: g23(elem%np*lmesh%nea)
623 real(rp), intent(in) :: nx(elem%nfptot*lmesh%ne)
624 real(rp), intent(in) :: ny(elem%nfptot*lmesh%ne)
625 real(rp), intent(in) :: nz(elem%nfptot*lmesh%ne)
626 integer, intent(in) :: vmapm(elem%nfptot*lmesh%ne)
627 integer, intent(in) :: vmapp(elem%nfptot*lmesh%ne)
628 integer, intent(in) :: vmapb(:)
629
630 integer :: p, ke, ke2d
631 integer :: i, i_, im, ip
632
633 real(rp) :: gsqrtv, g11_, g12_, g22_
634 real(rp) :: fac, normal_vec(3)
635
636 real(rp) :: stress_t_tmp, stress_t_tmpvec(3)
637 real(rp) :: vecw
638 real(rp) :: normal_flux
639 !-----------------------------------------------
640
641 !$omp parallel do collapse(2) private( &
642 !$omp ke, p, ke2D, i, i_, iM, iP, &
643 !$omp VECW, GsqrtV, G11_, G12_, G22_, fac, normal_vec, &
644 !$omp stress_t_tmp, stress_t_tmpvec, normal_flux )
645 do ke=lmesh%NeS, lmesh%NeE
646 do p=1, elem%NfpTot
647 i = p + (ke-1)*elem%NfpTot
648 ip = vmapp(i)
649 i_ = ip - elem%Np*lmesh%NeE
650
651 if (i_ > 0) then
652 ke2d = lmesh%EMap3Dto2D(ke)
653 im = vmapm(i)
654
655 gsqrtv = gsqrt(im) / gsqrth(elem%IndexH2Dto3D_bnd(p),ke2d)
656 g11_ = g11(elem%IndexH2Dto3D_bnd(p),ke2d)
657 g12_ = g12(elem%IndexH2Dto3D_bnd(p),ke2d)
658 g22_ = g22(elem%IndexH2Dto3D_bnd(p),ke2d)
659 fac = nz(i) * gsqrtv**2 / ( 1.0_rp + g11_ * ( gsqrtv * g13(im) )**2 + 2.0_rp * g12_ * ( gsqrtv**2 * g13(im) * g23(im) ) + g22_ * ( gsqrtv * g23(im) )**2 )
660 normal_vec(1) = nx(i) + fac * ( g11_ * g13(im) + g12_ * g23(im) )
661 normal_vec(2) = ny(i) + fac * ( g12_ * g13(im) + g22_ * g23(im) )
662 normal_vec(3) = fac / gsqrtv
663
664 select case( this%VelBC_list(domid)%list(i_) )
665 case ( bnd_type_slip_id)
666 vecw = t13(im) / gsqrtv + g13(im) * t11(im) + g23(im) * t12(im)
667 stress_t_tmpvec(1) = t11(im) * nx(i) + t12(im) * ny(i) + vecw * nz(i)
668
669 vecw = t23(im) / gsqrtv + g13(im) * t21(im) + g23(im) * t22(im)
670 stress_t_tmpvec(2) = t21(im) * nx(i) + t22(im) * ny(i) + vecw * nz(i)
671
672 vecw = t33(im) / gsqrtv
673 stress_t_tmpvec(3) = t31(im) * nx(i) + t32(im) * ny(i) + vecw * nz(i)
674
675 stress_t_tmp = sum( stress_t_tmpvec(:) * normal_vec(:) )
676 stress_t_tmpvec(:) = stress_t_tmpvec(:) - stress_t_tmp * normal_vec(:)
677
678 ! T1j
679 t11(ip) = t11(im) - 2.0_rp * stress_t_tmpvec(1) * normal_vec(1)
680 t12(ip) = t12(im) - 2.0_rp * stress_t_tmpvec(1) * normal_vec(2)
681 t13(ip) = t13(im) - 2.0_rp * stress_t_tmpvec(1) * normal_vec(3)
682
683 ! T2j
684 t21(ip) = t21(im) - 2.0_rp * stress_t_tmpvec(2) * normal_vec(1)
685 t22(ip) = t22(im) - 2.0_rp * stress_t_tmpvec(2) * normal_vec(2)
686 t23(ip) = t23(im) - 2.0_rp * stress_t_tmpvec(2) * normal_vec(3)
687
688 ! T3j
689 t31(ip) = t31(im) - 2.0_rp * stress_t_tmpvec(3) * normal_vec(1)
690 t32(ip) = t32(im) - 2.0_rp * stress_t_tmpvec(3) * normal_vec(2)
691 t33(ip) = t33(im) - 2.0_rp * stress_t_tmpvec(3) * normal_vec(3)
692
693 case ( bnd_type_noslip_id )
694 end select
695
696 select case( this%ThermalBC_list(domid)%list(i_) )
697 case ( bnd_type_adiabat_id )
698 normal_flux = df1(im) * nx(i) + df2(im) * ny(i) &
699 + ( df3(im) / gsqrtv + g13(im) * df1(im) + g23(im) * df2(im) ) * nz(i)
700 df1(ip) = df1(im) - 2.0_rp * normal_flux * normal_vec(1)
701 df2(ip) = df2(im) - 2.0_rp * normal_flux * normal_vec(2)
702 df3(ip) = df3(im) - 2.0_rp * normal_flux * normal_vec(3)
703 end select
704 end if
705 end do
706 end do
707
708 return
709 end subroutine atmos_dyn_bnd_applybc_tbstress_lc
710
711!OCL SERIAL
712 subroutine atmos_dyn_bnd_inquire_bound_flag( this, & ! (in)
713 is_bound, & ! (out)
714 domid, vmapm, vmapp, vmapb, lmesh, elem ) ! (in)
715
716 use scale_mesh_bndinfo, only: &
719 implicit none
720
721 class(atmdynbnd), intent(in) :: this
722 class(localmesh3d), intent(in) :: lmesh
723 class(elementbase3d), intent(in) :: elem
724 logical, intent(out) :: is_bound(elem%nfptot*lmesh%ne)
725 integer, intent(in) :: domid
726 integer, intent(in) :: vmapm(elem%nfptot*lmesh%ne)
727 integer, intent(in) :: vmapp(elem%nfptot*lmesh%ne)
728 integer, intent(in) :: vmapb(:)
729
730 integer :: i, i_, im, ip
731 !-----------------------------------------------
732
733 do i=1, elem%NfpTot*lmesh%Ne
734 ip = vmapp(i)
735 i_ = ip - elem%Np*lmesh%NeE
736 is_bound(i) = .false.
737
738 if (i_ > 0) then
739 im = vmapm(i)
740 if ( this%VelBC_list(domid)%list(i_) == bnd_type_slip_id ) then
741 is_bound(i) = .true.
742 else if ( this%VelBC_list(domid)%list(i_) == bnd_type_noslip_id ) then
743 is_bound(i) = .true.
744 end if
745
746 end if
747 end do
748
749 return
750 end subroutine atmos_dyn_bnd_inquire_bound_flag
751
752 !-- private -------------------------------------------------------
753
754!OCL SERIAL
755 subroutine bnd_init_lc( &
756 velBCInfo, thermalBCInfo, & ! (inout)
757 velbc_ids, thermalbc_ids, & ! (in)
758 thermal_fixval, & ! (in)
759 vmapb, mesh, lmesh, elem ) ! (in)
760
762 implicit none
763
764 type(meshbndinfo), intent(inout) :: velbcinfo
765 type(meshbndinfo), intent(inout) :: thermalbcinfo
766 integer, intent(in) :: velbc_ids(dom_bnd_num)
767 integer, intent(in) :: thermalbc_ids(dom_bnd_num)
768 real(rp), intent(in) :: thermal_fixval(dom_bnd_num)
769 class(meshbase), intent(in) :: mesh
770 class(localmesh3d), intent(in) :: lmesh
771 class(elementbase3d), intent(in) :: elem
772 integer, intent(in) :: vmapb(:)
773
774 integer :: tileid
775 integer :: dom_bnd_sizes(dom_bnd_num)
776 integer :: bnd_buf_size
777 integer :: b, is_, ie_
778
779 !-----------------------------------------------
780
781 dom_bnd_sizes(:) = &
782 elem%Nfp_h*lmesh%NeZ*(/ lmesh%NeX, lmesh%NeY, lmesh%NeX, lmesh%NeY, 0, 0 /) &
783 + elem%Nfp_v*lmesh%NeX*lmesh%NeY*(/ 0, 0, 0, 0, 1, 1 /)
784 bnd_buf_size = sum(dom_bnd_sizes)
785
786 call velbcinfo%Init( bnd_buf_size )
787 call velbcinfo%Set(1, bnd_buf_size, bnd_type_nospec_id)
788
789 call thermalbcinfo%Init( bnd_buf_size )
790 call thermalbcinfo%Set(1, bnd_buf_size, bnd_type_nospec_id)
791
792 tileid = lmesh%tileID
793 is_ = 1
794 do b=1, dom_bnd_num
795 ie_ = is_ + dom_bnd_sizes(b) - 1
796 if ( mesh%tileID_globalMap(b,tileid) == tileid &
797 .and. mesh%tileFaceID_globalMap(b,tileid) == b ) then
798 call velbcinfo%Set( is_, ie_, velbc_ids(b) )
799 call thermalbcinfo%Set( is_, ie_, thermalbc_ids(b), thermal_fixval(b) )
800 end if
801 is_ = ie_ + 1
802 end do
803
804 return
805 end subroutine bnd_init_lc
806
807end module scale_atm_dyn_dgm_bnd
module FElib / Fluid dyn solver / Atmosphere / Boundary
integer, parameter dombnd_south_id
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / Common
module FElib / Element / Base
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Local, Base
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Mesh / Base
module FElib / Mesh / Boundary information
integer, parameter, public bnd_type_slip_id
character(len= *), parameter, public bnd_type_nospec_name
integer, parameter, public bnd_type_fixval_id
integer function, public bndtype_nametoid(bnd_type_name)
integer, parameter, public bnd_type_periodic_id
integer, parameter, public bnd_type_nospec_id
integer, parameter, public bnd_type_adiabat_id
integer, parameter, public bnd_type_noslip_id
module FElib / Data / base