Neko 1.99.11
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!
33!> Subroutines to add advection terms to the RHS of a transport equation.
35 use advection, only : advection_t
36 use num_types, only : rp, dp
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, addcol3s2
46 use field_list, only : field_list_t
48 use device, only : device_map, device_unmap
50 use, intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
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
61 !> Number of RK4 sub-steps
62 integer :: ntaubd = 0
63 !> Coeffs of the higher-order space
64 type(coef_t) :: coef_gl
65 !> Coeffs of the original space in the simulation
66 type(coef_t), pointer :: coef_gll => null()
67 !> Interpolator between the original and higher-order spaces
68 type(interpolator_t) :: gll_to_gl
69 !> The additional higher-order space used in dealiasing
70 type(space_t) :: xh_gl
71 !> The original space used in the simulation
72 type(space_t), pointer :: xh_gll => null()
73 !> The time interpolator scheme
74 type(time_interpolator_t) :: dtime
75 !> The lagged velocity and scalar fields
76 type(field_series_t), pointer :: ulag, vlag, wlag, slag => null()
77 !> The times corresponding to the lagged fields
78 real(kind=dp), pointer :: ctlag(:) => null()
79 !> The time-steps corresponding to the lagged fields
80 real(kind=dp), pointer :: dctlag(:) => null()
81 !> The time scheme controller for the oifs scheme
82 type(time_scheme_controller_t), pointer :: oifs_scheme => null()
83 !> The current convecting field in GL space and rst format
84 type(field_t) :: cr_gl, cs_gl, ct_gl
85 !> The convecting field series in GL space and rst format
86 type(field_series_t) :: convr_gl, convs_gl, convt_gl
87 !> The time interpolated convecting field used in Runge_Kutta method
88 type(field_t), pointer :: cr_k1 => null(), cs_k1 => null(), &
89 ct_k1 => null()
90 type(field_t), pointer :: cr_k23 => null(), cs_k23 => null(), &
91 ct_k23 => null()
92 type(field_t), pointer :: cr_k4 => null(), cs_k4 => null(), &
93 ct_k4 => null()
94 !> The field_list containing the time interpolated convecting field
95 type(field_list_t) :: conv_k1, conv_k23, conv_k4
96 !> The convecting velocity field in GL space
97 real(kind=rp), allocatable :: cx(:), cy(:), cz(:)
98 !> Device pointers for cx, cy, cz
99 type(c_ptr) :: cx_d = c_null_ptr, cy_d = c_null_ptr, cz_d = c_null_ptr
100
101 contains
102 !> Add the advection term for the fluid, i.e. \f$u \cdot \nabla u \f$, to
103 !! the RHS
104 procedure, pass(this) :: compute => adv_oifs_compute
105 !> Add the advection term for a scalar, i.e. \f$u \cdot \nabla s \f$, to
106 !! the RHS
107 procedure, pass(this) :: compute_scalar => adv_oifs_compute_scalar
108 !> Constructor
109 procedure, pass(this) :: init => adv_oifs_init
110 !> setting characteristic convecting field
111 procedure, pass(this) :: set_conv_velocity_fst
112 !> Rebuild the convecting field series after a restart
113 procedure, pass(this) :: restart => adv_oifs_restart
114 !> Destructor
115 procedure, pass(this) :: free => adv_oifs_free
116 !> add the advection term for ALE, i.e. \f$(u - w_m) \cdot \nabla s \f$, to
117 !> the RHS
118 procedure, pass(this) :: compute_ale => adv_oifs_compute_ale
119 !> Update any metrics needed for the advection computation in ALE.
120 procedure, pass(this) :: recompute_metrics => recompute_metrics_oifs
121 end type adv_oifs_t
122
123contains
124
125 !> Constructor
126 !! @param lxd The polynomial order of the space used in the dealiasing.
127 !! @param coef The coefficients of the (space, mesh) pair.
128 !! @param ctarget Target CFL number.
129 !! @param ulag The x component of lagged velocity.
130 !! @param vlag The y component of lagged velocity.
131 !! @param wlag The z component of lagged velocity.
132 !! @param dtlag Lagged time steps.
133 !! @param tlag Lagged simulation times.
134 !! @param time_scheme The bdf-ext time scheme used in the method.
135 !! @param slag The lagged scalar field.
136 subroutine adv_oifs_init(this, lxd, coef, ctarget, ulag, vlag, wlag, &
137 dtlag, tlag, time_scheme, slag)
138 implicit none
139 class(adv_oifs_t), intent(inout) :: this
140 integer, intent(in) :: lxd
141 type(coef_t), target :: coef
142 real(kind=rp), intent(in) :: ctarget
143 type(field_series_t), target, intent(in) :: ulag, vlag, wlag
144 real(kind=dp), target, intent(in) :: dtlag(10)
145 real(kind=dp), target, intent(in) :: tlag(10)
146 type(time_scheme_controller_t), target, intent(in) :: time_scheme
147 type(field_series_t), target, optional :: slag
148 integer :: nel, n_GL, n, idx, idy, idz
149 real(kind=rp) :: max_cfl_rk4
150
151 call this%free()
152
153 ! stability limit for RK4 including safety factor
154 max_cfl_rk4 = 2.0
155 this%ntaubd = max(int(ctarget/max_cfl_rk4),1)
156
157 call this%Xh_GL%init(gl, lxd, lxd, lxd)
158 this%Xh_GLL => coef%Xh
159 this%coef_GLL => coef
160 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
161
162 call this%coef_GL%init(this%Xh_GL, coef%msh)
163
164 call this%cr_GL%init(coef%msh, this%Xh_GL)
165 call this%cs_GL%init(coef%msh, this%Xh_GL)
166 call this%ct_GL%init(coef%msh, this%Xh_GL)
167
168 nel = coef%msh%nelv
169 n_gl = nel*this%Xh_GL%lxyz
170 n = nel*coef%Xh%lxyz
171
172 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
173 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
174 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
175 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
176 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
177 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
178 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
179 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
180 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
181
182
183 allocate(this%cx(n_gl))
184 allocate(this%cy(n_gl))
185 allocate(this%cz(n_gl))
186
187 allocate(this%cr_k1)
188 allocate(this%cs_k1)
189 allocate(this%ct_k1)
190 allocate(this%cr_k23)
191 allocate(this%cs_k23)
192 allocate(this%ct_k23)
193 allocate(this%cr_k4)
194 allocate(this%cs_k4)
195 allocate(this%ct_k4)
196
197
198 call this%cr_k1%init(coef%msh, this%Xh_GL)
199 call this%cs_k1%init(coef%msh, this%Xh_GL)
200 call this%ct_k1%init(coef%msh, this%Xh_GL)
201
202 call this%cr_k23%init(coef%msh, this%Xh_GL)
203 call this%cs_k23%init(coef%msh, this%Xh_GL)
204 call this%ct_k23%init(coef%msh, this%Xh_GL)
205
206 call this%cr_k4%init(coef%msh, this%Xh_GL)
207 call this%cs_k4%init(coef%msh, this%Xh_GL)
208 call this%ct_k4%init(coef%msh, this%Xh_GL)
209
210 call this%conv_k1%init(3)
211 call this%conv_k23%init(3)
212 call this%conv_k4%init(3)
213
214 call this%conv_k1%assign(1, this%cr_k1)
215 call this%conv_k1%assign(2, this%cs_k1)
216 call this%conv_k1%assign(3, this%ct_k1)
217
218 call this%conv_k23%assign(1, this%cr_k23)
219 call this%conv_k23%assign(2, this%cs_k23)
220 call this%conv_k23%assign(3, this%ct_k23)
221
222 call this%conv_k4%assign(1, this%cr_k4)
223 call this%conv_k4%assign(2, this%cs_k4)
224 call this%conv_k4%assign(3, this%ct_k4)
225
226 call this%dtime%init(1)
227 this%ulag => ulag
228 this%vlag => vlag
229 this%wlag => wlag
230 this%ctlag => tlag
231 this%dctlag => dtlag
232 this%oifs_scheme => time_scheme
233
234 if (neko_bcknd_device .eq. 1) then
235 call device_map(this%cx, this%cx_d, n_gl)
236 call device_map(this%cy, this%cy_d, n_gl)
237 call device_map(this%cz, this%cz_d, n_gl)
238 end if
239
240 ! Initializing the convecting fields
241 ! Map the velocity fields from GLL space to GL space
242 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
243 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
244 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
245
246 ! Set the convecting field in the rst format
247 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
248 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
249
250 ! Set the convecting field series
251 call this%convr_GL%init(this%cr_GL, 3)
252 call this%convs_GL%init(this%cs_GL, 3)
253 call this%convt_GL%init(this%ct_GL, 3)
254
255 ! Repeat for previous time-steps
256 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
257 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
258 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
259
260 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
261 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
262
263 this%convr_GL%lf(1) = this%cr_GL
264 this%convs_GL%lf(1) = this%cs_GL
265 this%convt_GL%lf(1) = this%ct_GL
266
267 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
268 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
269 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
270
271 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
272 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
273
274 this%convr_GL%lf(2) = this%cr_GL
275 this%convs_GL%lf(2) = this%cs_GL
276 this%convt_GL%lf(2) = this%ct_GL
277
278 ! Initilize the lagged scalar field, if present.
279 if (present(slag)) then
280 this%slag => slag
281 end if
282
283 end subroutine adv_oifs_init
284
285 !> Destructor
286 subroutine adv_oifs_free(this)
287 class(adv_oifs_t), intent(inout) :: this
288
289 call this%conv_k1%free()
290 call this%conv_k23%free()
291 call this%conv_k4%free()
292
293 if (associated(this%cr_k1)) then
294 call this%cr_k1%free()
295 deallocate(this%cr_k1)
296 end if
297 if (associated(this%cs_k1)) then
298 call this%cs_k1%free()
299 deallocate(this%cs_k1)
300 end if
301 if (associated(this%ct_k1)) then
302 call this%ct_k1%free()
303 deallocate(this%ct_k1)
304 end if
305 if (associated(this%cr_k23)) then
306 call this%cr_k23%free()
307 deallocate(this%cr_k23)
308 end if
309 if (associated(this%cs_k23)) then
310 call this%cs_k23%free()
311 deallocate(this%cs_k23)
312 end if
313 if (associated(this%ct_k23)) then
314 call this%ct_k23%free()
315 deallocate(this%ct_k23)
316 end if
317 if (associated(this%cr_k4)) then
318 call this%cr_k4%free()
319 deallocate(this%cr_k4)
320 end if
321 if (associated(this%cs_k4)) then
322 call this%cs_k4%free()
323 deallocate(this%cs_k4)
324 end if
325 if (associated(this%ct_k4)) then
326 call this%ct_k4%free()
327 deallocate(this%ct_k4)
328 end if
329
330 nullify(this%cr_k1)
331 nullify(this%cs_k1)
332 nullify(this%ct_k1)
333 nullify(this%cr_k23)
334 nullify(this%cs_k23)
335 nullify(this%ct_k23)
336 nullify(this%cr_k4)
337 nullify(this%cs_k4)
338 nullify(this%ct_k4)
339
340 call this%convr_GL%free()
341 call this%convs_GL%free()
342 call this%convt_GL%free()
343
344 call this%cr_GL%free()
345 call this%cs_GL%free()
346 call this%ct_GL%free()
347
348 if (allocated(this%cx)) then
349 if (neko_bcknd_device .eq. 1) then
350 call device_unmap(this%cx, this%cx_d)
351 end if
352 deallocate(this%cx)
353 end if
354 if (allocated(this%cy)) then
355 if (neko_bcknd_device .eq. 1) then
356 call device_unmap(this%cy, this%cy_d)
357 end if
358 deallocate(this%cy)
359 end if
360 if (allocated(this%cz)) then
361 if (neko_bcknd_device .eq. 1) then
362 call device_unmap(this%cz, this%cz_d)
363 end if
364 deallocate(this%cz)
365 end if
366
367 call this%dtime%free()
368 call this%GLL_to_GL%free()
369 call this%coef_GL%free()
370 call this%Xh_GL%free()
371
372 nullify(this%coef_GLL)
373 nullify(this%Xh_GLL)
374 nullify(this%ulag)
375 nullify(this%vlag)
376 nullify(this%wlag)
377 nullify(this%slag)
378 nullify(this%ctlag)
379 nullify(this%dctlag)
380 nullify(this%oifs_scheme)
381
382 this%ntaubd = 0
383
384 end subroutine adv_oifs_free
385
386 !> Mapping the velocity fields to GL space and transforming them to the rst format
387 !! @param u Velocity component in x-direction
388 !! @param v Velocity component in y-direction
389 !! @param w Velocity component in z-direction
390 !! @note similar to set_ct_cvx in NEK5000
391 subroutine set_conv_velocity_fst(this, u, v, w)
392 implicit none
393 class(adv_oifs_t), intent(inout) :: this
394 type(field_t), intent(inout) :: u, v, w
395 integer :: i, nel, n_GL, idx, idy, idz
396
397 nel = this%coef_GLL%msh%nelv
398 n_gl = nel*this%Xh_GL%lxyz
399
400 call this%convr_GL%update()
401 call this%convs_GL%update()
402 call this%convt_GL%update()
403
404 call this%GLL_to_GL%map(this%cx, u%x, nel, this%Xh_GL)
405 call this%GLL_to_GL%map(this%cy, v%x, nel, this%Xh_GL)
406 call this%GLL_to_GL%map(this%cz, w%x, nel, this%Xh_GL)
407
408 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
409 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
410
411 this%convr_GL%f = this%cr_GL
412 this%convs_GL%f = this%cs_GL
413 this%convt_GL%f = this%ct_GL
414
415 end subroutine set_conv_velocity_fst
416
417 !> Rebuild the convecting field series after a restart.
418 !! @details `convr_GL`, `convs_GL` and `convt_GL` are not stored in the
419 !! checkpoint. They are recomputed from the restored lagged velocities,
420 !! first `lf(2)` and then `lf(1)`. The next call to `compute` or
421 !! `compute_scalar` adds the current velocity, as in a run without restart.
422 subroutine adv_oifs_restart(this)
423 class(adv_oifs_t), intent(inout) :: this
424
425 call this%set_conv_velocity_fst(this%ulag%lf(2), this%vlag%lf(2), &
426 this%wlag%lf(2))
427 call this%set_conv_velocity_fst(this%ulag%lf(1), this%vlag%lf(1), &
428 this%wlag%lf(1))
429
430 end subroutine adv_oifs_restart
431
432
433 !> Add the advection term for the fluid, i.e. \f$u \cdot \nabla u \f$, to
434 !! the RHS using the OIFS method.
435 !! @param vx The x component of velocity.
436 !! @param vy The y component of velocity.
437 !! @param vz The z component of velocity.
438 !! @param fx The x component of source term.
439 !! @param fy The y component of source term.
440 !! @param fz The z component of source term.
441 !! @param Xh The function space.
442 !! @param coef The coefficients of the (Xh, mesh) pair.
443 !! @param n Typically the size of the mesh.
444 !! @param dt Current time-step.
445 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
446 implicit none
447 class(adv_oifs_t), intent(inout) :: this
448 type(field_t), intent(inout) :: vx, vy, vz
449 type(field_t), intent(inout) :: fx, fy, fz
450 type(space_t), intent(in) :: Xh
451 type(coef_t), intent(in) :: coef
452 integer, intent(in) :: n
453 real(kind=rp), intent(in), optional :: dt
454 real(kind=dp) :: tau, tau1, th, dtau
455 integer :: ilag, itau, nel, n_GL
456
457 nel = coef%msh%nelv
458 n_gl = nel * this%Xh_GL%lxyz
459
460 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
461 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
462 xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
463 gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
464 cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
465 cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
466 cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
467 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
468 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
469 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
470
471 call dtime%init(oifs_scheme%ndiff)
472
473 tau = ctlag(oifs_scheme%ndiff)
474
475 call this%set_conv_velocity_fst(vx, vy, vz)
476
477 if (neko_bcknd_device .eq. 1) then
478 call device_rzero(fx%x_d,n)
479 call device_rzero(fy%x_d,n)
480 call device_rzero(fz%x_d,n)
481 else
482 call rzero(fx%x,n)
483 call rzero(fy%x,n)
484 call rzero(fz%x,n)
485 end if
486
487 do ilag = oifs_scheme%ndiff, 1, -1
488 if (neko_bcknd_device .eq. 1) then
489 if (ilag .eq. 1) then
490 call device_addcol3s2(fx%x_d, vx%x_d, coef%B_d, &
491 oifs_scheme%diffusion_coeffs%x(2), n)
492 call device_addcol3s2(fy%x_d, vy%x_d, coef%B_d, &
493 oifs_scheme%diffusion_coeffs%x(2), n)
494 call device_addcol3s2(fz%x_d, vz%x_d, coef%B_d, &
495 oifs_scheme%diffusion_coeffs%x(2), n)
496 else
497 call device_addcol3s2(fx%x_d, ulag%lf(ilag-1)%x_d, coef%B_d, &
498 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
499 call device_addcol3s2(fy%x_d, vlag%lf(ilag-1)%x_d, coef%B_d, &
500 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
501 call device_addcol3s2(fz%x_d, wlag%lf(ilag-1)%x_d, coef%B_d, &
502 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
503 end if
504 else
505 if (ilag .eq. 1) then
506 call addcol3s2(fx%x, vx%x, coef%B, &
507 oifs_scheme%diffusion_coeffs%x(2), n)
508 call addcol3s2(fy%x, vy%x, coef%B, &
509 oifs_scheme%diffusion_coeffs%x(2), n)
510 call addcol3s2(fz%x, vz%x, coef%B, &
511 oifs_scheme%diffusion_coeffs%x(2), n)
512 else
513 call addcol3s2(fx%x, ulag%lf(ilag-1)%x, coef%B, &
514 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
515 call addcol3s2(fy%x, vlag%lf(ilag-1)%x, coef%B, &
516 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
517 call addcol3s2(fz%x, wlag%lf(ilag-1)%x, coef%B, &
518 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
519 end if
520 end if
521 dtau = dctlag(ilag)/real(ntaubd)
522 do itau = 1, ntaubd
523 th = tau + dtau/2.
524 tau1 = tau + dtau
525 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
526 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
527 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
528 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
529 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
530 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
531 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
532 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
533 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
534 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
535 coef, coef_gl, gll_to_gl, tau, dtau, &
536 n, nel, n_gl)
537 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
538 coef, coef_gl, gll_to_gl, tau, dtau, &
539 n, nel, n_gl)
540 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
541 coef, coef_gl, gll_to_gl, tau, dtau, &
542 n, nel, n_gl)
543 tau = tau1
544 end do
545 end do
546
547 end associate
548
549 end subroutine adv_oifs_compute
550 !> Add the advection term for a scalar, i.e. \f$u \cdot \nabla s \f$, to the
551 !! RHS.
552 !! @param this The object.
553 !! @param vx The x component of velocity.
554 !! @param vy The y component of velocity.
555 !! @param vz The z component of velocity.
556 !! @param s The scalar.
557 !! @param fs The source term.
558 !! @param Xh The function space.
559 !! @param coef The coefficients of the (Xh, mesh) pair.
560 !! @param n Typically the size of the mesh.
561 !! @param dt Current time-step.
562 subroutine adv_oifs_compute_scalar(this, vx, vy, vz, s, fs, Xh, coef, n, dt)
563 implicit none
564 class(adv_oifs_t), intent(inout) :: this
565 type(field_t), intent(inout) :: vx, vy, vz
566 type(field_t), intent(inout) :: fs
567 type(field_t), intent(inout) :: s
568 type(space_t), intent(in) :: Xh
569 type(coef_t), intent(in) :: coef
570 integer, intent(in) :: n
571 real(kind=rp), intent(in), optional :: dt
572
573 real(kind=dp) :: tau, tau1, th, dtau
574 integer :: ilag, itau, nel, n_GL
575 nel = coef%msh%nelv
576 n_gl = nel * this%Xh_GL%lxyz
577
578 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
579 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
580 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
581 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
582 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
583 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
584 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
585 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
586 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
587 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
588
589 call dtime%init(oifs_scheme%ndiff)
590
591 tau = ctlag(oifs_scheme%ndiff)
592
593 call this%set_conv_velocity_fst(vx, vy, vz)
594
595 if (neko_bcknd_device .eq. 1) then
596 call device_rzero(fs%x_d,n)
597 else
598 call rzero(fs%x,n)
599 end if
600
601 do ilag = oifs_scheme%ndiff, 1, -1
602 if (neko_bcknd_device .eq. 1) then
603 if (ilag .eq. 1) then
604 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
605 oifs_scheme%diffusion_coeffs%x(2), n)
606 else
607 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
608 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
609 end if
610 else
611 if (ilag .eq. 1) then
612 call addcol3s2(fs%x, s%x, coef%B, &
613 oifs_scheme%diffusion_coeffs%x(2), n)
614 else
615 call addcol3s2(fs%x, slag%lf(ilag-1)%x, coef%B, &
616 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
617 end if
618 end if
619 dtau = dctlag(ilag)/real(ntaubd)
620 do itau = 1, ntaubd
621 th = tau + dtau/2.
622 tau1 = tau + dtau
623 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
624 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
625 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
626 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
627 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
628 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
629 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
630 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
631 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
632 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
633 coef, coef_gl, gll_to_gl, tau, dtau, &
634 n, nel, n_gl)
635 tau = tau1
636 end do
637 end do
638
639 end associate
640
641 end subroutine adv_oifs_compute_scalar
642 subroutine recompute_metrics_oifs(this, coef, moving_boundary)
643 class(adv_oifs_t), intent(inout) :: this
644 type(coef_t), intent(in) :: coef
645 logical, intent(in) :: moving_boundary
646 ! no-op
647 end subroutine recompute_metrics_oifs
648
649
650 subroutine adv_oifs_compute_ale(this, vx, vy, vz, wm_x, wm_y, wm_z, &
651 fx, fy, fz, Xh, coef, n, dt)
652 class(adv_oifs_t), intent(inout) :: this
653 type(field_t), intent(inout) :: vx, vy, vz
654 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
655 type(field_t), intent(inout) :: fx, fy, fz
656 type(space_t), intent(in) :: Xh
657 type(coef_t), intent(in) :: coef
658 integer, intent(in) :: n
659 real(kind=rp), intent(in), optional :: dt
660 ! no-op
661 end subroutine adv_oifs_compute_ale
662end module adv_oifs
double real
Map a Fortran array to a device (allocate and associate).
Definition device.F90:83
Unmap a Fortran array from a device (deassociate and free).
Definition device.F90:89
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:563
subroutine adv_oifs_restart(this)
Rebuild the convecting field series after a restart.
Definition adv_oifs.f90:423
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:652
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:446
subroutine recompute_metrics_oifs(this, coef, moving_boundary)
Definition adv_oifs.f90:643
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:392
subroutine adv_oifs_init(this, lxd, coef, ctarget, ulag, vlag, wlag, dtlag, tlag, time_scheme, slag)
Constructor.
Definition adv_oifs.f90:138
subroutine adv_oifs_free(this)
Destructor.
Definition adv_oifs.f90:287
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
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 addcol3s2(a, b, c, s, n)
Returns .
Definition math.F90:1246
subroutine, public copy(a, b, n)
Copy a vector .
Definition math.F90:305
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.F90:249
Build configurations.
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_xsmm
integer, parameter, public dp
Definition num_types.f90:10
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
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:50
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:136
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:64
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