Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
reichardt.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!
33!
34!> Implements `reichardt_t`.
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
44 use user_intf, only : user_t
45 use registry, only : neko_registry
49 use field_math, only : field_invcol3
50 use vector, only : vector_t
51 use math, only : masked_gather_copy_0
54 use logger, only : log_size, neko_log
55
56 implicit none
57 private
58
59 !> Wall model based on Reichardt's law of the wall,
60 !! \f$ u^+ = \frac{1}{\kappa} \ln(1 + \kappa y^+) + C \left[1 -
61 !! e^{-y^+/B_1} - \frac{y^+}{B_1} e^{-y^+/B_2} \right] \f$,
62 !! with the original constants \f$ C = 7.8 \f$, \f$ B_1 = 11 \f$ and
63 !! \f$ B_2 = 3 \f$ as defaults.
64 !! Reference: https://doi.org/10.1002/zamm.19510310704
65 type, public, extends(wall_model_t) :: reichardt_t
66 !> The von Karman coefficient.
67 real(kind=rp) :: kappa = 0.41_rp
68 !> The amplitude of the exponential correction.
69 real(kind=rp) :: c = 7.8_rp
70 !> The damping length scale, in wall units.
71 real(kind=rp) :: b1 = 11.0_rp
72 !> The decay length scale of the second exponential term, in wall units.
73 real(kind=rp) :: b2 = 3.0_rp
74 !> The kinematic viscosity.
75 type(vector_t) :: nu
76 !> The fluid density at the boundary.
77 type(vector_t) :: rho_w
78 !> Velocity sampled away from the wall.
79 type(vector_t) :: u_s, v_s, w_s
80 contains
81 !> Constructor from JSON.
82 procedure, pass(this) :: init => reichardt_init
83 !> Partial constructor from JSON, meant to work as the first stage of
84 !! initialization before the `finalize` call.
85 procedure, pass(this) :: partial_init => reichardt_partial_init
86 !> Finalize the construction using the mask and facet arrays of the bc.
87 procedure, pass(this) :: finalize => reichardt_finalize
88 !> Constructor from components.
89 procedure, pass(this) :: init_from_components => &
91 !> Destructor.
92 procedure, pass(this) :: free => reichardt_free
93 !> Compute the kinematic viscosity at the wall.
94 procedure, pass(this) :: compute_nu => reichardt_compute_nu
95 !> Compute the wall shear stress.
96 procedure, pass(this) :: compute => reichardt_compute
97 end type reichardt_t
98
99contains
100 !> Constructor from JSON.
101 !! @param scheme_name The name of the scheme for which the wall model is used.
102 !! @param coef SEM coefficients.
103 !! @param msk The boundary mask.
104 !! @param facet The boundary facets.
105 !! @param json A dictionary with parameters.
106 subroutine reichardt_init(this, scheme_name, coef, msk, facet, json)
107 class(reichardt_t), intent(inout) :: this
108 character(len=*), intent(in) :: scheme_name
109 type(coef_t), intent(in) :: coef
110 integer, intent(in) :: msk(:)
111 integer, intent(in) :: facet(:)
112 type(json_file), intent(inout) :: json
113 real(kind=rp) :: kappa, c, b1, b2
114 class(wall_sampler_t), allocatable :: sampler
115
116 call json_get_or_lookup(json, "kappa", kappa)
117 call json_get_or_lookup_or_default(json, "C", c, 7.8_rp)
118 call json_get_or_lookup_or_default(json, "B1", b1, 11.0_rp)
119 call json_get_or_lookup_or_default(json, "B2", b2, 3.0_rp)
120
121 call wall_sampler_factory(sampler, json)
122 call this%init_from_components(scheme_name, coef, msk, facet, sampler, &
123 kappa, c, b1, b2)
124 end subroutine reichardt_init
125
126 !> Constructor from JSON.
127 !! @param coef SEM coefficients.
128 !! @param scheme_name The name of the scheme for which the wall model is used.
129 !! @param json A dictionary with parameters.
130 subroutine reichardt_partial_init(this, coef, scheme_name, json)
131 class(reichardt_t), intent(inout) :: this
132 type(coef_t), intent(in) :: coef
133 character(len=*), intent(in) :: scheme_name
134 type(json_file), intent(inout) :: json
135 character(len=LOG_SIZE) :: log_buf
136
137 call this%partial_init_base(coef, scheme_name, json)
138 call json_get_or_lookup(json, "kappa", this%kappa)
139 call json_get_or_lookup_or_default(json, "C", this%C, 7.8_rp)
140 call json_get_or_lookup_or_default(json, "B1", this%B1, 11.0_rp)
141 call json_get_or_lookup_or_default(json, "B2", this%B2, 3.0_rp)
142
143 call neko_log%section('Wall model')
144 write(log_buf, '(A)') 'Model : Reichardt'
145 call neko_log%message(log_buf)
146 write(log_buf, '(A, E15.7)') 'kappa : ', this%kappa
147 call neko_log%message(log_buf)
148 write(log_buf, '(A, E15.7)') 'C : ', this%C
149 call neko_log%message(log_buf)
150 write(log_buf, '(A, E15.7)') 'B1 : ', this%B1
151 call neko_log%message(log_buf)
152 write(log_buf, '(A, E15.7)') 'B2 : ', this%B2
153 call neko_log%message(log_buf)
154 call neko_log%end_section()
155
156 end subroutine reichardt_partial_init
157
158 !> Finalize the construction using the mask and facet arrays of the bc.
159 !! @param msk The boundary mask.
160 !! @param facet The boundary facets.
161 !! @param bc_name The name of the boundary condition.
162 !! @param user The user interface.
163 subroutine reichardt_finalize(this, msk, facet, bc_name, user)
164 class(reichardt_t), intent(inout) :: this
165 integer, intent(in) :: msk(:)
166 integer, intent(in) :: facet(:)
167 character(len=*), optional, intent(in) :: bc_name
168 type(user_t), target, optional, intent(in) :: user
169
170 call this%finalize_base(msk, facet, bc_name, user)
171 call this%nu%init(this%n_nodes)
172 call this%rho_w%init(this%n_nodes)
173 call this%validate_single_sample()
174 call this%u_s%init(this%n_nodes)
175 call this%v_s%init(this%n_nodes)
176 call this%w_s%init(this%n_nodes)
177 end subroutine reichardt_finalize
178
179 !> Constructor from components.
180 !! @param scheme_name The name of the scheme for which the wall model is used.
181 !! @param coef SEM coefficients.
182 !! @param msk The boundary mask.
183 !! @param facet The boundary facets.
184 !! @param sampler The sampling strategy. Ownership is transferred.
185 !! @param kappa The von Karman coefficient.
186 !! @param C The amplitude of the exponential correction.
187 !! @param B1 The damping length scale, in wall units.
188 !! @param B2 The decay length scale of the second exponential term, in
189 !! wall units.
190 subroutine reichardt_init_from_components(this, scheme_name, coef, msk, &
191 facet, sampler, kappa, C, B1, B2)
192 class(reichardt_t), intent(inout) :: this
193 character(len=*), intent(in) :: scheme_name
194 type(coef_t), intent(in) :: coef
195 integer, intent(in) :: msk(:)
196 integer, intent(in) :: facet(:)
197 class(wall_sampler_t), allocatable, intent(inout) :: sampler
198 real(kind=rp), intent(in) :: kappa, c, b1, b2
199
200 call this%free()
201 call this%init_base(scheme_name, coef, msk, facet, sampler)
202
203 this%kappa = kappa
204 this%C = c
205 this%B1 = b1
206 this%B2 = b2
207
208 call this%nu%init(this%n_nodes)
209 call this%rho_w%init(this%n_nodes)
210 call this%validate_single_sample()
211 call this%u_s%init(this%n_nodes)
212 call this%v_s%init(this%n_nodes)
213 call this%w_s%init(this%n_nodes)
214 end subroutine reichardt_init_from_components
215
216 !> Compute the kinematic viscosity vector.
217 subroutine reichardt_compute_nu(this)
218 class(reichardt_t), intent(inout) :: this
219 type(field_t), pointer :: temp
220 integer :: idx
221
222 call neko_scratch_registry%request_field(temp, idx, .false.)
223 call field_invcol3(temp, this%mu, this%rho)
224
225 if (neko_bcknd_device .eq. 1) then
226 call device_masked_gather_copy_0(this%nu%x_d, temp%x_d, this%msk_d, &
227 temp%size(), this%nu%size())
228 call device_masked_gather_copy_0(this%rho_w%x_d, this%rho%x_d, &
229 this%msk_d, this%rho%size(), this%rho_w%size())
230 else
231 call masked_gather_copy_0(this%nu%x, temp%x, this%msk, temp%size(), &
232 this%nu%size())
233 call masked_gather_copy_0(this%rho_w%x, this%rho%x, this%msk, &
234 this%rho%size(), this%rho_w%size())
235 end if
236
237 call neko_scratch_registry%relinquish_field(idx)
238 end subroutine reichardt_compute_nu
239
240 !> Destructor for the reichardt_t class.
241 subroutine reichardt_free(this)
242 class(reichardt_t), intent(inout) :: this
243
244 call this%nu%free()
245 call this%rho_w%free()
246 call this%u_s%free()
247 call this%v_s%free()
248 call this%w_s%free()
249 call this%free_base()
250
251 end subroutine reichardt_free
252
253 !> Compute the wall shear stress.
254 !! @param t The time value.
255 !! @param tstep The current time-step.
256 subroutine reichardt_compute(this, t, tstep)
257 class(reichardt_t), intent(inout) :: this
258 real(kind=rp), intent(in) :: t
259 integer, intent(in) :: tstep
260 type(field_t), pointer :: u
261 type(field_t), pointer :: v
262 type(field_t), pointer :: w
263
264 call this%compute_nu()
265
266 u => neko_registry%get_field("u")
267 v => neko_registry%get_field("v")
268 w => neko_registry%get_field("w")
269
270 call this%sampler%sample(u, this%u_s)
271 call this%sampler%sample(v, this%v_s)
272 call this%sampler%sample(w, this%w_s)
273
274 if (neko_bcknd_device .eq. 1) then
275 call reichardt_compute_device(this%u_s%x_d, this%v_s%x_d, &
276 this%w_s%x_d, &
277 this%n_x%x_d, this%n_y%x_d, this%n_z%x_d, &
278 this%nu%x_d, this%rho_w%x_d, this%sampler%h%x_d, &
279 this%tau_x%x_d, this%tau_y%x_d, this%tau_z%x_d, &
280 this%n_nodes, this%kappa, this%C, this%B1, this%B2, tstep)
281 else
282 call reichardt_compute_cpu(this%u_s%x, this%v_s%x, this%w_s%x, &
283 this%n_x%x, this%n_y%x, this%n_z%x, &
284 this%nu%x, this%rho_w%x, this%sampler%h%x, &
285 this%tau_x%x, this%tau_y%x, this%tau_z%x, &
286 this%n_nodes, this%kappa, this%C, this%B1, this%B2, tstep)
287 end if
288
289 nullify(u, v, w)
290
291 end subroutine reichardt_compute
292end module reichardt
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.
Logging routines.
Definition log.f90:34
type(log_t), public neko_log
Global log stream.
Definition log.f90:92
integer, parameter, public log_size
Definition log.f90:46
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:374
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:158
Implements the CPU kernel for the reichardt_t type.
subroutine, public reichardt_compute_cpu(u, v, w, n_x, n_y, n_z, nu, rho_w, h, tau_x, tau_y, tau_z, n_nodes, kappa, c, b1, b2, tstep)
Compute the wall shear stress on cpu using Reichardt's law.
Implements the device kernel for the reichardt_t type.
subroutine, public reichardt_compute_device(u_d, v_d, w_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, kappa, c, b1, b2, tstep)
Compute the wall shear stress on device using Reichardt's law.
Implements reichardt_t.
Definition reichardt.f90:35
subroutine reichardt_init(this, scheme_name, coef, msk, facet, json)
Constructor from JSON.
subroutine reichardt_partial_init(this, coef, scheme_name, json)
Constructor from JSON.
subroutine reichardt_compute(this, t, tstep)
Compute the wall shear stress.
subroutine reichardt_init_from_components(this, scheme_name, coef, msk, facet, sampler, kappa, c, b1, b2)
Constructor from components.
subroutine reichardt_finalize(this, msk, facet, bc_name, user)
Finalize the construction using the mask and facet arrays of the bc.
subroutine reichardt_compute_nu(this)
Compute the kinematic viscosity vector.
subroutine reichardt_free(this)
Destructor for the reichardt_t class.
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.
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
Defines a vector.
Definition vector.f90:34
Implements wall_model_t.
Factory for wall-model samplers.
subroutine, public wall_sampler_factory(object, json)
Wall sampler factory.
Defines the abstract interface for wall-model field samplers.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
Wall model based on Reichardt's law of the wall, , with the original constants , and as defaults....
Definition reichardt.f90:65
A type collecting all the overridable user routines and flag to suppress type injection from custom m...
Base abstract type for wall-stress models for wall-modelled LES.
Base type for sampling solution fields at points associated with wall nodes. Samples belonging to one...