Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
symmetry.f90
Go to the documentation of this file.
1! Copyright (c) 2020-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!
35 use num_types, only : rp
37 use mixed_bc, only : mixed_bc_t
39 use coefs, only : coef_t
40 use json_module, only : json_file
41 use, intrinsic :: iso_c_binding, only : c_ptr
42 use time_state, only : time_state_t
43 implicit none
44 private
45
50 type, public, extends(mixed_bc_t) :: symmetry_t
51 contains
53 procedure, pass(this) :: apply_scalar => symmetry_apply_scalar
55 procedure, pass(this) :: apply_vector => symmetry_apply_vector
57 procedure, pass(this) :: apply_scalar_dev => symmetry_apply_scalar_dev
59 procedure, pass(this) :: apply_vector_dev => symmetry_apply_vector_dev
61 procedure, pass(this) :: init => symmetry_init
63 procedure, pass(this) :: init_from_components => &
66 procedure, pass(this) :: free => symmetry_free
68 procedure, pass(this) :: finalize => symmetry_finalize
69 end type symmetry_t
70
71contains
72
76 subroutine symmetry_init(this, coef, json)
77 class(symmetry_t), intent(inout), target :: this
78 type(coef_t), target, intent(in) :: coef
79 type(json_file), intent(inout) :: json
80
81 call this%init_from_components(coef)
82 end subroutine symmetry_init
83
86 subroutine symmetry_init_from_components(this, coef)
87 class(symmetry_t), intent(inout), target :: this
88 type(coef_t), target, intent(in) :: coef
89
90 call this%free()
91
92 call this%init_base(coef)
93 this%bc_type = bc_mixed_constrains_normal
95
97 subroutine symmetry_finalize(this)
98 class(symmetry_t), target, intent(inout) :: this
99
100 ! Reads coef%nx, ny and nz directly, never through get_normal()
101 call this%coef%require_facets('symmetry')
102
103 call this%finalize_base()
104 end subroutine symmetry_finalize
105
111 subroutine symmetry_apply_scalar(this, x, n, time, strong)
112 class(symmetry_t), intent(inout) :: this
113 integer, intent(in) :: n
114 real(kind=rp), intent(inout), dimension(n) :: x
115 type(time_state_t), intent(in), optional :: time
116 logical, intent(in), optional :: strong
117 end subroutine symmetry_apply_scalar
118
128 subroutine symmetry_apply_vector(this, x, y, z, n, time, strong)
129 class(symmetry_t), intent(inout) :: this
130 integer, intent(in) :: n
131 real(kind=rp), intent(inout), dimension(n) :: x
132 real(kind=rp), intent(inout), dimension(n) :: y
133 real(kind=rp), intent(inout), dimension(n) :: z
134 type(time_state_t), intent(in), optional :: time
135 logical, intent(in), optional :: strong
136 logical :: strong_
137 integer :: i, m, k
138 real(kind=rp) :: normal(3), u_n
139
140 if (present(strong)) then
141 strong_ = strong
142 else
143 strong_ = .true.
144 end if
145
146 if (strong_) then
147 m = this%resolved_msk%size()
148
149 do i = 1, m
150 k = this%resolved_msk%get(i)
151 normal = this%n%x(:,i)
152 u_n = x(k) * normal(1) + y(k) * normal(2) + z(k) * normal(3)
153
154 x(k) = x(k) - u_n * normal(1)
155 y(k) = y(k) - u_n * normal(2)
156 z(k) = z(k) - u_n * normal(3)
157 end do
158 end if
159 end subroutine symmetry_apply_vector
160
166 subroutine symmetry_apply_scalar_dev(this, x_d, time, strong, strm)
167 class(symmetry_t), intent(inout), target :: this
168 type(c_ptr), intent(inout) :: x_d
169 type(time_state_t), intent(in), optional :: time
170 logical, intent(in), optional :: strong
171 type(c_ptr), intent(inout) :: strm
172 end subroutine symmetry_apply_scalar_dev
173
183 subroutine symmetry_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
184 class(symmetry_t), intent(inout), target :: this
185 type(c_ptr), intent(inout) :: x_d
186 type(c_ptr), intent(inout) :: y_d
187 type(c_ptr), intent(inout) :: z_d
188 type(time_state_t), intent(in), optional :: time
189 logical, intent(in), optional :: strong
190 type(c_ptr), intent(inout) :: strm
191 logical :: strong_
192 integer :: m
193
194 if (present(strong)) then
195 strong_ = strong
196 else
197 strong_ = .true.
198 end if
199
200 if (strong_) then
201 m = this%resolved_msk%size()
202 if (m .gt. 0) then
203 call device_constrain_mixed_bc_zero(this%resolved_msk%get_d(), &
204 x_d, y_d, z_d, 1, 0, 0, this%n%x_d, this%t1%x_d, &
205 this%t2%x_d, m, strm)
206 end if
207 end if
208 end subroutine symmetry_apply_vector_dev
209
211 subroutine symmetry_free(this)
212 class(symmetry_t), target, intent(inout) :: this
213
214 call this%free_mixed()
215 call this%free_base()
216 end subroutine symmetry_free
217
218end module symmetry
Defines a boundary condition.
Definition bc.f90:34
integer, parameter, public bc_mixed_constrains_normal
Definition bc.f90:67
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_zero(mixed_msk, x, y, z, constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm)
Constrain mixed-boundary projections by zeroing the selected local components on the device.
Implements mixed_bc_t.
Definition mixed_bc.f90:31
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Implements symmetry_t.
Definition symmetry.f90:34
subroutine symmetry_apply_vector(this, x, y, z, n, time, strong)
Remove the normal component on the CPU.
Definition symmetry.f90:129
subroutine symmetry_apply_scalar(this, x, n, time, strong)
No-op scalar application.
Definition symmetry.f90:112
subroutine symmetry_init_from_components(this, coef)
Construct the boundary condition from its components.
Definition symmetry.f90:87
subroutine symmetry_init(this, coef, json)
Construct the boundary condition from JSON.
Definition symmetry.f90:77
subroutine symmetry_apply_scalar_dev(this, x_d, time, strong, strm)
No-op scalar application on the device.
Definition symmetry.f90:167
subroutine symmetry_finalize(this)
Finalize the boundary condition.
Definition symmetry.f90:98
subroutine symmetry_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
Remove the normal component on the device.
Definition symmetry.f90:184
subroutine symmetry_free(this)
Free the boundary condition and its mixed-bc storage.
Definition symmetry.f90:212
Module with things related to the simulation time.
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
Symmetry boundary condition constraining the normal vector component.
Definition symmetry.f90:50
A struct that contains all info about the time, expand as needed.