Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
non_normal.f90
Go to the documentation of this file.
1! Copyright (c) 2020-2021, 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 json_module, only : json_file
37 use mixed_bc, only : mixed_bc_t
38 use num_types, only : rp
40 use coefs, only : coef_t
42 use utils, only : neko_error
43 use time_state, only : time_state_t
44 use, intrinsic :: iso_c_binding, only : c_ptr
45 implicit none
46 private
47
53 type, public, extends(mixed_bc_t) :: non_normal_t
55 real(kind=rp) :: value(3) = 0.0_rp
56 contains
58 procedure, pass(this) :: apply_scalar => non_normal_apply_scalar
60 procedure, pass(this) :: apply_vector => non_normal_apply_vector
62 procedure, pass(this) :: apply_scalar_dev => non_normal_apply_scalar_dev
64 procedure, pass(this) :: apply_vector_dev => non_normal_apply_vector_dev
66 procedure, pass(this) :: init => non_normal_init
68 procedure, pass(this) :: init_from_components => &
71 procedure, pass(this) :: free => non_normal_free
73 procedure, pass(this) :: finalize => non_normal_finalize
74 end type non_normal_t
75
76contains
77
81 subroutine non_normal_init(this, coef, json)
82 class(non_normal_t), target, intent(inout) :: this
83 type(coef_t), target, intent(in) :: coef
84 type(json_file), intent(inout) ::json
85 real(kind=rp), allocatable :: value(:)
86 real(kind=rp) :: value_3(3)
87 logical :: found
88 integer :: var_type
89
90 value_3 = 0.0_rp
91 call json_get_or_lookup(json, "value", value)
92 if (size(value) .ne. 3) then
93 call neko_error("The non_normal boundary condition requires a " // &
94 "3-component value vector.")
95 end if
96 value_3 = value
97 call this%init_from_components(coef, value_3)
98 end subroutine non_normal_init
99
103 subroutine non_normal_init_from_components(this, coef, value)
104 class(non_normal_t), target, intent(inout) :: this
105 type(coef_t), target, intent(in) :: coef
106 real(kind=rp), intent(in) :: value(3)
107
108 call this%free()
109 call this%init_base(coef)
110 this%bc_type = bc_mixed_constrains_tangent
111 this%value = value
113
119 subroutine non_normal_apply_scalar(this, x, n, time, strong)
120 class(non_normal_t), intent(inout) :: this
121 integer, intent(in) :: n
122 real(kind=rp), intent(inout), dimension(n) :: x
123 type(time_state_t), intent(in), optional :: time
124 logical, intent(in), optional :: strong
125 end subroutine non_normal_apply_scalar
126
135 subroutine non_normal_apply_vector(this, x, y, z, n, time, strong)
136 class(non_normal_t), intent(inout) :: this
137 integer, intent(in) :: n
138 real(kind=rp), intent(inout), dimension(n) :: x
139 real(kind=rp), intent(inout), dimension(n) :: y
140 real(kind=rp), intent(inout), dimension(n) :: z
141 type(time_state_t), intent(in), optional :: time
142 logical, intent(in), optional :: strong
143 logical :: strong_
144 integer :: i, m, k
145 real(kind=rp) :: normal(3), t1(3), t2(3)
146 real(kind=rp) :: u_n, g_t1, g_t2
147
148 ! Reads coef%nx, ny and nz directly, never through get_normal()
149 call this%coef%require_facets('non_normal')
150
151 if (present(strong)) then
152 strong_ = strong
153 else
154 strong_ = .true.
155 end if
156
157 if (.not. strong_) return
158
159 m = this%resolved_msk%size()
160 do i = 1, m
161 k = this%resolved_msk%get(i)
162 normal = this%n%x(:, i)
163 t1 = this%t1%x(:, i)
164 t2 = this%t2%x(:, i)
165
166 ! Normal component, will be reserved
167 u_n = x(k) * normal(1) + y(k) * normal(2) + z(k) * normal(3)
168 ! Project global input onto local tangential directions
169 g_t1 = this%value(1) * t1(1) + this%value(2) * t1(2) + &
170 this%value(3) * t1(3)
171 g_t2 = this%value(1) * t2(1) + this%value(2) * t2(2) + &
172 this%value(3) * t2(3)
173
174 ! Reconstruct in global coordinates
175 x(k) = u_n * normal(1) + g_t1 * t1(1) + g_t2 * t2(1)
176 y(k) = u_n * normal(2) + g_t1 * t1(2) + g_t2 * t2(2)
177 z(k) = u_n * normal(3) + g_t1 * t1(3) + g_t2 * t2(3)
178 end do
179 end subroutine non_normal_apply_vector
180
186 subroutine non_normal_apply_scalar_dev(this, x_d, time, strong, strm)
187 class(non_normal_t), intent(inout), target :: this
188 type(c_ptr), intent(inout) :: x_d
189 type(time_state_t), intent(in), optional :: time
190 logical, intent(in), optional :: strong
191 type(c_ptr), intent(inout) :: strm
192 end subroutine non_normal_apply_scalar_dev
193
203 subroutine non_normal_apply_vector_dev(this, x_d, y_d, z_d, time, strong, &
204 strm)
205 class(non_normal_t), intent(inout), target :: this
206 type(c_ptr), intent(inout) :: x_d
207 type(c_ptr), intent(inout) :: y_d
208 type(c_ptr), intent(inout) :: z_d
209 type(time_state_t), intent(in), optional :: time
210 logical, intent(in), optional :: strong
211 type(c_ptr), intent(inout) :: strm
212 logical :: strong_
213 integer :: m
214
215 if (present(strong)) then
216 strong_ = strong
217 else
218 strong_ = .true.
219 end if
220
221 if (strong_) then
222 m = this%resolved_msk%size()
223 if (m .gt. 0) then
225 this%resolved_msk%get_d(), x_d, y_d, z_d, 0, 1, 1, &
226 this%n%x_d, this%t1%x_d, this%t2%x_d, this%value(1), &
227 this%value(2), this%value(3), m, strm)
228 end if
229 end if
230 end subroutine non_normal_apply_vector_dev
231
233 subroutine non_normal_finalize(this)
234 class(non_normal_t), target, intent(inout) :: this
235
236 call this%finalize_base()
237 end subroutine non_normal_finalize
238
240 subroutine non_normal_free(this)
241 class(non_normal_t), target, intent(inout) :: this
242
243 call this%free_mixed()
244 call this%free_base()
245 end subroutine non_normal_free
246end module non_normal
Defines a boundary condition.
Definition bc.f90:34
integer, parameter, public bc_mixed_constrains_tangent
Definition bc.f90:68
Coefficients.
Definition coef.f90:34
Device wrappers for basis-aware mixed boundary-condition constraint kernels. These routines operate o...
subroutine, public device_constrain_mixed_bc_set_const(mixed_msk, x, y, z, constraint_n, constraint_t1, constraint_t2, n, t1, t2, value_n, value_t1, value_t2, m, strm)
Constrain mixed-boundary projections by assigning prescribed local components derived from a constant...
Utilities for retrieving parameters from the case files.
Implements mixed_bc_t.
Definition mixed_bc.f90:31
Implements non_normal_t.
subroutine non_normal_finalize(this)
Finalize the boundary condition.
subroutine non_normal_init_from_components(this, coef, value)
Construct the boundary condition from a uniform global vector.
subroutine non_normal_apply_scalar_dev(this, x_d, time, strong, strm)
No-op scalar application on the device.
subroutine non_normal_init(this, coef, json)
Construct the boundary condition from JSON.
subroutine non_normal_apply_scalar(this, x, n, time, strong)
No-op scalar application.
subroutine non_normal_free(this)
Free the boundary condition and its mixed-bc storage.
subroutine non_normal_apply_vector(this, x, y, z, n, time, strong)
Strong application preserving the normal component while enforcing the tangential projections of the ...
subroutine non_normal_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
Apply the tangential components of the prescribed vector on the device.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:93
Base type for mixed boundary conditions that need projector-provided local-basis data on the physical...
Definition mixed_bc.f90:50
Mixed Dirichlet condition constraining the tangential vector components.
A struct that contains all info about the time, expand as needed.