Loading [MathJax]/extensions/tex2jax.js
Neko 0.9.99
A portable framework for high-order spectral element flow simulations
All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Pages
dirichlet.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!
36 use num_types, only : rp
37 use bc, only : bc_t
38 use coefs, only : coef_t
39 use json_module, only : json_file
40 use json_utils, only : json_get
41 use, intrinsic :: iso_c_binding, only : c_ptr
42 implicit none
43 private
44
47 type, public, extends(bc_t) :: dirichlet_t
48 real(kind=rp), private :: g
49 contains
50 procedure, pass(this) :: apply_scalar => dirichlet_apply_scalar
51 procedure, pass(this) :: apply_vector => dirichlet_apply_vector
52 procedure, pass(this) :: apply_scalar_dev => dirichlet_apply_scalar_dev
53 procedure, pass(this) :: apply_vector_dev => dirichlet_apply_vector_dev
54 procedure, pass(this) :: set_g => dirichlet_set_g
56 procedure, pass(this) :: init => dirichlet_init
58 procedure, pass(this) :: init_from_components => &
61 procedure, pass(this) :: free => dirichlet_free
63 procedure, pass(this) :: finalize => dirichlet_finalize
64 end type dirichlet_t
65
66contains
67
71 subroutine dirichlet_init(this, coef, json)
72 class(dirichlet_t), intent(inout), target :: this
73 type(coef_t), intent(in) :: coef
74 type(json_file), intent(inout) ::json
75 real(kind=rp) :: g
76
77 call this%init_base(coef)
78 call json_get(json , "value", g)
79
80 this%g = g
81 end subroutine dirichlet_init
82
86 subroutine dirichlet_init_from_components(this, coef, g)
87 class(dirichlet_t), intent(inout), target :: this
88 type(coef_t), intent(in) :: coef
89 real(kind=rp), intent(in) :: g
90
91 call this%init_base(coef)
92 this%g = g
94
97 subroutine dirichlet_apply_scalar(this, x, n, t, tstep, strong)
98 class(dirichlet_t), intent(inout) :: this
99 integer, intent(in) :: n
100 real(kind=rp), intent(inout), dimension(n) :: x
101 real(kind=rp), intent(in), optional :: t
102 integer, intent(in), optional :: tstep
103 logical, intent(in), optional :: strong
104 integer :: i, m, k
105 logical :: strong_ = .true.
106
107 if (present(strong)) strong_ = strong
108
109 if (strong_) then
110 m = this%msk(0)
111 do i = 1, m
112 k = this%msk(i)
113 x(k) = this%g
114 end do
115 end if
116 end subroutine dirichlet_apply_scalar
117
120 subroutine dirichlet_apply_vector(this, x, y, z, n, t, tstep, strong)
121 class(dirichlet_t), intent(inout) :: this
122 integer, intent(in) :: n
123 real(kind=rp), intent(inout), dimension(n) :: x
124 real(kind=rp), intent(inout), dimension(n) :: y
125 real(kind=rp), intent(inout), dimension(n) :: z
126 real(kind=rp), intent(in), optional :: t
127 integer, intent(in), optional :: tstep
128 logical, intent(in), optional :: strong
129 integer :: i, m, k
130 logical :: strong_ = .true.
131
132 if (present(strong)) strong_ = strong
133
134 if (strong_) then
135 m = this%msk(0)
136 do i = 1, m
137 k = this%msk(i)
138 x(k) = this%g
139 y(k) = this%g
140 z(k) = this%g
141 end do
142 end if
143
144 end subroutine dirichlet_apply_vector
145
148 subroutine dirichlet_apply_scalar_dev(this, x_d, t, tstep, strong)
149 class(dirichlet_t), intent(inout), target :: this
150 type(c_ptr) :: x_d
151 real(kind=rp), intent(in), optional :: t
152 integer, intent(in), optional :: tstep
153 logical, intent(in), optional :: strong
154 logical :: strong_ = .true.
155
156 if (present(strong)) strong_ = strong
157
158
159 if (strong_ .and. this%msk(0) .gt. 0) then
160 call device_dirichlet_apply_scalar(this%msk_d, x_d, &
161 this%g, size(this%msk))
162 end if
163
164 end subroutine dirichlet_apply_scalar_dev
165
168 subroutine dirichlet_apply_vector_dev(this, x_d, y_d, z_d, t, tstep, strong)
169 class(dirichlet_t), intent(inout), target :: this
170 type(c_ptr) :: x_d
171 type(c_ptr) :: y_d
172 type(c_ptr) :: z_d
173 real(kind=rp), intent(in), optional :: t
174 integer, intent(in), optional :: tstep
175 logical, intent(in), optional :: strong
176 logical :: strong_ = .true.
177
178 if (present(strong)) strong_ = strong
179
180 if (strong_ .and. this%msk(0) .gt. 0) then
181 call device_dirichlet_apply_vector(this%msk_d, x_d, y_d, z_d, this%g, &
182 size(this%msk))
183 end if
184
185 end subroutine dirichlet_apply_vector_dev
186
188 subroutine dirichlet_set_g(this, g)
189 class(dirichlet_t), intent(inout) :: this
190 real(kind=rp), intent(in) :: g
191
192 this%g = g
193
194 end subroutine dirichlet_set_g
195
197 subroutine dirichlet_free(this)
198 class(dirichlet_t), target, intent(inout) :: this
199
200 call this%free_base
201
202 end subroutine dirichlet_free
203
205 subroutine dirichlet_finalize(this)
206 class(dirichlet_t), target, intent(inout) :: this
207
208 call this%finalize_base()
209 end subroutine dirichlet_finalize
210
211end module dirichlet
Retrieves a parameter by name or throws an error.
Defines a boundary condition.
Definition bc.f90:34
Coefficients.
Definition coef.f90:34
subroutine, public device_dirichlet_apply_scalar(msk, x, g, m)
subroutine, public device_dirichlet_apply_vector(msk, x, y, z, g, m)
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
subroutine dirichlet_apply_vector(this, x, y, z, n, t, tstep, strong)
Boundary condition apply for a generic Dirichlet condition to vectors x, y and z.
subroutine dirichlet_apply_scalar(this, x, n, t, tstep, strong)
Boundary condition apply for a generic Dirichlet condition to a vector x.
Definition dirichlet.f90:98
subroutine dirichlet_free(this)
Destructor.
subroutine dirichlet_init_from_components(this, coef, g)
Constructor from components.
Definition dirichlet.f90:87
subroutine dirichlet_apply_vector_dev(this, x_d, y_d, z_d, t, tstep, strong)
Boundary condition apply for a generic Dirichlet condition to vectors x, y and z (device version)
subroutine dirichlet_finalize(this)
Finalize.
subroutine dirichlet_apply_scalar_dev(this, x_d, t, tstep, strong)
Boundary condition apply for a generic Dirichlet condition to a vector x (device version)
subroutine dirichlet_init(this, coef, json)
Constructor from JSON.
Definition dirichlet.f90:72
subroutine dirichlet_set_g(this, g)
Set value of .
Utilities for retrieving parameters from the case files.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Base type for a boundary condition.
Definition bc.f90:57
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:55
Generic Dirichlet boundary condition on .
Definition dirichlet.f90:47