FE-Project
Loading...
Searching...
No Matches
scale_atm_dyn_dgm_globalsw.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
21 use scale_const, only: &
22 grav => const_grav
23
25 use scale_element_base, only: &
32
33 !-----------------------------------------------------------------------------
34 implicit none
35 private
36 !-----------------------------------------------------------------------------
37 !
38 !++ Public procedures
39 !
43
44 !-----------------------------------------------------------------------------
45 !
46 !++ Public parameters & variables
47 !
48
49 !-----------------------------------------------------------------------------
50 !
51 !++ Private procedures & variables
52 !
53 !-------------------
54
55 integer, private, parameter :: VARS_H_ID = 1
56 integer, private, parameter :: VARS_U1_ID = 2
57 integer, private, parameter :: VARS_u2_ID = 3
58 integer, private, parameter :: PROG_VARS_NUM = 3
59
60 private :: cal_del_flux_dyn
61
62contains
63 subroutine atm_dyn_dgm_globalsw_init( mesh )
64 implicit none
65 class(meshbase2d), intent(in) :: mesh
66 !--------------------------------------------
67 return
68 end subroutine atm_dyn_dgm_globalsw_init
69
70
72 implicit none
73 !--------------------------------------------
74 return
75 end subroutine atm_dyn_dgm_globalsw_final
76
77 !-------------------------------
78
79!OCL SERIAL
81 h_dt, U_dt, V_dt, & ! (out)
82 h_, u_, v_, hs_, u1_, u2_, coriolis, & ! (in)
83 dx, dy, sx, sy, lift, lmesh, elem )
84
85 implicit none
86
87 class(localmesh2d), intent(in) :: lmesh
88 class(elementbase2d), intent(in) :: elem
89 type(sparsemat), intent(in) :: dx, dy, sx, sy, lift
90 real(rp), intent(out) :: h_dt(elem%np,lmesh%nea)
91 real(rp), intent(out) :: u_dt(elem%np,lmesh%nea)
92 real(rp), intent(out) :: v_dt(elem%np,lmesh%nea)
93 real(rp), intent(in) :: h_(elem%np,lmesh%nea)
94 real(rp), intent(in) :: u_(elem%np,lmesh%nea)
95 real(rp), intent(in) :: v_(elem%np,lmesh%nea)
96 real(rp), intent(in) :: hs_(elem%np,lmesh%nea)
97 real(rp), intent(in) :: u1_(elem%np,lmesh%nea)
98 real(rp), intent(in) :: u2_(elem%np,lmesh%nea)
99 real(rp), intent(in) :: coriolis(elem%np,lmesh%nea)
100
101 real(rp) :: fx(elem%np), fy(elem%np), liftdelflx(elem%np)
102 real(rp) :: del_flux(elem%nfptot,lmesh%ne,prog_vars_num)
103 real(rp) :: del_flux_aux(elem%nfptot,lmesh%ne,1)
104 real(rp) :: u1_dt(elem%np), u2_dt(elem%np)
105 real(rp) :: vor(elem%np), e(elem%np)
106 integer :: ke
107 !------------------------------------------------------------------------
108
109 call prof_rapstart('cal_dyn_tend_bndflux', 3)
110 call cal_del_flux_dyn( del_flux, del_flux_aux, & ! (out)
111 h_, u_, v_, hs_, u1_, u2_, & ! (in)
112 lmesh%Gsqrt, lmesh%GIJ(:,:,1,1), lmesh%GIJ(:,:,2,2), & ! (in)
113 lmesh%normal_fn(:,:,1), lmesh%normal_fn(:,:,2), & ! (in)
114 lmesh%vmapM, lmesh%vmapP, & ! (in)
115 lmesh, elem ) ! (in)
116 call prof_rapend('cal_dyn_tend_bndflux', 3)
117
118 !-----
119 call prof_rapstart('cal_dyn_tend_interior', 3)
120
121 !$omp parallel do private( &
122 !$omp E, VOR, &
123 !$omp u1_dt, u2_dt, Fx, Fy, LiftDelFlx )
124 do ke = lmesh%NeS, lmesh%NeE
125 !--
126 call sparsemat_matmul(dx, u2_(:,ke), fx)
127 call sparsemat_matmul(dy, u1_(:,ke), fy)
128 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux_aux(:,ke,1), liftdelflx)
129
130 vor(:) = ( &
131 lmesh%Escale(:,ke,1,1) * fx(:) &
132 - lmesh%Escale(:,ke,2,2) * fy(:) &
133 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke)
134
135 e(:) = grav * ( hs_(:,ke) + h_(:,ke) ) &
136 + 0.5_rp * ( u1_(:,ke) * u_(:,ke) + u2_(:,ke) * v_(:,ke) )
137
138 !-- h
139 call sparsemat_matmul(dx, lmesh%Gsqrt(:,ke) * h_(:,ke) * u_(:,ke), fx)
140 call sparsemat_matmul(dy, lmesh%Gsqrt(:,ke) * h_(:,ke) * v_(:,ke), fy)
141 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,vars_h_id), liftdelflx)
142
143 h_dt(:,ke) = - ( &
144 lmesh%Escale(:,ke,1,1) * fx(:) &
145 + lmesh%Escale(:,ke,2,2) * fy(:) &
146 + liftdelflx(:) ) / lmesh%Gsqrt(:,ke)
147
148 !-- u1
149 call sparsemat_matmul(dx, e(:), fx)
150 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,vars_u1_id), liftdelflx)
151
152 u1_dt(:) = - ( &
153 lmesh%Escale(:,ke,1,1) * fx(:) &
154 + liftdelflx(:) &
155 - lmesh%Gsqrt(:,ke) * ( coriolis(:,ke) + vor(:) ) * v_(:,ke) )
156
157 !-- u2
158 call sparsemat_matmul(dy, e(:), fy)
159 call sparsemat_matmul(lift, lmesh%Fscale(:,ke) * del_flux(:,ke,vars_u2_id), liftdelflx)
160
161 u2_dt(:) = - ( &
162 lmesh%Escale(:,ke,2,2) * fy(:) &
163 + liftdelflx(:) &
164 + lmesh%Gsqrt(:,ke) * ( coriolis(:,ke) + vor(:) ) * u_(:,ke) )
165
166 !--
167 u_dt(:,ke) = lmesh%GIJ(:,ke,1,1) * u1_dt(:) + lmesh%GIJ(:,ke,1,2) * u2_dt(:)
168 v_dt(:,ke) = lmesh%GIJ(:,ke,2,1) * u1_dt(:) + lmesh%GIJ(:,ke,2,2) * u2_dt(:)
169 end do
170
171 call prof_rapend('cal_dyn_tend_interior', 3)
172
173 return
174 end subroutine atm_dyn_dgm_globalsw_cal_tend
175
176 !------
177
178!OCL SERIAL
179 subroutine cal_del_flux_dyn( del_flux, del_flux_aux, &
180 h_, U_, V_, hs_, u1_, u2_, &
181 Gsqrt_, G11_, G22_, nx, ny, vmapM, vmapP, lmesh, elem )
182
183 implicit none
184
185 class(localmesh2d), intent(in) :: lmesh
186 class(elementbase2d), intent(in) :: elem
187 real(rp), intent(out) :: del_flux(elem%nfptot,lmesh%ne,prog_vars_num)
188 real(rp), intent(out) :: del_flux_aux(elem%nfptot,lmesh%ne,1)
189 real(rp), intent(in) :: h_(elem%np*lmesh%nea)
190 real(rp), intent(in) :: u_(elem%np*lmesh%nea)
191 real(rp), intent(in) :: v_(elem%np*lmesh%nea)
192 real(rp), intent(in) :: hs_(elem%np*lmesh%nea)
193 real(rp), intent(in) :: u1_(elem%np*lmesh%nea)
194 real(rp), intent(in) :: u2_(elem%np*lmesh%nea)
195 real(rp), intent(in) :: gsqrt_(elem%np*lmesh%nea)
196 real(rp), intent(in) :: g11_(elem%np*lmesh%ne)
197 real(rp), intent(in) :: g22_(elem%np*lmesh%ne)
198 real(rp), intent(in) :: nx(elem%nfptot,lmesh%ne)
199 real(rp), intent(in) :: ny(elem%nfptot,lmesh%ne)
200 integer, intent(in) :: vmapm(elem%nfptot,lmesh%ne)
201 integer, intent(in) :: vmapp(elem%nfptot,lmesh%ne)
202
203 integer :: ke, ip(elem%nfptot), im(elem%nfptot)
204 real(rp) :: velp(elem%nfptot), velm(elem%nfptot), alpha(elem%nfptot)
205 real(rp) :: h_p(elem%nfptot), h_m(elem%nfptot)
206 real(rp) :: e_p(elem%nfptot), e_m(elem%nfptot)
207 real(rp) :: gii(elem%nfptot)
208 !------------------------------------------------------------------------
209
210
211 !$omp parallel do private( iM, iP, &
212 !$omp alpha, VelM, VelP, &
213 !$omp h_P, h_M, E_P, E_M, Gii )
214 do ke=lmesh%NeS, lmesh%NeE
215 im(:) = vmapm(:,ke); ip(:) = vmapp(:,ke)
216
217 h_m(:) = h_(im)
218 h_p(:) = h_(ip)
219 velm(:) = u_(im) * nx(:,ke) + v_(im) * ny(:,ke)
220 velp(:) = u_(ip) * nx(:,ke) + v_(ip) * ny(:,ke)
221 gii(:) = g11_(im) * abs(nx(:,ke)) + g22_(im) * abs(ny(:,ke))
222
223 e_m(:) = 0.5_rp * ( u_(im) * u1_(im) + v_(im) * u2_(im) ) &
224 + grav * ( h_m(:) + hs_(im) )
225 e_p(:) = 0.5_rp * ( u_(ip) * u1_(ip) + v_(ip) * u2_(ip) ) &
226 + grav * ( h_p(:) + hs_(ip) )
227
228 alpha(:) = max( sqrt( gii(:) * grav * (h_m(:) + hs_(im)) ) + abs(velm(:)), &
229 sqrt( gii(:) * grav * (h_p(:) + hs_(ip)) ) + abs(velp(:)) )
230
231 del_flux(:,ke,vars_h_id) = 0.5_rp * gsqrt_(im) * ( &
232 (h_p(:) * velp(:) - h_m(:) * velm(:) ) &
233 - alpha(:) * ( h_p(:) - h_m(:) ) )
234
235 del_flux(:,ke,vars_u1_id) = 0.5_rp * ( &
236 ( e_p(:) - e_m(:) ) * nx(:,ke) &
237 - alpha(:) * ( u1_(ip) - u1_(im) ) )
238
239 del_flux(:,ke,vars_u2_id) = 0.5_rp * ( &
240 ( e_p(:) - e_m(:) ) * ny(:,ke) &
241 - alpha(:) * ( u2_(ip) - u2_(im) ) )
242
243 del_flux_aux(:,ke,1) = 0.5_rp * ( &
244 ( u2_(ip) - u2_(im) ) * nx(:,ke) &
245 - ( u1_(ip) - u1_(im) ) * ny(:,ke) )
246 end do
247
248 return
249 end subroutine cal_del_flux_dyn
250
module FElib / Fluid dyn solver / Atmosphere / Global shallow water
subroutine, public atm_dyn_dgm_globalsw_final()
subroutine, public atm_dyn_dgm_globalsw_init(mesh)
subroutine, public atm_dyn_dgm_globalsw_cal_tend(h_dt, u_dt, v_dt, h_, u_, v_, hs_, u1_, u2_, coriolis, dx, dy, sx, sy, lift, lmesh, elem)
module FElib / Element / Base
module FElib / Element / Quadrilateral
module FElib / Mesh / Local 2D
module FElib / Mesh / Base 2D
module FElib / Data / base
module common / sparsemat