Neko 1.99.5
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
cai_sagaut_model_ii.f90
Go to the documentation of this file.
1! Copyright (c) 2026, 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!
36 use field, only : field_t
37 use num_types, only : rp
38 use json_module, only : json_file
39 use coefs, only : coef_t
41 use wall_model, only : wall_model_t
42 use registry, only : neko_registry
46 use field_math, only : field_invcol3
47 use vector, only : vector_t
48 use math, only : masked_gather_copy_0
51
52 implicit none
53 private
54
57 type, public, extends(wall_model_t) :: cai_sagaut_model_ii_t
59 real(kind=rp) :: kappa = 0.41_rp
61 real(kind=rp) :: b = 5.2_rp
63 real(kind=rp) :: p = 1.138_rp
65 real(kind=rp) :: s = 217.8_rp
67 type(vector_t) :: nu
69 type(vector_t) :: rho_w
70 contains
72 procedure, pass(this) :: init => cai_sagaut_model_ii_init
74 procedure, pass(this) :: partial_init => cai_sagaut_model_ii_partial_init
76 procedure, pass(this) :: finalize => cai_sagaut_model_ii_finalize
78 procedure, pass(this) :: init_from_components => &
81 procedure, pass(this) :: free => cai_sagaut_model_ii_free
83 procedure, pass(this) :: compute_nu_and_rho => &
86 procedure, pass(this) :: compute => cai_sagaut_model_ii_compute
88
89contains
97 subroutine cai_sagaut_model_ii_init(this, scheme_name, coef, msk, facet, &
98 h_index, json)
99 class(cai_sagaut_model_ii_t), intent(inout) :: this
100 character(len=*), intent(in) :: scheme_name
101 type(coef_t), intent(in) :: coef
102 integer, intent(in) :: msk(:)
103 integer, intent(in) :: facet(:)
104 integer, intent(in) :: h_index
105 type(json_file), intent(inout) :: json
106 real(kind=rp) :: kappa, b, p, s
107
108 call json_get_or_lookup(json, "kappa", kappa)
109 call json_get_or_lookup(json, "B", b)
110 call json_get_or_lookup_or_default(json, "p", p, 1.138_rp)
111 call json_get_or_lookup_or_default(json, "s", s, 217.8_rp)
112
113 call this%init_from_components(scheme_name, coef, msk, facet, h_index, &
114 kappa, b, p, s)
115 end subroutine cai_sagaut_model_ii_init
116
120 subroutine cai_sagaut_model_ii_partial_init(this, coef, json)
121 class(cai_sagaut_model_ii_t), intent(inout) :: this
122 type(coef_t), intent(in) :: coef
123 type(json_file), intent(inout) :: json
124 call this%partial_init_base(coef, json)
125 call json_get_or_lookup(json, "kappa", this%kappa)
126 call json_get_or_lookup(json, "B", this%B)
127 call json_get_or_lookup_or_default(json, "p", this%p, 1.138_rp)
128 call json_get_or_lookup_or_default(json, "s", this%s, 217.8_rp)
130
134 subroutine cai_sagaut_model_ii_finalize(this, msk, facet)
135 class(cai_sagaut_model_ii_t), intent(inout) :: this
136 integer, intent(in) :: msk(:)
137 integer, intent(in) :: facet(:)
138
139 call this%finalize_base(msk, facet)
140 call this%nu%init(this%n_nodes)
141 call this%rho_w%init(this%n_nodes)
142 end subroutine cai_sagaut_model_ii_finalize
143
154 subroutine cai_sagaut_model_ii_init_from_components(this, scheme_name, coef, &
155 msk, facet, h_index, kappa, B, p, s)
156 class(cai_sagaut_model_ii_t), intent(inout) :: this
157 character(len=*), intent(in) :: scheme_name
158 type(coef_t), intent(in) :: coef
159 integer, intent(in) :: msk(:)
160 integer, intent(in) :: facet(:)
161 integer, intent(in) :: h_index
162 real(kind=rp), intent(in) :: kappa, b, p, s
163
164 call this%free()
165 call this%init_base(scheme_name, coef, msk, facet, h_index)
166
167 this%kappa = kappa
168 this%B = b
169 this%p = p
170 this%s = s
171
172 call this%nu%init(this%n_nodes)
173 call this%rho_w%init(this%n_nodes)
175
178 class(cai_sagaut_model_ii_t), intent(inout) :: this
179 type(field_t), pointer :: temp
180 integer :: idx
181
182 call neko_scratch_registry%request_field(temp, idx, .false.)
183 call field_invcol3(temp, this%mu, this%rho)
184
185 if (neko_bcknd_device .eq. 1) then
186 call device_masked_gather_copy_0(this%nu%x_d, temp%x_d, this%msk_d, &
187 temp%size(), this%nu%size())
188 call device_masked_gather_copy_0(this%rho_w%x_d, this%rho%x_d, &
189 this%msk_d, this%rho%size(), this%rho_w%size())
190 else
191 call masked_gather_copy_0(this%nu%x, temp%x, this%msk, temp%size(), &
192 this%nu%size())
193 call masked_gather_copy_0(this%rho_w%x, this%rho%x, this%msk, &
194 this%rho%size(), this%rho_w%size())
195 end if
196
197 call neko_scratch_registry%relinquish_field(idx)
199
202 class(cai_sagaut_model_ii_t), intent(inout) :: this
203
204 call this%rho_w%free()
205 call this%nu%free()
206 call this%free_base()
207 end subroutine cai_sagaut_model_ii_free
208
212 subroutine cai_sagaut_model_ii_compute(this, t, tstep)
213 class(cai_sagaut_model_ii_t), intent(inout) :: this
214 real(kind=rp), intent(in) :: t
215 integer, intent(in) :: tstep
216 type(field_t), pointer :: u
217 type(field_t), pointer :: v
218 type(field_t), pointer :: w
219
220 call this%compute_nu_and_rho()
221
222 u => neko_registry%get_field("u")
223 v => neko_registry%get_field("v")
224 w => neko_registry%get_field("w")
225
226 if (neko_bcknd_device .eq. 1) then
227 call cai_sagaut_model_ii_compute_device(u%x_d, v%x_d, w%x_d, &
228 this%ind_r_d, this%ind_s_d, this%ind_t_d, this%ind_e_d, &
229 this%n_x%x_d, this%n_y%x_d, this%n_z%x_d, this%nu%x_d, &
230 this%rho_w%x_d, this%h%x_d, this%tau_x%x_d, this%tau_y%x_d, &
231 this%tau_z%x_d, this%n_nodes, u%Xh%lx, this%kappa, this%B, &
232 this%p, this%s)
233 else
234 call cai_sagaut_model_ii_compute_cpu(u%x, v%x, w%x, this%ind_r, &
235 this%ind_s, this%ind_t, this%ind_e, this%n_x%x, this%n_y%x, &
236 this%n_z%x, this%nu%x, this%rho_w%x, this%h%x, this%tau_x%x, &
237 this%tau_y%x, this%tau_z%x, this%n_nodes, u%Xh%lx, u%msh%nelv, &
238 this%kappa, this%B, this%p, this%s)
239 end if
240
241 nullify(u, v, w)
242
243 end subroutine cai_sagaut_model_ii_compute
244end module cai_sagaut_model_ii
__global__ void cai_sagaut_model_ii_compute(const T *__restrict__ u_d, const T *__restrict__ v_d, const T *__restrict__ w_d, const int *__restrict__ ind_r_d, const int *__restrict__ ind_s_d, const int *__restrict__ ind_t_d, const int *__restrict__ ind_e_d, const T *__restrict__ n_x_d, const T *__restrict__ n_y_d, const T *__restrict__ n_z_d, const T *__restrict__ nu_d, const T *__restrict__ rho_w_d, const T *__restrict__ h_d, T *__restrict__ tau_x_d, T *__restrict__ tau_y_d, T *__restrict__ tau_z_d, const int n_nodes, const int lx, const T kappa, const T B, const T p, const T s)
CPU backend for cai_sagaut_model_ii_t.
subroutine, public cai_sagaut_model_ii_compute_cpu(u, v, w, ind_r, ind_s, ind_t, ind_e, n_x, n_y, n_z, nu, rho_w, h, tau_x, tau_y, tau_z, n_nodes, lx, nelv, kappa, b, p, s)
Evaluate wall shear stresses with the CPU Model-II kernel.
Device dispatch for cai_sagaut_model_ii_t.
subroutine, public cai_sagaut_model_ii_compute_device(u_d, v_d, w_d, ind_r_d, ind_s_d, ind_t_d, ind_e_d, n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, tau_x_d, tau_y_d, tau_z_d, n_nodes, lx, kappa, b, p, s)
Evaluate the device wall-model kernel for Model-II.
Implements cai_sagaut_model_ii_t.
subroutine cai_sagaut_model_ii_init(this, scheme_name, coef, msk, facet, h_index, json)
Initialise the wall model from the case file.
subroutine cai_sagaut_model_ii_compute_nu_and_rho(this)
Gather viscosity and density values at the wall-model points.
subroutine cai_sagaut_model_ii_partial_init(this, coef, json)
Partially initialise the wall model from the case file.
subroutine cai_sagaut_model_ii_init_from_components(this, scheme_name, coef, msk, facet, h_index, kappa, b, p, s)
Initialise the wall model from explicit components.
subroutine cai_sagaut_model_ii_free(this)
Destructor.
subroutine cai_sagaut_model_ii_finalize(this, msk, facet)
Finalise allocation of derived data structures.
Coefficients.
Definition coef.f90:34
subroutine, public device_masked_gather_copy_0(a_d, b_d, mask_d, n, n_mask, strm)
Gather a masked vector .
subroutine, public field_invcol3(a, b, c, n)
Invert a vector .
Defines a field.
Definition field.f90:34
Utilities for retrieving parameters from the case files.
Definition math.f90:60
subroutine, public masked_gather_copy_0(a, b, mask, n, n_mask)
Gather a masked vector to reduced contigous vector .
Definition math.f90:360
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:144
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 vector.
Definition vector.f90:34
Implements wall_model_t.
Explicit wall model based on Model-II from Cai and Sagaut (2021).
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:62
Base abstract type for wall-stress models for wall-modelled LES.