Neko  0.8.99
A portable framework for high-order spectral element flow simulations
wall_model_bc.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 !
35  use num_types
36  use bc, only : bc_t
37  use, intrinsic :: iso_c_binding, only : c_ptr
38  use utils, only : neko_error, nonlinear_index
39  use coefs, only : coef_t
40  use wall_model, only : wall_model_t
41  use rough_log_law, only : rough_log_law_t
42  use spalding, only : spalding_t
43  use shear_stress, only : shear_stress_t
44  implicit none
45  private
46 
49  type, public, extends(shear_stress_t) :: wall_model_bc_t
51  class(wall_model_t), allocatable :: wall_model
52  contains
53  procedure, pass(this) :: apply_scalar => wall_model_bc_apply_scalar
54  procedure, pass(this) :: apply_vector => wall_model_bc_apply_vector
55  procedure, pass(this) :: apply_scalar_dev => wall_model_bc_apply_scalar_dev
56  procedure, pass(this) :: apply_vector_dev => wall_model_bc_apply_vector_dev
57  procedure, pass(this) :: init_wall_model_bc => &
59  end type wall_model_bc_t
60 
61  contains
62 
64  subroutine wall_model_bc_apply_scalar(this, x, n, t, tstep)
65  class(wall_model_bc_t), intent(inout) :: this
66  integer, intent(in) :: n
67  real(kind=rp), intent(inout), dimension(n) :: x
68  real(kind=rp), intent(in), optional :: t
69  integer, intent(in), optional :: tstep
70 
71  call neko_error("The wall model bc is not applicable to scalar fields.")
72 
73  end subroutine wall_model_bc_apply_scalar
74 
77  subroutine wall_model_bc_apply_vector(this, x, y, z, n, t, tstep)
78  class(wall_model_bc_t), intent(inout) :: this
79  integer, intent(in) :: n
80  real(kind=rp), intent(inout), dimension(n) :: x
81  real(kind=rp), intent(inout), dimension(n) :: y
82  real(kind=rp), intent(inout), dimension(n) :: z
83  real(kind=rp), intent(in), optional :: t
84  integer, intent(in), optional :: tstep
85  integer :: i, m, k, fid
86  real(kind=rp) :: magtau
87 
88  call this%wall_model%compute(t, tstep)
89 
90  do i=1, this%msk(0)
91  magtau = sqrt(this%wall_model%tau_x(i)**2 + this%wall_model%tau_y(i)**2&
92  + this%wall_model%tau_z(i)**2)
93 
94  ! Mark sampling nodes with a -1 for debugging
95  this%wall_model%tau_field%x(this%wall_model%ind_r(i), &
96  this%wall_model%ind_s(i), &
97  this%wall_model%ind_t(i), &
98  this%wall_model%ind_e(i)) = -1.0_rp
99  this%wall_model%tau_field%x(this%msk(i),1,1,1) = magtau
100  end do
101 
102  call this%shear_stress_t%set_stress(this%wall_model%tau_x, &
103  this%wall_model%tau_z)
104  call this%shear_stress_t%apply_vector(x, y, z, n, t, tstep)
105 
106  end subroutine wall_model_bc_apply_vector
107 
110  subroutine wall_model_bc_apply_scalar_dev(this, x_d, t, tstep)
111  class(wall_model_bc_t), intent(inout), target :: this
112  type(c_ptr) :: x_d
113  real(kind=rp), intent(in), optional :: t
114  integer, intent(in), optional :: tstep
115 
116  call neko_error("wall_model_bc bc not implemented on the device")
117 
118  end subroutine wall_model_bc_apply_scalar_dev
119 
122  subroutine wall_model_bc_apply_vector_dev(this, x_d, y_d, z_d, t, tstep)
123  class(wall_model_bc_t), intent(inout), target :: this
124  type(c_ptr) :: x_d
125  type(c_ptr) :: y_d
126  type(c_ptr) :: z_d
127  real(kind=rp), intent(in), optional :: t
128  integer, intent(in), optional :: tstep
129 
130  call neko_error("wall_model_bc bc not implemented on the device")
131 
132  end subroutine wall_model_bc_apply_vector_dev
133 
136  subroutine wall_model_bc_init_wall_model_bc(this, coef)
137  class(wall_model_bc_t), intent(inout) :: this
138  type(coef_t), target, intent(in) :: coef
139 
140  call this%shear_stress_t%init_shear_stress(coef)
141 
142  end subroutine wall_model_bc_init_wall_model_bc
143 
144  end module wall_model_bc
__device__ void nonlinear_index(const int idx, const int lx, int *index)
Defines a boundary condition.
Definition: bc.f90:34
Coefficients.
Definition: coef.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Implements rough_log_law_t.
Defines a shear stress boundary condition for a vector field.
Implements spalding_t.
Definition: spalding.f90:35
Utilities.
Definition: utils.f90:35
Defines the wall_model_bc_t type.
subroutine wall_model_bc_apply_scalar(this, x, n, t, tstep)
Apply shear stress for a scalar field x.
subroutine wall_model_bc_init_wall_model_bc(this, coef)
Constructor.
subroutine wall_model_bc_apply_scalar_dev(this, x_d, t, tstep)
Boundary condition apply for a generic wall_model_bc condition to a vector x (device version)
subroutine wall_model_bc_apply_vector(this, x, y, z, n, t, tstep)
Boundary condition apply for a generic wall_model_bc condition to vectors x, y and z.
subroutine wall_model_bc_apply_vector_dev(this, x_d, y_d, z_d, t, tstep)
Boundary condition apply for a generic wall_model_bc condition to vectors x, y and z (device version)
Implements wall_model_t.
Definition: wall_model.f90:35
Base type for a boundary condition.
Definition: bc.f90:51
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition: coef.f90:55
Wall model based on the log-law for a rough wall. The formula defining the law is ....
A shear stress boundary condition.
Wall model based on Spalding's law of the wall. Reference: http://dx.doi.org/10.1115/1....
Definition: spalding.f90:53
Base abstract type for wall-stress models for wall-modelled LES.
Definition: wall_model.f90:54
A shear stress boundary condition, computing the stress values using a wall model.