Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
rough_log_law.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!
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 vector, only : vector_t
42 use wall_model, only : wall_model_t
45 use user_intf, only : user_t
46 use utils, only : neko_error
47 use registry, only : neko_registry
48 use json_utils, only : json_get_or_lookup, &
53 use math, only: masked_gather_copy_0
55 use logger, only : log_size, neko_log
56 implicit none
57 private
58
63 type, public, extends(wall_model_t) :: rough_log_law_t
64
66 real(kind=rp) :: kappa
68 real(kind=rp) :: b
70 real(kind=rp) :: z0
71 ! The fluid density at the boundary
72 type(vector_t) :: rho_w
74 type(vector_t) :: u_s, v_s, w_s
75 contains
77 procedure, pass(this) :: init => rough_log_law_init
80 procedure, pass(this) :: partial_init => rough_log_law_partial_init
82 procedure, pass(this) :: finalize => rough_log_law_finalize
84 procedure, pass(this) :: init_from_components => &
87 procedure, pass(this) :: free => rough_log_law_free
89 procedure, pass(this) :: compute => rough_log_law_compute
90 ! Extract fluid properties at the wall (rho)
91 procedure, pass(this) :: extract_properties => &
93 end type rough_log_law_t
94
95contains
102 subroutine rough_log_law_init(this, scheme_name, coef, msk, facet, &
103 json)
104 class(rough_log_law_t), intent(inout) :: this
105 character(len=*), intent(in) :: scheme_name
106 type(coef_t), intent(in) :: coef
107 integer, intent(in) :: msk(:)
108 integer, intent(in) :: facet(:)
109 type(json_file), intent(inout) :: json
110 real(kind=rp) :: kappa, b, z0
111 class(wall_sampler_t), allocatable :: sampler
112
113 call json_get_or_lookup_or_default(json, "kappa", kappa, 0.4_rp)
114 call json_get_or_lookup_or_default(json, "B", b, 0.0_rp)
115 call json_get_or_lookup(json, "z0", z0)
116
117 call wall_sampler_factory(sampler, json)
118 call this%init_from_components(scheme_name, coef, msk, facet, sampler, &
119 kappa, b, z0)
120 end subroutine rough_log_law_init
121
125 subroutine rough_log_law_partial_init(this, coef, scheme_name, json)
126 class(rough_log_law_t), intent(inout) :: this
127 type(coef_t), intent(in) :: coef
128 character(len=*), intent(in) :: scheme_name
129 type(json_file), intent(inout) :: json
130 character(len=LOG_SIZE) :: log_buf
131
132 call this%partial_init_base(coef, scheme_name, json)
133 call json_get_or_lookup_or_default(json, "kappa", this%kappa, 0.4_rp)
134 call json_get_or_lookup_or_default(json, "B", this%B, 0.0_rp)
135 call json_get_or_lookup(json, "z0", this%z0)
136
137 call neko_log%section('Wall model')
138 write(log_buf, '(A)') 'Model : Rough log law'
139 call neko_log%message(log_buf)
140 write(log_buf, '(A, E15.7)') 'kappa : ', this%kappa
141 call neko_log%message(log_buf)
142 write(log_buf, '(A, E15.7)') 'B : ', this%B
143 call neko_log%message(log_buf)
144 write(log_buf, '(A, E15.7)') 'z0 : ', this%z0
145 call neko_log%message(log_buf)
146 call neko_log%end_section()
147
148 end subroutine rough_log_law_partial_init
149
153 subroutine rough_log_law_finalize(this, msk, facet, bc_name, user)
154 class(rough_log_law_t), intent(inout) :: this
155 integer, intent(in) :: msk(:)
156 integer, intent(in) :: facet(:)
157 character(len=*), optional, intent(in) :: bc_name
158 type(user_t), target, optional, intent(in) :: user
159
160 call this%finalize_base(msk, facet, bc_name, user)
161
162 call this%rho_w%init(this%n_nodes)
163 call this%validate_single_sample()
164 call this%u_s%init(this%n_nodes)
165 call this%v_s%init(this%n_nodes)
166 call this%w_s%init(this%n_nodes)
168
169 end subroutine rough_log_law_finalize
170
173 class(rough_log_law_t), intent(inout) :: this
174
175 if (neko_bcknd_device .eq. 1) then
176 call device_masked_gather_copy_0(this%rho_w%x_d, this%rho%x_d, &
177 this%msk_d, &
178 this%rho%size(), this%rho_w%size())
179 else
180 call masked_gather_copy_0(this%rho_w%x, this%rho%x, this%msk, &
181 this%rho%size(), this%rho_w%size())
182 end if
184
194 subroutine rough_log_law_init_from_components(this, scheme_name, coef, msk, &
195 facet, sampler, kappa, B, z0)
196 class(rough_log_law_t), intent(inout) :: this
197 character(len=*), intent(in) :: scheme_name
198 type(coef_t), intent(in) :: coef
199 integer, intent(in) :: msk(:)
200 integer, intent(in) :: facet(:)
201 class(wall_sampler_t), allocatable, intent(inout) :: sampler
202 real(kind=rp), intent(in) :: kappa, b, z0
203
204 call this%free()
205 call this%init_base(scheme_name, coef, msk, facet, sampler)
206
207 this%kappa = kappa
208 this%B = b
209 this%z0 = z0
210
211 call this%rho_w%init(this%n_nodes)
212 call this%validate_single_sample()
213 call this%u_s%init(this%n_nodes)
214 call this%v_s%init(this%n_nodes)
215 call this%w_s%init(this%n_nodes)
216
218
220
222 class(rough_log_law_t), intent(in) :: this
223
224 if (any(this%sampler%h%x(1:this%n_nodes) .le. this%z0)) then
225 call neko_error("Roughlog WM: Sampling height h must be greater " // &
226 "than roughness z0. Increase the sampling height or decrease z0.")
227 else if (this%z0 .eq. 0.0_rp) then
228 call neko_error("Roughlog WM: Roughness z0 must be greater than 0.")
229 end if
231
233 subroutine rough_log_law_free(this)
234 class(rough_log_law_t), intent(inout) :: this
235
236 call this%rho_w%free()
237 call this%u_s%free()
238 call this%v_s%free()
239 call this%w_s%free()
240 call this%free_base()
241
242 end subroutine rough_log_law_free
243
247 subroutine rough_log_law_compute(this, t, tstep)
248 class(rough_log_law_t), intent(inout) :: this
249 real(kind=rp), intent(in) :: t
250 integer, intent(in) :: tstep
251 type(field_t), pointer :: u
252 type(field_t), pointer :: v
253 type(field_t), pointer :: w
254
255 ! Extract boundary values for rho
256 call this%extract_properties()
257
258 u => neko_registry%get_field("u")
259 v => neko_registry%get_field("v")
260 w => neko_registry%get_field("w")
261
262 call this%sampler%sample(u, this%u_s)
263 call this%sampler%sample(v, this%v_s)
264 call this%sampler%sample(w, this%w_s)
265
266 if (neko_bcknd_device .eq. 1) then
267 call rough_log_law_compute_device(this%u_s%x_d, this%v_s%x_d, &
268 this%w_s%x_d, &
269 this%n_x%x_d, this%n_y%x_d, this%n_z%x_d, &
270 this%sampler%h%x_d, this%tau_x%x_d, this%tau_y%x_d, &
271 this%tau_z%x_d, this%n_nodes, this%kappa, &
272 this%rho_w%x_d, this%B, this%z0, tstep)
273 else
274 call rough_log_law_compute_cpu(this%u_s%x, this%v_s%x, this%w_s%x, &
275 this%n_x%x, this%n_y%x, this%n_z%x, &
276 this%sampler%h%x, this%tau_x%x, this%tau_y%x, this%tau_z%x, &
277 this%n_nodes, this%kappa, &
278 this%rho_w%x, this%B, this%z0, tstep)
279 end if
280
281 nullify(u, v, w)
282
283 end subroutine rough_log_law_compute
284
285
286end module rough_log_law
__global__ void rough_log_law_compute(const T *__restrict__ u_d, const T *__restrict__ v_d, const T *__restrict__ w_d, const T *__restrict__ n_x_d, const T *__restrict__ n_y_d, const T *__restrict__ n_z_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 T kappa, const T *__restrict__ rho_w_d, const T B, const T z0)
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 .
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:80
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:363
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:144
Implements the CPU kernel for the rough_log_law_t type.
subroutine, public rough_log_law_compute_cpu(u, v, w, n_x, n_y, n_z, h, tau_x, tau_y, tau_z, n_nodes, kappa, rho_w, b, z0, tstep)
Compute the wall shear stress on CPU using the rough log-law model.
Implements the device kernel for the rough_log_law_t type.
subroutine, public rough_log_law_compute_device(u_d, v_d, w_d, n_x_d, n_y_d, n_z_d, h_d, tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, rho_w_d, b, z0, tstep)
Compute the wall shear stress on device using the rough log-law model.
Implements rough_log_law_t.
subroutine rough_log_law_init_from_components(this, scheme_name, coef, msk, facet, sampler, kappa, b, z0)
Constructor from components.
subroutine rough_log_law_extract_properties(this)
Extract the values of rho at the boundary.
subroutine rough_log_law_partial_init(this, coef, scheme_name, json)
Constructor from JSON.
subroutine rough_log_law_init(this, scheme_name, coef, msk, facet, json)
Constructor from JSON.
subroutine rough_log_law_validate_sampling_height(this)
subroutine rough_log_law_finalize(this, msk, facet, bc_name, user)
Finalize the construction using the mask and facet arrays of the bc.
subroutine rough_log_law_free(this)
Destructor for the rough_log_law_t (base) 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
Utilities.
Definition utils.f90:35
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:93
Wall model based on the log-law for a rough wall. The formula defining the law is ....
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...