46 public :: opr_cpu_dudxyz, opr_cpu_opgrad, opr_cpu_cdtp, &
48 opr_cpu_convect_scalar, opr_cpu_set_convect_rst, &
53 module subroutine opr_cpu_dudxyz(du, u, dr, ds, dt, coef)
54 type(coef_t),
intent(in),
target :: coef
55 real(kind=
rp),
intent(inout), &
56 dimension(coef%Xh%lx, coef%Xh%ly, coef%Xh%lz, coef%msh%nelv) :: du
57 real(kind=
rp),
intent(in), &
58 dimension(coef%Xh%lx, coef%Xh%ly, coef%Xh%lz, coef%msh%nelv) :: &
60 end subroutine opr_cpu_dudxyz
62 module subroutine opr_cpu_opgrad(ux, uy, uz, u, coef, e_start, e_end)
63 type(coef_t),
intent(in) :: coef
64 integer,
intent(in) :: e_start, e_end
65 real(kind=
rp),
intent(inout) :: ux(coef%Xh%lxyz, e_end - e_start + 1)
66 real(kind=
rp),
intent(inout) :: uy(coef%Xh%lxyz, e_end - e_start + 1)
67 real(kind=
rp),
intent(inout) :: uz(coef%Xh%lxyz, e_end - e_start + 1)
68 real(kind=
rp),
intent(in) :: u(coef%Xh%lxyz, e_end - e_start + 1)
69 end subroutine opr_cpu_opgrad
71 module subroutine opr_cpu_cdtp(dtx, x, dr, ds, dt, coef, e_start, e_end)
72 type(coef_t),
intent(in) :: coef
73 integer,
intent(in) :: e_start, e_end
74 real(kind=
rp),
intent(inout) :: dtx(coef%Xh%lxyz, e_end - e_start + 1)
75 real(kind=
rp),
intent(inout) :: x(coef%Xh%lxyz, e_end - e_start + 1)
76 real(kind=
rp),
intent(in) :: dr(coef%Xh%lxyz, e_end - e_start + 1)
77 real(kind=
rp),
intent(in) :: ds(coef%Xh%lxyz, e_end - e_start + 1)
78 real(kind=
rp),
intent(in) :: dt(coef%Xh%lxyz, e_end - e_start + 1)
79 end subroutine opr_cpu_cdtp
81 module subroutine opr_cpu_conv1(du, u, vx, vy, vz, xh, &
83 type(space_t),
intent(in) :: Xh
84 type(coef_t),
intent(in) :: coef
85 integer,
intent(in) :: e_start, e_end
86 real(kind=
rp),
intent(inout) :: du(xh%lxyz, e_end - e_start + 1)
87 real(kind=
rp),
intent(inout) :: &
88 u(xh%lx, xh%ly, xh%lz, e_end - e_start + 1)
89 real(kind=
rp),
intent(inout) :: &
90 vx(xh%lx, xh%ly, xh%lz, e_end - e_start + 1)
91 real(kind=
rp),
intent(inout) :: &
92 vy(xh%lx, xh%ly, xh%lz, e_end - e_start + 1)
93 real(kind=
rp),
intent(inout) :: &
94 vz(xh%lx, xh%ly, xh%lz, e_end - e_start + 1)
95 end subroutine opr_cpu_conv1
97 module subroutine opr_cpu_convect_scalar(du, u, cr, cs, ct, xh_gll, &
98 xh_gl, coef_gll, coef_gl, gll_to_gl)
99 type(space_t),
intent(in) :: Xh_GL
100 type(space_t),
intent(in) :: Xh_GLL
101 type(coef_t),
intent(in) :: coef_GLL
102 type(coef_t),
intent(in) :: coef_GL
103 type(interpolator_t),
intent(inout) :: GLL_to_GL
104 real(kind=
rp),
intent(inout) :: &
105 du(xh_gll%lx, xh_gll%ly, xh_gll%lz, coef_gl%msh%nelv)
106 real(kind=
rp),
intent(inout) :: &
107 u(xh_gl%lx, xh_gl%lx, xh_gl%lx, coef_gl%msh%nelv)
108 real(kind=
rp),
intent(inout) :: cr(xh_gl%lxyz, coef_gl%msh%nelv)
109 real(kind=
rp),
intent(inout) :: cs(xh_gl%lxyz, coef_gl%msh%nelv)
110 real(kind=
rp),
intent(inout) :: ct(xh_gl%lxyz, coef_gl%msh%nelv)
112 end subroutine opr_cpu_convect_scalar
114 module subroutine opr_cpu_set_convect_rst(cr, cs, ct, cx, cy, cz, &
116 type(space_t),
intent(inout) :: Xh
117 type(coef_t),
intent(inout) :: coef
118 real(kind=
rp),
dimension(Xh%lxyz, coef%msh%nelv), &
119 intent(inout) :: cr, cs, ct
120 real(kind=
rp),
dimension(Xh%lxyz, coef%msh%nelv), &
121 intent(in) :: cx, cy, cz
122 end subroutine opr_cpu_set_convect_rst
127 subroutine opr_cpu_curl(w1, w2, w3, u1, u2, u3, work1, work2, c_Xh)
128 type(
field_t),
intent(inout) :: w1
129 type(
field_t),
intent(inout) :: w2
130 type(
field_t),
intent(inout) :: w3
131 type(
field_t),
intent(in) :: u1
132 type(
field_t),
intent(in) :: u2
133 type(
field_t),
intent(in) :: u3
134 type(
field_t),
intent(inout) :: work1
135 type(
field_t),
intent(inout) :: work2
136 type(
coef_t),
intent(in) :: c_xh
143 call opr_cpu_dudxyz(work1%x, u3%x, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
144 if (gdim .eq. 3)
then
145 call opr_cpu_dudxyz(work2%x, u2%x, c_xh%drdz, c_xh%dsdz, &
147 call sub3(w1%x, work1%x, work2%x, n)
149 call copy(w1%x, work1%x, n)
152 if (gdim .eq. 3)
then
153 call opr_cpu_dudxyz(work1%x, u1%x, c_xh%drdz, c_xh%dsdz, c_xh%dtdz, c_xh)
154 call opr_cpu_dudxyz(work2%x, u3%x, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
155 call sub3(w2%x, work1%x, work2%x, n)
157 call rzero(work1%x, n)
158 call opr_cpu_dudxyz(work2%x, u3%x, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
159 call sub3(w2%x, work1%x, work2%x, n)
162 call opr_cpu_dudxyz(work1%x, u2%x, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
163 call opr_cpu_dudxyz(work2%x, u1%x, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
164 call sub3(w3%x, work1%x, work2%x, n)
167 call opcolv(w1%x, w2%x, w3%x, c_xh%B, gdim, n)
168 if (c_xh%cyclic)
call opr_cpu_rotate_cyc_r4(w1%x, w2%x, w3%x, 1, c_xh)
169 call c_xh%gs_h%op(w1, gs_op_add)
170 call c_xh%gs_h%op(w2, gs_op_add)
171 call c_xh%gs_h%op(w3, gs_op_add)
172 if (c_xh%cyclic)
call opr_cpu_rotate_cyc_r4(w1%x, w2%x, w3%x, 0, c_xh)
173 call opcolv(w1%x, w2%x, w3%x, c_xh%Binv, gdim, n)
175 end subroutine opr_cpu_curl
177 function opr_cpu_cfl(dt, u, v, w, Xh, coef, nelv, gdim)
result(cfl)
180 integer :: nelv, gdim
182 real(kind=
rp),
dimension(Xh%lx, Xh%ly, Xh%lz, nelv) :: u, v, w
183 real(kind=
rp) :: cflr, cfls, cflt, cflm
184 real(kind=
rp) :: ur, us, ut
186 integer :: i, j, k, e
188 if (gdim .eq. 3)
then
193 ur = ( u(i,j,k,e)*coef%drdx(i,j,k,e) &
194 + v(i,j,k,e)*coef%drdy(i,j,k,e) &
195 + w(i,j,k,e)*coef%drdz(i,j,k,e) ) &
196 * coef%jacinv(i,j,k,e)
197 us = ( u(i,j,k,e)*coef%dsdx(i,j,k,e) &
198 + v(i,j,k,e)*coef%dsdy(i,j,k,e) &
199 + w(i,j,k,e)*coef%dsdz(i,j,k,e) ) &
200 * coef%jacinv(i,j,k,e)
201 ut = ( u(i,j,k,e)*coef%dtdx(i,j,k,e) &
202 + v(i,j,k,e)*coef%dtdy(i,j,k,e) &
203 + w(i,j,k,e)*coef%dtdz(i,j,k,e) ) &
204 * coef%jacinv(i,j,k,e)
206 cflr = abs(dt*ur*xh%dr_inv(i))
207 cfls = abs(dt*us*xh%ds_inv(j))
208 cflt = abs(dt*ut*xh%dt_inv(k))
210 cflm = cflr + cfls + cflt
220 ur = ( u(i,j,1,e)*coef%drdx(i,j,1,e) &
221 + v(i,j,1,e)*coef%drdy(i,j,1,e) ) * coef%jacinv(i,j,1,e)
222 us = ( u(i,j,1,e)*coef%dsdx(i,j,1,e) &
223 + v(i,j,1,e)*coef%dsdy(i,j,1,e) ) * coef%jacinv(i,j,1,e)
225 cflr = abs(dt*ur*xh%dr_inv(i))
226 cfls = abs(dt*us*xh%ds_inv(j))
235 end function opr_cpu_cfl
237 subroutine opr_cpu_lambda2(lambda2, u, v, w, coef)
238 type(
coef_t),
intent(in) :: coef
240 type(
field_t),
intent(in) :: u, v, w
241 real(kind=
rp) :: grad(coef%Xh%lxyz,3,3)
243 real(kind=
xp) :: eigen(3), b, c, d, q, r, theta, l2
244 real(kind=
xp) :: s11, s22, s33, s12, s13, s23, o12, o13, o23
245 real(kind=
xp) :: a11, a22, a33, a12, a13, a23
246 real(kind=
xp) :: msk1, msk2, msk3
248 do e = 1, coef%msh%nelv
249 call opr_cpu_opgrad(grad(1,1,1), grad(1,1,2), grad(1,1,3), &
250 u%x(1,1,1,e), coef,e,e)
251 call opr_cpu_opgrad(grad(1,2,1), grad(1,2,2), grad(1,2,3), &
252 v%x(1,1,1,e), coef,e,e)
253 call opr_cpu_opgrad(grad(1,3,1), grad(1,3,2), grad(1,3,3), &
254 w%x(1,1,1,e), coef,e,e)
256 do i = 1, coef%Xh%lxyz
262 s12 = 0.5_xp*(grad(i,1,2) + grad(i,2,1))
263 s13 = 0.5_xp*(grad(i,1,3) + grad(i,3,1))
264 s23 = 0.5_xp*(grad(i,2,3) + grad(i,3,2))
266 o12 = 0.5_xp*(grad(i,1,2) - grad(i,2,1))
267 o13 = 0.5_xp*(grad(i,1,3) - grad(i,3,1))
268 o23 = 0.5_xp*(grad(i,2,3) - grad(i,3,2))
270 a11 = s11*s11 + s12*s12 + s13*s13 - o12*o12 - o13*o13
271 a12 = s11 * s12 + s12 * s22 + s13 * s23 - o13 * o23
272 a13 = s11 * s13 + s12 * s23 + s13 * s33 + o12 * o23
274 a22 = s12*s12 + s22*s22 + s23*s23 - o12*o12 - o23*o23
275 a23 = s12 * s13 + s22 * s23 + s23 * s33 - o12 * o13
276 a33 = s13*s13 + s23*s23 + s33*s33 - o13*o13 - o23*o23
279 b = -(a11 + a22 + a33)
280 c = -(a12*a12 + a13*a13 + a23*a23 &
281 - a11 * a22 - a11 * a33 - a22 * a33)
282 d = -(2.0_xp * a12 * a13 * a23 - a11 * a23*a23 &
283 - a22 * a13*a13 - a33 * a12*a12 + a11 * a22 * a33)
286 q = (3.0_xp * c - b*b) / 9.0_xp
287 r = (9.0_xp * c * b - 27.0_xp * d - 2.0_xp * b*b*b) / 54.0_xp
288 theta = acos( r / sqrt(-q*q*q) )
290 eigen(1) = 2.0_xp * sqrt(-q) * cos(theta / 3.0_xp) - b / 3.0_xp
291 eigen(2) = 2.0_xp * sqrt(-q) * &
292 cos((theta + 2.0_xp *
pi) / 3.0_xp) - b / 3.0_xp
293 eigen(3) = 2.0_xp * sqrt(-q) * &
294 cos((theta + 4.0_xp *
pi) / 3.0_xp) - b / 3.0_xp
295 msk1 = merge(1.0_rp, 0.0_rp, eigen(2) .le. eigen(1) &
296 .and. eigen(1) .le. eigen(3) .or. eigen(3) &
297 .le. eigen(1) .and. eigen(1) .le. eigen(2) )
298 msk2 = merge(1.0_rp, 0.0_rp, eigen(1) .le. eigen(2) &
299 .and. eigen(2) .le. eigen(3) .or. eigen(3) &
300 .le. eigen(2) .and. eigen(2) .le. eigen(1))
301 msk3 = merge(1.0_rp, 0.0_rp, eigen(1) .le. eigen(3) &
302 .and. eigen(3) .le. eigen(2) .or. eigen(2) &
303 .le. eigen(3) .and. eigen(3) .le. eigen(1))
305 l2 = msk1 * eigen(1) + msk2 * eigen(2) + msk3 * eigen(3)
310 end subroutine opr_cpu_lambda2
312 subroutine opr_cpu_rotate_cyc_r1(vx, vy, vz, idir, coef)
313 real(kind=
rp),
dimension(:),
intent(inout) :: vx, vy, vz
314 integer,
intent(in) :: idir
315 type(
coef_t),
intent(in) :: coef
316 integer :: i, j, ncyc
317 real(kind=
rp) :: vnor, vtan
319 ncyc = coef%cyc_msk(0) - 1
324 if (idir .eq. 1)
then
325 vnor = vx(j) * coef%R11(i) + vy(j) * coef%R12(i)
326 vtan = -vx(j) * coef%R12(i) + vy(j) * coef%R11(i)
327 else if (idir .eq. 0)
then
328 vnor = vx(j) * coef%R11(i) - vy(j) * coef%R12(i)
329 vtan = vx(j) * coef%R12(i) + vy(j) * coef%R11(i)
336 end subroutine opr_cpu_rotate_cyc_r1
339 subroutine opr_cpu_rotate_cyc_r4(vx, vy, vz, idir, coef)
340 real(kind=
rp),
dimension(:,:,:,:),
intent(inout) :: vx, vy, vz
341 integer,
intent(in) :: idir
342 type(
coef_t),
intent(in) :: coef
343 integer :: i, j, ncyc
344 real(kind=
rp) :: vnor, vtan
346 ncyc = coef%cyc_msk(0) - 1
351 if (idir .eq. 1)
then
352 vnor = vx(j, 1, 1, 1) * coef%R11(i) + vy(j, 1, 1, 1) * coef%R12(i)
353 vtan = -vx(j, 1, 1, 1) * coef%R12(i) + vy(j, 1, 1, 1) * coef%R11(i)
354 else if (idir .eq. 0)
then
355 vnor = vx(j, 1, 1, 1) * coef%R11(i) - vy(j, 1, 1, 1) * coef%R12(i)
356 vtan = vx(j, 1, 1, 1) * coef%R12(i) + vy(j, 1, 1, 1) * coef%R11(i)
359 vx(j, 1, 1, 1) = vnor
360 vy(j, 1, 1, 1) = vtan
364 end subroutine opr_cpu_rotate_cyc_r4
Routines to interpolate between different spaces.
A simulation component that computes lambda2 The values are stored in the field registry under the na...
real(kind=rp), parameter, public pi
subroutine, public sub3(a, b, c, n)
Vector subtraction .
subroutine, public copy(a, b, n)
Copy a vector .
subroutine, public rzero(a, n)
Zero a real vector.
Collection of vector field operations operating on and . Note that in general the indices and ....
subroutine, public opcolv(a1, a2, a3, c, gdim, n)
integer, parameter, public xp
integer, parameter, public dp
integer, parameter, public rp
Global precision used in computations.
subroutine, public opr_cpu_curl(w1, w2, w3, u1, u2, u3, work1, work2, c_xh)
subroutine, public opr_cpu_rotate_cyc_r1(vx, vy, vz, idir, coef)
real(kind=rp) function, public opr_cpu_cfl(dt, u, v, w, xh, coef, nelv, gdim)
subroutine, public opr_cpu_lambda2(lambda2, u, v, w, coef)
subroutine, public opr_cpu_rotate_cyc_r4(vx, vy, vz, idir, coef)
Defines a function space.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Interpolation between two space::space_t.
The function space for the SEM solution fields.