Neko 1.1.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
wall_model_bc.f90
Go to the documentation of this file.
1! Copyright (c) 2024-2025, 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 num_types, only : rp
37 use, intrinsic :: iso_c_binding, only : c_ptr
38 use utils, only : neko_error
39 use json_utils, only : json_get
40 use coefs, only : coef_t
41 use wall_model, only : wall_model_t, wall_model_allocator
43 use json_module, only : json_file
44 use time_state, only : time_state_t
45 implicit none
46 private
47
51 type, public, extends(shear_stress_t) :: wall_model_bc_t
53 class(wall_model_t), allocatable :: wall_model
54 contains
56 procedure, pass(this) :: init => wall_model_bc_init
58 procedure, pass(this) :: free => wall_model_bc_free
60 procedure, pass(this) :: finalize => wall_model_bc_finalize
61 procedure, pass(this) :: apply_scalar => wall_model_bc_apply_scalar
62 procedure, pass(this) :: apply_vector => wall_model_bc_apply_vector
63 procedure, pass(this) :: apply_scalar_dev => &
65 procedure, pass(this) :: apply_vector_dev => &
67 end type wall_model_bc_t
68
69contains
70
72 subroutine wall_model_bc_apply_scalar(this, x, n, time, strong)
73 class(wall_model_bc_t), intent(inout) :: this
74 integer, intent(in) :: n
75 real(kind=rp), intent(inout), dimension(n) :: x
76 type(time_state_t), intent(in), optional :: time
77 logical, intent(in), optional :: strong
78
79 call neko_error("The wall model bc is not applicable to scalar fields.")
80
81 end subroutine wall_model_bc_apply_scalar
82
90 subroutine wall_model_bc_apply_vector(this, x, y, z, n, time, strong)
91 class(wall_model_bc_t), intent(inout) :: this
92 integer, intent(in) :: n
93 real(kind=rp), intent(inout), dimension(n) :: x
94 real(kind=rp), intent(inout), dimension(n) :: y
95 real(kind=rp), intent(inout), dimension(n) :: z
96 type(time_state_t), intent(in), optional :: time
97 logical, intent(in), optional :: strong
98 integer :: i, m, k, fid
99 real(kind=rp) :: magtau
100 logical :: strong_
101
102 if (present(strong)) then
103 strong_ = strong
104 else
105 strong_ = .true.
106 end if
107
108 if (.not. present(time)) then
109 call neko_error("wall_model_bc_apply_vector: time is required.")
110 end if
111
112 if (.not. strong_) then
113 !$omp single
114 ! Compute the wall stress using the wall model.
115 call this%wall_model%compute(time%t, time%tstep)
116
117 ! Populate the 3D wall stress field for post-processing.
118 call this%wall_model%compute_mag_field()
119
120 ! Set the computed stress for application by the underlying Neumann
121 ! boundary conditions.
122 call this%set_stress(this%wall_model%tau_x, this%wall_model%tau_y, &
123 this%wall_model%tau_z)
124 !$omp end single
125 end if
126
127 ! Either add the stress to the RHS or apply the non-penetration condition
128 call this%shear_stress_t%apply_vector(x, y, z, n, time, strong_)
129
130 end subroutine wall_model_bc_apply_vector
131
134 subroutine wall_model_bc_apply_scalar_dev(this, x_d, time, strong, strm)
135 class(wall_model_bc_t), intent(inout), target :: this
136 type(c_ptr), intent(inout) :: x_d
137 type(time_state_t), intent(in), optional :: time
138 logical, intent(in), optional :: strong
139 type(c_ptr), intent(inout) :: strm
140
141 call neko_error("The wall model bc is not applicable to scalar fields.")
142
143 end subroutine wall_model_bc_apply_scalar_dev
144
147 subroutine wall_model_bc_apply_vector_dev(this, x_d, y_d, z_d, time, &
148 strong, strm)
149 class(wall_model_bc_t), intent(inout), target :: this
150 type(c_ptr), intent(inout) :: x_d
151 type(c_ptr), intent(inout) :: y_d
152 type(c_ptr), intent(inout) :: z_d
153 type(time_state_t), intent(in), optional :: time
154 logical, intent(in), optional :: strong
155 logical :: strong_
156 type(c_ptr), intent(inout) :: strm
157
158 if (present(strong)) then
159 strong_ = strong
160 else
161 strong_ = .true.
162 end if
163
164 if (.not. present(time)) then
165 call neko_error("wall_model_bc_apply_vector_dev: time is required.")
166 end if
167
168 if (.not. strong_) then
169 !$omp single
170 ! Compute the wall stress using the wall model.
171 call this%wall_model%compute(time%t, time%tstep)
172
173 ! Populate the 3D wall stress field for post-processing.
174 call this%wall_model%compute_mag_field()
175
176 ! Set the computed stress for application by the underlying Neumann
177 ! boundary conditions.
178 call this%set_stress(this%wall_model%tau_x, this%wall_model%tau_y, &
179 this%wall_model%tau_z)
180 !$omp end single
181 end if
182
183 ! Either add the stress to the RHS or apply the non-penetration condition
184 call this%shear_stress_t%apply_vector_dev(x_d, y_d, z_d, &
185 time, strong_, strm)
186
187 end subroutine wall_model_bc_apply_vector_dev
188
192 subroutine wall_model_bc_init(this, coef, json)
193 class(wall_model_bc_t), target, intent(inout) :: this
194 type(coef_t), target, intent(in) :: coef
195 type(json_file), intent(inout) :: json
196 real(kind=rp) :: value(3) = [0, 0, 0]
197 character(len=:), allocatable :: type_name
198
199 ! Initialize the shear stress base class.
200 call this%shear_stress_t%init_from_components(coef, value)
201 ! Partial initialization of the wall model by parsing the JSON.
202 call json_get(json, "model", type_name)
203 call wall_model_allocator(this%wall_model, type_name)
204
205 call this%wall_model%partial_init(coef, json)
206 end subroutine wall_model_bc_init
207
209 subroutine wall_model_bc_free(this)
210 class(wall_model_bc_t), target, intent(inout) :: this
211
212 call this%shear_stress_t%free()
213 call this%wall_model%free()
214
215 if (allocated(this%wall_model)) then
216 deallocate(this%wall_model)
217 end if
218
219 end subroutine wall_model_bc_free
220
222 subroutine wall_model_bc_finalize(this, only_facets)
223 class(wall_model_bc_t), target, intent(inout) :: this
224 logical, optional, intent(in) :: only_facets
225
226 if (present(only_facets)) then
227 if (.not. only_facets) then
228 call neko_error("For wall_model_bc_t, only_facets has to be true.")
229 end if
230 end if
231
232 call this%shear_stress_t%finalize(.true.)
233 call this%wall_model%finalize(this%msk, this%facet)
234 end subroutine wall_model_bc_finalize
235
236end module wall_model_bc
Retrieves a parameter by name or throws an error.
Coefficients.
Definition coef.f90:34
Utilities for retrieving parameters from the case files.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a shear stress boundary condition for a vector field. Maintainer: Timofey Mukha.
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
Defines the wall_model_bc_t type. Maintainer: Timofey Mukha.
subroutine wall_model_bc_init(this, coef, json)
Constructor.
subroutine wall_model_bc_apply_scalar(this, x, n, time, strong)
Apply shear stress for a scalar field x.
subroutine wall_model_bc_apply_scalar_dev(this, x_d, time, strong, strm)
Boundary condition apply for a generic wall_model_bc condition to a vector x (device version)
subroutine wall_model_bc_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
Boundary condition apply for a generic wall_model_bc condition to vectors x, y and z (device version)
subroutine wall_model_bc_apply_vector(this, x, y, z, n, time, strong)
Apply the boundary condition to the right-hand side.
subroutine wall_model_bc_free(this)
Destructor.
subroutine wall_model_bc_finalize(this, only_facets)
Finalize by building mask arrays and init'ing the wall model.
Implements wall_model_t.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:63
A shear stress boundary condition.
A struct that contains all info about the time, expand as needed.
Base abstract type for wall-stress models for wall-modelled LES.
A shear stress boundary condition, computing the stress values using a wall model.