Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
zero_dirichlet.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!
37 use num_types, only : rp
38 use bc, only : bc_t
39 use, intrinsic :: iso_c_binding, only : c_ptr
40 use coefs, only : coef_t
41 use json_module, only : json_file
42 use time_state, only : time_state_t
43 implicit none
44 private
45
49 type, public, extends(bc_t) :: zero_dirichlet_t
50 contains
51 procedure, pass(this) :: apply_scalar => zero_dirichlet_apply_scalar
52 procedure, pass(this) :: apply_vector => zero_dirichlet_apply_vector
53 procedure, pass(this) :: apply_scalar_dev => &
55 procedure, pass(this) :: apply_vector_dev => &
58 procedure, pass(this) :: init => zero_dirichlet_init
60 procedure, pass(this) :: init_from_components => &
63 procedure, pass(this) :: free => zero_dirichlet_free
65 procedure, pass(this) :: finalize => zero_dirichlet_finalize
66 end type zero_dirichlet_t
67
68contains
69
73 subroutine zero_dirichlet_init(this, coef, json)
74 class(zero_dirichlet_t), intent(inout), target :: this
75 type(coef_t), target, intent(in) :: coef
76 type(json_file), intent(inout) :: json
77
78 call this%init_from_components(coef)
79 end subroutine zero_dirichlet_init
80
84 class(zero_dirichlet_t), intent(inout), target :: this
85 type(coef_t), target, intent(in) :: coef
86
87 call this%init_base(coef)
89
92 subroutine zero_dirichlet_apply_scalar(this, x, n, time, strong)
93 class(zero_dirichlet_t), intent(inout) :: this
94 integer, intent(in) :: n
95 real(kind=rp), intent(inout), dimension(n) :: x
96 type(time_state_t), intent(in), optional :: time
97 logical, intent(in), optional :: strong
98 integer :: i, m, k
99 logical :: strong_
100
101 if (present(strong)) then
102 strong_ = strong
103 else
104 strong_ = .true.
105 end if
106
107 m = this%msk(0)
108
109 if (strong_) then
110 !$omp do
111 do i = 1, m
112 k = this%msk(i)
113 x(k) = 0d0
114 end do
115 !$omp end do
116 end if
117
118 end subroutine zero_dirichlet_apply_scalar
119
121 subroutine zero_dirichlet_apply_vector(this, x, y, z, n, time, strong)
122 class(zero_dirichlet_t), intent(inout) :: this
123 integer, intent(in) :: n
124 real(kind=rp), intent(inout), dimension(n) :: x
125 real(kind=rp), intent(inout), dimension(n) :: y
126 real(kind=rp), intent(inout), dimension(n) :: z
127 type(time_state_t), intent(in), optional :: time
128 logical, intent(in), optional :: strong
129 integer :: i, m, k
130 logical :: strong_
131
132 if (present(strong)) then
133 strong_ = strong
134 else
135 strong_ = .true.
136 end if
137
138 if (strong_) then
139 m = this%msk(0)
140 !$omp do
141 do i = 1, m
142 k = this%msk(i)
143 x(k) = 0d0
144 y(k) = 0d0
145 z(k) = 0d0
146 end do
147 !$omp end do
148 end if
149
150 end subroutine zero_dirichlet_apply_vector
151
153 subroutine zero_dirichlet_apply_scalar_dev(this, x_d, time, strong, strm)
154 class(zero_dirichlet_t), intent(inout), target :: this
155 type(c_ptr), intent(inout) :: x_d
156 type(time_state_t), intent(in), optional :: time
157 logical, intent(in), optional :: strong
158 type(c_ptr), intent(inout) :: strm
159 logical :: strong_
160
161 if (present(strong)) then
162 strong_ = strong
163 else
164 strong_ = .true.
165 end if
166
167 if (strong_ .and. (this%msk(0) .gt. 0)) then
168 call device_zero_dirichlet_apply_scalar(this%msk_d, x_d, &
169 size(this%msk), strm)
170 end if
171
173
175 subroutine zero_dirichlet_apply_vector_dev(this, x_d, y_d, z_d, time, &
176 strong, strm)
177 class(zero_dirichlet_t), intent(inout), target :: this
178 type(c_ptr), intent(inout) :: x_d
179 type(c_ptr), intent(inout) :: y_d
180 type(c_ptr), intent(inout) :: z_d
181 type(time_state_t), intent(in), optional :: time
182 logical, intent(in), optional :: strong
183 type(c_ptr), intent(inout) :: strm
184 logical :: strong_
185
186 if (present(strong)) then
187 strong_ = strong
188 else
189 strong_ = .true.
190 end if
191
192 if (strong_ .and. (this%msk(0) .gt. 0)) then
193 call device_zero_dirichlet_apply_vector(this%msk_d, x_d, y_d, z_d, &
194 size(this%msk), strm)
195 end if
196
198
200 subroutine zero_dirichlet_free(this)
201 class(zero_dirichlet_t), target, intent(inout) :: this
202
203 call this%free_base()
204
205 end subroutine zero_dirichlet_free
206
208 subroutine zero_dirichlet_finalize(this, only_facets)
209 class(zero_dirichlet_t), target, intent(inout) :: this
210 logical, optional, intent(in) :: only_facets
211 logical :: only_facets_
212
213 if (present(only_facets)) then
214 only_facets_ = only_facets
215 else
216 only_facets_ = .false.
217 end if
218
219 call this%finalize_base(only_facets_)
220 end subroutine zero_dirichlet_finalize
221
222end module zero_dirichlet
Defines a boundary condition.
Definition bc.f90:34
Coefficients.
Definition coef.f90:34
subroutine, public device_zero_dirichlet_apply_vector(msk, x, y, z, m, strm)
subroutine, public device_zero_dirichlet_apply_scalar(msk, x, m, strm)
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Module with things related to the simulation time.
Defines a zero-valued Dirichlet boundary condition.
subroutine zero_dirichlet_apply_scalar(this, x, n, time, strong)
Apply boundary condition to a scalar field. to a vector x.
subroutine zero_dirichlet_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
Apply boundary condition to a vector field, device version.
subroutine zero_dirichlet_init(this, coef, json)
Constructor.
subroutine zero_dirichlet_apply_scalar_dev(this, x_d, time, strong, strm)
Apply boundary condition to a scalar field, device version.
subroutine zero_dirichlet_free(this)
Destructor.
subroutine zero_dirichlet_init_from_components(this, coef)
Constructor.
subroutine zero_dirichlet_finalize(this, only_facets)
Finalize.
subroutine zero_dirichlet_apply_vector(this, x, y, z, n, time, strong)
Apply boundary condition to a vector field.
Base type for a boundary condition.
Definition bc.f90:62
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:63
A struct that contains all info about the time, expand as needed.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...