Neko 1.99.9
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, bc_dirichlet
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)
88 this%bc_type = bc_dirichlet
90
93 subroutine zero_dirichlet_apply_scalar(this, x, n, time, strong)
94 class(zero_dirichlet_t), intent(inout) :: this
95 integer, intent(in) :: n
96 real(kind=rp), intent(inout), dimension(n) :: x
97 type(time_state_t), intent(in), optional :: time
98 logical, intent(in), optional :: strong
99 integer :: i, m, k
100 logical :: strong_
101
102 if (present(strong)) then
103 strong_ = strong
104 else
105 strong_ = .true.
106 end if
107
108 m = this%msk(0)
109
110 if (strong_) then
111 !$omp do
112 do i = 1, m
113 k = this%msk(i)
114 x(k) = 0d0
115 end do
116 !$omp end do
117 end if
118
119 end subroutine zero_dirichlet_apply_scalar
120
122 subroutine zero_dirichlet_apply_vector(this, x, y, z, n, time, strong)
123 class(zero_dirichlet_t), intent(inout) :: this
124 integer, intent(in) :: n
125 real(kind=rp), intent(inout), dimension(n) :: x
126 real(kind=rp), intent(inout), dimension(n) :: y
127 real(kind=rp), intent(inout), dimension(n) :: z
128 type(time_state_t), intent(in), optional :: time
129 logical, intent(in), optional :: strong
130 integer :: i, m, k
131 logical :: strong_
132
133 if (present(strong)) then
134 strong_ = strong
135 else
136 strong_ = .true.
137 end if
138
139 if (strong_) then
140 m = this%msk(0)
141 !$omp do
142 do i = 1, m
143 k = this%msk(i)
144 x(k) = 0d0
145 y(k) = 0d0
146 z(k) = 0d0
147 end do
148 !$omp end do
149 end if
150
151 end subroutine zero_dirichlet_apply_vector
152
154 subroutine zero_dirichlet_apply_scalar_dev(this, x_d, time, strong, strm)
155 class(zero_dirichlet_t), intent(inout), target :: this
156 type(c_ptr), intent(inout) :: x_d
157 type(time_state_t), intent(in), optional :: time
158 logical, intent(in), optional :: strong
159 type(c_ptr), intent(inout) :: strm
160 logical :: strong_
161
162 if (present(strong)) then
163 strong_ = strong
164 else
165 strong_ = .true.
166 end if
167
168 if (strong_ .and. (this%msk(0) .gt. 0)) then
169 call device_zero_dirichlet_apply_scalar(this%msk_d, x_d, &
170 size(this%msk), strm)
171 end if
172
174
176 subroutine zero_dirichlet_apply_vector_dev(this, x_d, y_d, z_d, time, &
177 strong, strm)
178 class(zero_dirichlet_t), intent(inout), target :: this
179 type(c_ptr), intent(inout) :: x_d
180 type(c_ptr), intent(inout) :: y_d
181 type(c_ptr), intent(inout) :: z_d
182 type(time_state_t), intent(in), optional :: time
183 logical, intent(in), optional :: strong
184 type(c_ptr), intent(inout) :: strm
185 logical :: strong_
186
187 if (present(strong)) then
188 strong_ = strong
189 else
190 strong_ = .true.
191 end if
192
193 if (strong_ .and. (this%msk(0) .gt. 0)) then
194 call device_zero_dirichlet_apply_vector(this%msk_d, x_d, y_d, z_d, &
195 size(this%msk), strm)
196 end if
197
199
201 subroutine zero_dirichlet_free(this)
202 class(zero_dirichlet_t), target, intent(inout) :: this
203
204 call this%free_base()
205
206 end subroutine zero_dirichlet_free
207
209 subroutine zero_dirichlet_finalize(this)
210 class(zero_dirichlet_t), target, intent(inout) :: this
211 call this%finalize_base()
212 end subroutine zero_dirichlet_finalize
213
214end module zero_dirichlet
Defines a boundary condition.
Definition bc.f90:34
integer, parameter, public bc_dirichlet
Supported boundary condition types. The values are set in order of precedence for global resolution....
Definition bc.f90:66
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:14
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_apply_vector(this, x, y, z, n, time, strong)
Apply boundary condition to a vector field.
subroutine zero_dirichlet_finalize(this)
Finalize.
Base type for a boundary condition.
Definition bc.f90:72
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:93
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...