Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
adv_oifs.f90
Go to the documentation of this file.
1! Copyright (c) 2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use advection, only : advection_t
36 use num_types, only : rp
37 use space, only : space_t, gl
38 use field, only : field_t
39 use coefs, only : coef_t
40 use math, only : copy, rzero
46 use field_list, only : field_list_t
48 use device, only : device_map, device_free
50 use, intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr, c_associated
51 implicit none
52 private
53
54 !! Type encapsulating operator-integration-factor splitting advection
55 !! routines with dealiasing applied
56 !! Literature:
57 !! https://www.mcs.anl.gov/~fischer/nek5000/oifs.pdf
58 !! https://publications.anl.gov/anlpubs/2017/12/140626.pdf
59 !! https://dl.acm.org/doi/abs/10.1007/BF01063118
60 type, public, extends(advection_t) :: adv_oifs_t
62 integer :: ntaubd
64 type(coef_t) :: coef_gl
66 type(coef_t), pointer :: coef_gll => null()
68 type(interpolator_t) :: gll_to_gl
70 type(space_t) :: xh_gl
72 type(space_t), pointer :: xh_gll => null()
74 type(time_interpolator_t) :: dtime
76 type(field_series_t), pointer :: ulag, vlag, wlag, slag => null()
78 real(kind=rp), pointer :: ctlag(:) => null()
80 real(kind=rp), pointer :: dctlag(:) => null()
82 type(time_scheme_controller_t), pointer :: oifs_scheme => null()
84 type(field_t) :: cr_gl, cs_gl, ct_gl
86 type(field_series_t) :: convr_gl, convs_gl, convt_gl
88 type(field_t), pointer :: cr_k1, cs_k1, ct_k1
89 type(field_t), pointer :: cr_k23, cs_k23, ct_k23
90 type(field_t), pointer :: cr_k4, cs_k4, ct_k4
92 type(field_list_t) :: conv_k1, conv_k23, conv_k4
94 real(kind=rp), allocatable :: cx(:), cy(:), cz(:)
96 type(c_ptr) :: cx_d = c_null_ptr, cy_d = c_null_ptr, cz_d = c_null_ptr
97
98 contains
101 procedure, pass(this) :: compute => adv_oifs_compute
104 procedure, pass(this) :: compute_scalar => adv_oifs_compute_scalar
106 procedure, pass(this) :: init => adv_oifs_init
108 procedure, pass(this) :: set_conv_velocity_fst
110 procedure, pass(this) :: free => adv_oifs_free
113 procedure, pass(this) :: compute_ale => adv_oifs_compute_ale
115 procedure, pass(this) :: recompute_metrics => recompute_metrics_oifs
116 end type adv_oifs_t
117
118contains
119
131 subroutine adv_oifs_init(this, lxd, coef, ctarget, ulag, vlag, wlag, &
132 dtlag, tlag, time_scheme, slag)
133 implicit none
134 class(adv_oifs_t) :: this
135 integer, intent(in) :: lxd
136 type(coef_t), target :: coef
137 real(kind=rp), intent(in) :: ctarget
138 type(field_series_t), target, intent(in) :: ulag, vlag, wlag
139 real(kind=rp), target, intent(in) :: dtlag(10)
140 real(kind=rp), target, intent(in) :: tlag(10)
141 type(time_scheme_controller_t), target, intent(in) :: time_scheme
142 type(field_series_t), target, optional :: slag
143 integer :: nel, n_GL, n, idx, idy, idz
144 real(kind=rp) :: max_cfl_rk4
145
146 ! stability limit for RK4 including safety factor
147 max_cfl_rk4 = 2.0
148 this%ntaubd = max(int(ctarget/max_cfl_rk4),1)
149
150 call this%Xh_GL%init(gl, lxd, lxd, lxd)
151 this%Xh_GLL => coef%Xh
152 this%coef_GLL => coef
153 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
154
155 call this%coef_GL%init(this%Xh_GL, coef%msh)
156
157 call this%cr_GL%init(coef%msh, this%Xh_GL)
158 call this%cs_GL%init(coef%msh, this%Xh_GL)
159 call this%ct_GL%init(coef%msh, this%Xh_GL)
160
161 nel = coef%msh%nelv
162 n_gl = nel*this%Xh_GL%lxyz
163 n = nel*coef%Xh%lxyz
164
165 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
166 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
167 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
168 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
169 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
170 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
171 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
172 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
173 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
174
175
176 allocate(this%cx(n_gl))
177 allocate(this%cy(n_gl))
178 allocate(this%cz(n_gl))
179
180 allocate(this%cr_k1)
181 allocate(this%cs_k1)
182 allocate(this%ct_k1)
183 allocate(this%cr_k23)
184 allocate(this%cs_k23)
185 allocate(this%ct_k23)
186 allocate(this%cr_k4)
187 allocate(this%cs_k4)
188 allocate(this%ct_k4)
189
190
191 call this%cr_k1%init(coef%msh, this%Xh_GL)
192 call this%cs_k1%init(coef%msh, this%Xh_GL)
193 call this%ct_k1%init(coef%msh, this%Xh_GL)
194
195 call this%cr_k23%init(coef%msh, this%Xh_GL)
196 call this%cs_k23%init(coef%msh, this%Xh_GL)
197 call this%ct_k23%init(coef%msh, this%Xh_GL)
198
199 call this%cr_k4%init(coef%msh, this%Xh_GL)
200 call this%cs_k4%init(coef%msh, this%Xh_GL)
201 call this%ct_k4%init(coef%msh, this%Xh_GL)
202
203 call this%conv_k1%init(3)
204 call this%conv_k23%init(3)
205 call this%conv_k4%init(3)
206
207 call this%conv_k1%assign(1, this%cr_k1)
208 call this%conv_k1%assign(2, this%cs_k1)
209 call this%conv_k1%assign(3, this%ct_k1)
210
211 call this%conv_k23%assign(1, this%cr_k23)
212 call this%conv_k23%assign(2, this%cs_k23)
213 call this%conv_k23%assign(3, this%ct_k23)
214
215 call this%conv_k4%assign(1, this%cr_k4)
216 call this%conv_k4%assign(2, this%cs_k4)
217 call this%conv_k4%assign(3, this%ct_k4)
218
219 call this%dtime%init(1)
220 this%ulag => ulag
221 this%vlag => vlag
222 this%wlag => wlag
223 this%ctlag => tlag
224 this%dctlag => dtlag
225 this%oifs_scheme => time_scheme
226
227 if (neko_bcknd_device .eq. 1) then
228 call device_map(this%cx, this%cx_d, n_gl)
229 call device_map(this%cy, this%cy_d, n_gl)
230 call device_map(this%cz, this%cz_d, n_gl)
231 end if
232
233 ! Initializing the convecting fields
234 ! Map the velocity fields from GLL space to GL space
235 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
236 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
237 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
238
239 ! Set the convecting field in the rst format
240 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
241 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
242
243 ! Set the convecting field series
244 call this%convr_GL%init(this%cr_GL, 3)
245 call this%convs_GL%init(this%cs_GL, 3)
246 call this%convt_GL%init(this%ct_GL, 3)
247
248 ! Repeat for previous time-steps
249 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
250 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
251 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
252
253 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
254 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
255
256 this%convr_GL%lf(1) = this%cr_GL
257 this%convs_GL%lf(1) = this%cs_GL
258 this%convt_GL%lf(1) = this%ct_GL
259
260 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
261 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
262 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
263
264 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
265 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
266
267 this%convr_GL%lf(2) = this%cr_GL
268 this%convs_GL%lf(2) = this%cs_GL
269 this%convt_GL%lf(2) = this%ct_GL
270
271 ! Initilize the lagged scalar field, if present.
272 if (present(slag)) then
273 this%slag => slag
274 end if
275
276 end subroutine adv_oifs_init
277
279 subroutine adv_oifs_free(this)
280 class(adv_oifs_t), intent(inout) :: this
281
282 call this%coef_GL%free()
283
284 nullify(this%coef_GLL)
285
286 call this%GLL_to_GL%free()
287
288 call this%Xh_GL%free()
289
290 nullify(this%Xh_GLL)
291
292 call this%dtime%free()
293
294 call this%cr_GL%free()
295 call this%cs_GL%free()
296 call this%ct_GL%free()
297
298 call this%convr_GL%free()
299 call this%convs_GL%free()
300 call this%convt_GL%free()
301
302 call this%conv_k1%free()
303 call this%conv_k23%free()
304 call this%conv_k4%free()
305
306 if (associated(this%cr_k1)) then
307 deallocate(this%cr_k1)
308 end if
309 if (associated(this%cs_k1)) then
310 deallocate(this%cs_k1)
311 end if
312 if (associated(this%ct_k1)) then
313 deallocate(this%ct_k1)
314 end if
315 if (associated(this%cr_k23)) then
316 deallocate(this%cr_k23)
317 end if
318 if (associated(this%cs_k23)) then
319 deallocate(this%cs_k23)
320 end if
321 if (associated(this%ct_k23)) then
322 deallocate(this%ct_k23)
323 end if
324 if (associated(this%cr_k4)) then
325 deallocate(this%cr_k4)
326 end if
327 if (associated(this%cs_k4)) then
328 deallocate(this%cs_k4)
329 end if
330 if (associated(this%ct_k4)) then
331 deallocate(this%ct_k4)
332 end if
333
334 nullify(this%ulag)
335 nullify(this%vlag)
336 nullify(this%wlag)
337 nullify(this%slag)
338 nullify(this%ctlag)
339 nullify(this%dctlag)
340 nullify(this%oifs_scheme)
341 nullify(this%cr_k1)
342 nullify(this%cs_k1)
343 nullify(this%ct_k1)
344 nullify(this%cr_k23)
345 nullify(this%cs_k23)
346 nullify(this%ct_k23)
347 nullify(this%cr_k4)
348 nullify(this%cs_k4)
349 nullify(this%ct_k4)
350
351 if (allocated(this%cx)) then
352 deallocate(this%cx)
353 end if
354 if (allocated(this%cy)) then
355 deallocate(this%cy)
356 end if
357 if (allocated(this%cz)) then
358 deallocate(this%cz)
359 end if
360 if (c_associated(this%cx_d)) then
361 call device_free(this%cx_d)
362 end if
363 if (c_associated(this%cy_d)) then
364 call device_free(this%cy_d)
365 end if
366 if (c_associated(this%cz_d)) then
367 call device_free(this%cz_d)
368 end if
369
370 end subroutine adv_oifs_free
371
377 subroutine set_conv_velocity_fst(this, u, v, w)
378 implicit none
379 class(adv_oifs_t), intent(inout) :: this
380 type(field_t), intent(inout) :: u, v, w
381 integer :: i, nel, n_GL, idx, idy, idz
382
383 nel = this%coef_GLL%msh%nelv
384 n_gl = nel*this%Xh_GL%lxyz
385
386 call this%convr_GL%update()
387 call this%convs_GL%update()
388 call this%convt_GL%update()
389
390 call this%GLL_to_GL%map(this%cx, u%x, nel, this%Xh_GL)
391 call this%GLL_to_GL%map(this%cy, v%x, nel, this%Xh_GL)
392 call this%GLL_to_GL%map(this%cz, w%x, nel, this%Xh_GL)
393
394 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
395 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
396
397 this%convr_GL%f = this%cr_GL
398 this%convs_GL%f = this%cs_GL
399 this%convt_GL%f = this%ct_GL
400
401 end subroutine set_conv_velocity_fst
402
403
416 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
417 implicit none
418 class(adv_oifs_t), intent(inout) :: this
419 type(field_t), intent(inout) :: vx, vy, vz
420 type(field_t), intent(inout) :: fx, fy, fz
421 type(space_t), intent(in) :: Xh
422 type(coef_t), intent(in) :: coef
423 integer, intent(in) :: n
424 real(kind=rp), intent(in), optional :: dt
425 real(kind=rp) :: tau, tau1, th, dtau
426 integer :: i, ilag, itau, nel, n_GL
427
428 nel = coef%msh%nelv
429 n_gl = nel * this%Xh_GL%lxyz
430
431 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
432 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
433 xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
434 gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
435 cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
436 cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
437 cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
438 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
439 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
440 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
441
442 call dtime%init(oifs_scheme%ndiff)
443
444 tau = ctlag(oifs_scheme%ndiff)
445
446 call this%set_conv_velocity_fst(vx, vy, vz)
447
448 if (neko_bcknd_device .eq. 1) then
449 call device_rzero(fx%x_d,n)
450 call device_rzero(fy%x_d,n)
451 call device_rzero(fz%x_d,n)
452 else
453 call rzero(fx%x,n)
454 call rzero(fy%x,n)
455 call rzero(fz%x,n)
456 end if
457
458 do ilag = oifs_scheme%ndiff, 1, -1
459 if (neko_bcknd_device .eq. 1) then
460 if (ilag .eq. 1) then
461 call device_addcol3s2(fx%x_d, vx%x_d, coef%B_d, &
462 oifs_scheme%diffusion_coeffs%x(2), n)
463 call device_addcol3s2(fy%x_d, vy%x_d, coef%B_d, &
464 oifs_scheme%diffusion_coeffs%x(2), n)
465 call device_addcol3s2(fz%x_d, vz%x_d, coef%B_d, &
466 oifs_scheme%diffusion_coeffs%x(2), n)
467 else
468 call device_addcol3s2(fx%x_d, ulag%lf(ilag-1)%x_d, coef%B_d, &
469 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
470 call device_addcol3s2(fy%x_d, vlag%lf(ilag-1)%x_d, coef%B_d, &
471 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
472 call device_addcol3s2(fz%x_d, wlag%lf(ilag-1)%x_d, coef%B_d, &
473 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
474 end if
475 else
476 if (ilag .eq. 1) then
477 do i = 1, n
478 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
479 oifs_scheme%diffusion_coeffs%x(2) &
480 * vx%x(i,1,1,1) * coef%B(i,1,1,1)
481 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
482 oifs_scheme%diffusion_coeffs%x(2) &
483 * vy%x(i,1,1,1) * coef%B(i,1,1,1)
484 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
485 oifs_scheme%diffusion_coeffs%x(2) &
486 * vz%x(i,1,1,1) * coef%B(i,1,1,1)
487 end do
488 else
489 do i = 1, n
490 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
491 oifs_scheme%diffusion_coeffs%x(ilag+1) &
492 * ulag%lf(ilag-1)%x(i,1,1,1) &
493 * coef%B(i,1,1,1)
494 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
495 oifs_scheme%diffusion_coeffs%x(ilag+1) &
496 * vlag%lf(ilag-1)%x(i,1,1,1) &
497 * coef%B(i,1,1,1)
498 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
499 oifs_scheme%diffusion_coeffs%x(ilag+1) &
500 * wlag%lf(ilag-1)%x(i,1,1,1) &
501 * coef%B(i,1,1,1)
502 end do
503 end if
504 end if
505 dtau = dctlag(ilag)/real(ntaubd)
506 do itau = 1, ntaubd
507 th = tau + dtau/2.
508 tau1 = tau + dtau
509 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
510 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
511 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
512 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
513 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
514 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
515 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
516 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
517 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
518 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
519 coef, coef_gl, gll_to_gl, tau, dtau, &
520 n, nel, n_gl)
521 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
522 coef, coef_gl, gll_to_gl, tau, dtau, &
523 n, nel, n_gl)
524 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
525 coef, coef_gl, gll_to_gl, tau, dtau, &
526 n, nel, n_gl)
527 tau = tau1
528 end do
529 end do
530
531 end associate
532
533 end subroutine adv_oifs_compute
546 subroutine adv_oifs_compute_scalar(this, vx, vy, vz, s, fs, Xh, coef, n, dt)
547 implicit none
548 class(adv_oifs_t), intent(inout) :: this
549 type(field_t), intent(inout) :: vx, vy, vz
550 type(field_t), intent(inout) :: fs
551 type(field_t), intent(inout) :: s
552 type(space_t), intent(in) :: Xh
553 type(coef_t), intent(in) :: coef
554 integer, intent(in) :: n
555 real(kind=rp), intent(in), optional :: dt
556 real(kind=rp) :: tau, tau1, th, dtau
557 integer :: i, ilag, itau, nel, n_GL
558 nel = coef%msh%nelv
559 n_gl = nel * this%Xh_GL%lxyz
560
561 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
562 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
563 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
564 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
565 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
566 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
567 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
568 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
569 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
570 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
571
572 call dtime%init(oifs_scheme%ndiff)
573
574 tau = ctlag(oifs_scheme%ndiff)
575
576 call this%set_conv_velocity_fst(vx, vy, vz)
577
578 if (neko_bcknd_device .eq. 1) then
579 call device_rzero(fs%x_d,n)
580 else
581 call rzero(fs%x,n)
582 end if
583
584 do ilag = oifs_scheme%ndiff, 1, -1
585 if (neko_bcknd_device .eq. 1) then
586 if (ilag .eq. 1) then
587 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
588 oifs_scheme%diffusion_coeffs%x(2), n)
589 else
590 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
591 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
592 end if
593 else
594 if (ilag .eq. 1) then
595 do i = 1, n
596 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
597 oifs_scheme%diffusion_coeffs%x(2) &
598 * s%x(i,1,1,1) * coef%B(i,1,1,1)
599 end do
600 else
601 do i = 1, n
602 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
603 oifs_scheme%diffusion_coeffs%x(ilag+1) &
604 * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
605 end do
606 end if
607 end if
608 dtau = dctlag(ilag)/real(ntaubd)
609 do itau = 1, ntaubd
610 th = tau + dtau/2.
611 tau1 = tau + dtau
612 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
613 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
614 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
615 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
616 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
617 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
618 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
619 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
620 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
621 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
622 coef, coef_gl, gll_to_gl, tau, dtau, &
623 n, nel, n_gl)
624 tau = tau1
625 end do
626 end do
627
628 end associate
629
630 end subroutine adv_oifs_compute_scalar
631 subroutine recompute_metrics_oifs(this, coef, moving_boundary)
632 class(adv_oifs_t), intent(inout) :: this
633 type(coef_t), intent(in) :: coef
634 logical, intent(in) :: moving_boundary
635 ! no-op
636 end subroutine recompute_metrics_oifs
637
638
639 subroutine adv_oifs_compute_ale(this, vx, vy, vz, wm_x, wm_y, wm_z, &
640 fx, fy, fz, Xh, coef, n, dt)
641 class(adv_oifs_t), intent(inout) :: this
642 type(field_t), intent(inout) :: vx, vy, vz
643 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
644 type(field_t), intent(inout) :: fx, fy, fz
645 type(space_t), intent(in) :: Xh
646 type(coef_t), intent(in) :: coef
647 integer, intent(in) :: n
648 real(kind=rp), intent(in), optional :: dt
649 ! no-op
650 end subroutine adv_oifs_compute_ale
651end module adv_oifs
double real
Map a Fortran array to a device (allocate and associate)
Definition device.F90:77
Subroutines to add advection terms to the RHS of a transport equation.
Definition adv_oifs.f90:34
subroutine adv_oifs_compute_scalar(this, vx, vy, vz, s, fs, xh, coef, n, dt)
Add the advection term for a scalar, i.e. , to the RHS.
Definition adv_oifs.f90:547
subroutine adv_oifs_compute_ale(this, vx, vy, vz, wm_x, wm_y, wm_z, fx, fy, fz, xh, coef, n, dt)
Definition adv_oifs.f90:641
subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, xh, coef, n, dt)
Add the advection term for the fluid, i.e. , to the RHS using the OIFS method.
Definition adv_oifs.f90:417
subroutine recompute_metrics_oifs(this, coef, moving_boundary)
Definition adv_oifs.f90:632
subroutine set_conv_velocity_fst(this, u, v, w)
Mapping the velocity fields to GL space and transforming them to the rst format.
Definition adv_oifs.f90:378
subroutine adv_oifs_init(this, lxd, coef, ctarget, ulag, vlag, wlag, dtlag, tlag, time_scheme, slag)
Constructor.
Definition adv_oifs.f90:133
subroutine adv_oifs_free(this)
Destructor.
Definition adv_oifs.f90:280
Subroutines to add advection terms to the RHS of a transport equation.
Definition advection.f90:34
Coefficients.
Definition coef.f90:34
subroutine, public device_rzero(a_d, n, strm)
Zero a real vector.
subroutine, public device_addcol3s2(a_d, b_d, c_d, s, n, strm)
Returns .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
subroutine, public device_free(x_d)
Deallocate memory on the device.
Definition device.F90:225
Contains the field_serties_t type.
Defines a field.
Definition field.f90:34
Routines to interpolate between different spaces.
Definition math.f90:60
subroutine, public copy(a, b, n)
Copy a vector .
Definition math.f90:250
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.f90:206
Build configurations.
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_xsmm
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
subroutine, public set_convect_rst(cr, cs, ct, cx, cy, cz, xh, coef)
Transforms the convecting velocity field to the rst form of the GL space.
subroutine, public runge_kutta(phi, conv_k1, conv_k23, conv_k4, xh_gll, xh_gl, coef, coef_gl, gll_to_gl, tau, dtau, n, nel, n_gl)
Compute one step of Runge Kutta time interpolation for OIFS scheme.
Defines a function space.
Definition space.f90:34
integer, parameter, public gl
Definition space.f90:49
Implements type time_interpolator_t.
Compound scheme for the advection and diffusion operators in a transport equation.
Base class for time integration schemes.
Base abstract type for computing the advection operator.
Definition advection.f90:46
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:62
field_list_t, To be able to group fields together
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
Interpolation between two space::space_t.
The function space for the SEM solution fields.
Definition space.f90:63
Provides a tool to perform interpolation in time.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
#define max(a, b)
Definition tensor.cu:40