Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
adv_no_dealias.f90
Go to the documentation of this file.
1! Copyright (c) 2021-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 math, only : subcol3, rzero, addcol3
38 use field_math, only : field_col3
39 use space, only : space_t
40 use field, only : field_t
41 use coefs, only : coef_t
44 use operators, only : conv1, div
47 use, intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr, c_associated
48 implicit none
49 private
50
52 type, public, extends(advection_t) :: adv_no_dealias_t
53 contains
55 procedure, pass(this) :: init => init_no_dealias
57 procedure, pass(this) :: free => free_no_dealias
60 procedure, pass(this) :: compute => compute_advection_no_dealias
63 procedure, pass(this) :: compute_scalar => &
67 procedure, pass(this) :: compute_ale => compute_ale_advection_no_dealias
69 procedure, pass(this) :: recompute_metrics => recompute_metrics_no_dealias
70 end type adv_no_dealias_t
71
72contains
73
76 subroutine init_no_dealias(this, coef)
77 class(adv_no_dealias_t), intent(inout) :: this
78 type(coef_t), intent(in) :: coef
79
80 end subroutine init_no_dealias
81
83 subroutine free_no_dealias(this)
84 class(adv_no_dealias_t), intent(inout) :: this
85
86 end subroutine free_no_dealias
87
100 subroutine compute_advection_no_dealias(this, vx, vy, vz, fx, fy, fz, Xh, &
101 coef, n, dt)
102 class(adv_no_dealias_t), intent(inout) :: this
103 type(space_t), intent(in) :: Xh
104 type(coef_t), intent(in) :: coef
105 type(field_t), intent(inout) :: vx, vy, vz
106 type(field_t), intent(inout) :: fx, fy, fz
107 integer, intent(in) :: n
108 real(kind=rp), intent(in), optional :: dt
109
110 type(field_t), pointer :: temp
111 integer :: id_temp
112
113 call neko_scratch_registry%request_field(temp, id_temp, .false.)
114
115 if (neko_bcknd_device .eq. 1) then
116
117 call conv1(temp%x, vx%x, vx%x, vy%x, vz%x, xh, coef)
118 call device_subcol3 (fx%x_d, coef%B_d, temp%x_d, n)
119 call conv1(temp%x, vy%x, vx%x, vy%x, vz%x, xh, coef)
120 call device_subcol3 (fy%x_d, coef%B_d, temp%x_d, n)
121 if (coef%Xh%lz .eq. 1) then
122 call device_rzero (temp%x_d, n)
123 else
124 call conv1(temp%x, vz%x, vx%x, vy%x, vz%x, xh, coef)
125 call device_subcol3(fz%x_d, coef%B_d, temp%x_d, n)
126 end if
127 else
128 call conv1(temp%x, vx%x, vx%x, vy%x, vz%x, xh, coef)
129 call subcol3 (fx%x, coef%B, temp%x, n)
130 call conv1(temp%x, vy%x, vx%x, vy%x, vz%x, xh, coef)
131 call subcol3 (fy%x, coef%B, temp%x, n)
132 if (coef%Xh%lz .eq. 1) then
133 call rzero (temp%x, n)
134 else
135 call conv1(temp%x, vz%x, vx%x, vy%x, vz%x, xh, coef)
136 call subcol3(fz%x, coef%B, temp%x, n)
137 end if
138 end if
139
140 call neko_scratch_registry%relinquish_field(id_temp)
141 end subroutine compute_advection_no_dealias
142
155 subroutine compute_scalar_advection_no_dealias(this, vx, vy, vz, s, fs, Xh, &
156 coef, n, dt)
157 class(adv_no_dealias_t), intent(inout) :: this
158 type(field_t), intent(inout) :: vx, vy, vz
159 type(field_t), intent(inout) :: s
160 type(field_t), intent(inout) :: fs
161 type(space_t), intent(in) :: Xh
162 type(coef_t), intent(in) :: coef
163 integer, intent(in) :: n
164 real(kind=rp), intent(in), optional :: dt
165
166 type(field_t), pointer :: temp
167 integer :: id_temp
168 call neko_scratch_registry%request_field(temp, id_temp, .false.)
169
170 if (neko_bcknd_device .eq. 1) then
171
172 call conv1(temp%x, s%x, vx%x, vy%x, vz%x, xh, coef)
173 call device_subcol3 (fs%x_d, coef%B_d, temp%x_d, n)
174 if (coef%Xh%lz .eq. 1) then
175 call device_rzero (temp%x_d, n)
176 end if
177 else
178 ! temp will hold vx*ds/dx + vy*ds/dy + vz*ds/sz
179 call conv1(temp%x, s%x, vx%x, vy%x, vz%x, xh, coef)
180
181 ! fs = fs - B*temp
182 call subcol3 (fs%x, coef%B, temp%x, n)
183 if (coef%Xh%lz .eq. 1) then
184 call rzero (temp%x, n)
185 end if
186 end if
187
188 call neko_scratch_registry%relinquish_field(id_temp)
190
191 subroutine recompute_metrics_no_dealias(this, coef, moving_boundary)
192 class(adv_no_dealias_t), intent(inout) :: this
193 type(coef_t), intent(in) :: coef
194 logical, intent(in) :: moving_boundary
195 ! no-op
196 end subroutine recompute_metrics_no_dealias
197
198 subroutine compute_ale_advection_no_dealias(this, vx, vy, vz, &
199 wm_x, wm_y, wm_z, fx, fy, fz, Xh, coef, n, dt)
200 class(adv_no_dealias_t), intent(inout) :: this
201 type(field_t), intent(inout) :: vx, vy, vz
202 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
203 type(field_t), intent(inout) :: fx, fy, fz
204 type(space_t), intent(in) :: Xh
205 type(coef_t), intent(in) :: coef
206 integer, intent(in) :: n
207 real(kind=rp), intent(in), optional :: dt
208 type(field_t), pointer :: temp, work_x, work_y, work_z
209 integer :: id(4)
210
211 call neko_scratch_registry%request_field(temp, id(1), .false.)
212 call neko_scratch_registry%request_field(work_x, id(2), .false.)
213 call neko_scratch_registry%request_field(work_y, id(3), .false.)
214 call neko_scratch_registry%request_field(work_z, id(4), .false.)
215
216 ! u.wm_*
217 call field_col3(work_x, vx, wm_x)
218 call field_col3(work_y, vx, wm_y)
219 call field_col3(work_z, vx, wm_z)
220 call div(temp%x_d, work_x%x_d, work_y%x_d, work_z%x_d, coef)
221
222 if (neko_bcknd_device .eq. 1) then
223 call device_addcol3(fx%x_d, coef%B_d, temp%x_d, n)
224 else
225 call addcol3(fx%x, coef%B, temp%x, n)
226 end if
227
228 ! v.wm_*
229 call field_col3(work_x, vy, wm_x)
230 call field_col3(work_y, vy, wm_y)
231 call field_col3(work_z, vy, wm_z)
232 call div(temp%x_d, work_x%x_d, work_y%x_d, work_z%x_d, coef)
233
234 if (neko_bcknd_device .eq. 1) then
235 call device_addcol3(fy%x_d, coef%B_d, temp%x_d, n)
236 else
237 call addcol3(fy%x, coef%B, temp%x, n)
238 end if
239
240 ! w.wm_*
241 call field_col3(work_x, vz, wm_x)
242 call field_col3(work_y, vz, wm_y)
243 call field_col3(work_z, vz, wm_z)
244 call div(temp%x_d, work_x%x_d, work_y%x_d, work_z%x_d, coef)
245
246 if (neko_bcknd_device .eq. 1) then
247 call device_addcol3(fz%x_d, coef%B_d, temp%x_d, n)
248 else
249 call addcol3(fz%x, coef%B, temp%x, n)
250 end if
251
252 call neko_scratch_registry%relinquish_field(id)
253
255end module adv_no_dealias
Return the device pointer for an associated Fortran array.
Definition device.F90:107
Map a Fortran array to a device (allocate and associate)
Definition device.F90:77
Compute the divergence of a vector field.
Definition operators.f90:85
Subroutines to add advection terms to the RHS of a transport equation.
subroutine init_no_dealias(this, coef)
Constructor.
subroutine free_no_dealias(this)
Destructor.
subroutine compute_ale_advection_no_dealias(this, vx, vy, vz, wm_x, wm_y, wm_z, fx, fy, fz, xh, coef, n, dt)
subroutine compute_scalar_advection_no_dealias(this, vx, vy, vz, s, fs, xh, coef, n, dt)
Add the advection term for a scalar, i.e. , to the RHS.
subroutine recompute_metrics_no_dealias(this, coef, moving_boundary)
subroutine compute_advection_no_dealias(this, vx, vy, vz, fx, fy, fz, xh, coef, n, dt)
Add the advection term for the fluid, i.e. to the RHS.
Subroutines to add advection terms to the RHS of a transport equation.
Definition advection.f90:34
Coefficients.
Definition coef.f90:34
subroutine, public device_addcol3(a_d, b_d, c_d, n, strm)
Returns .
subroutine, public device_rzero(a_d, n, strm)
Zero a real vector.
subroutine, public device_subcol3(a_d, b_d, c_d, 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
subroutine, public field_col3(a, b, c, n)
Vector multiplication with 3 vectors .
Defines a field.
Definition field.f90:34
Definition math.f90:60
subroutine, public subcol3(a, b, c, n)
Returns .
Definition math.f90:1075
subroutine, public addcol3(a, b, c, n)
Returns .
Definition math.f90:1162
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.f90:233
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
subroutine, public conv1(du, u, vx, vy, vz, xh, coef, es, ee)
Compute the advection term.
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Defines a function space.
Definition space.f90:34
Type encapsulating advection routines with no dealiasing applied.
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:63
The function space for the SEM solution fields.
Definition space.f90:63