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 !$omp do
161 do i = 1, m
162 k = this%resolved_msk%get(i)
163 normal = this%n%x(:, i)
164 t1 = this%t1%x(:, i)
165 t2 = this%t2%x(:, i)
166
167 ! Normal component, will be reserved
168 u_n = x(k) * normal(1) + y(k) * normal(2) + z(k) * normal(3)
169 ! Project global input onto local tangential directions
170 g_t1 = this%value(1) * t1(1) + this%value(2) * t1(2) + &
171 this%value(3) * t1(3)
172 g_t2 = this%value(1) * t2(1) + this%value(2) * t2(2) + &
173 this%value(3) * t2(3)
174
175 ! Reconstruct in global coordinates
176 x(k) = u_n * normal(1) + g_t1 * t1(1) + g_t2 * t2(1)
177 y(k) = u_n * normal(2) + g_t1 * t1(2) + g_t2 * t2(2)
178 z(k) = u_n * normal(3) + g_t1 * t1(3) + g_t2 * t2(3)
179 end do
180 !$omp end do
181 end subroutine non_normal_apply_vector
182
188 subroutine non_normal_apply_scalar_dev(this, x_d, time, strong, strm)
189 class(non_normal_t), intent(inout), target :: this
190 type(c_ptr), intent(inout) :: x_d
191 type(time_state_t), intent(in), optional :: time
192 logical, intent(in), optional :: strong
193 type(c_ptr), intent(inout) :: strm
194 end subroutine non_normal_apply_scalar_dev
195
205 subroutine non_normal_apply_vector_dev(this, x_d, y_d, z_d, time, strong, &
206 strm)
207 class(non_normal_t), intent(inout), target :: this
208 type(c_ptr), intent(inout) :: x_d
209 type(c_ptr), intent(inout) :: y_d
210 type(c_ptr), intent(inout) :: z_d
211 type(time_state_t), intent(in), optional :: time
212 logical, intent(in), optional :: strong
213 type(c_ptr), intent(inout) :: strm
214 logical :: strong_
215 integer :: m
216
217 if (present(strong)) then
218 strong_ = strong
219 else
220 strong_ = .true.
221 end if
222
223 if (strong_) then
224 m = this%resolved_msk%size()
225 if (m .gt. 0) then
227 this%resolved_msk%get_d(), x_d, y_d, z_d, 0, 1, 1, &
228 this%n%x_d, this%t1%x_d, this%t2%x_d, this%value(1), &
229 this%value(2), this%value(3), m, strm)
230 end if
231 end if
232 end subroutine non_normal_apply_vector_dev
233
235 subroutine non_normal_finalize(this)
236 class(non_normal_t), target, intent(inout) :: this
237
238 call this%finalize_base()
239 end subroutine non_normal_finalize
240
242 subroutine non_normal_free(this)
243 class(non_normal_t), target, intent(inout) :: this
244
245 call this%free_mixed()
246 call this%free_base()
247 end subroutine non_normal_free
248end module non_normal
Defines a boundary condition.
Definition bc.f90:34
integer, parameter, public bc_mixed_constrains_tangent
Definition bc.f90:69
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:135
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.