Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
field_dirichlet.f90
Go to the documentation of this file.
1! Copyright (c) 2020-2024, 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
36 use coefs, only: coef_t
37 use dirichlet, only: dirichlet_t
38 use bc, only: bc_t
39 use bc_list, only : bc_list_t
40 use device, only: c_ptr, c_size_t
41 use utils, only: split_string
42 use field, only : field_t
43 use field_list, only : field_list_t
44 use math, only: masked_copy
46 use dofmap, only : dofmap_t
47 use utils, only: neko_error
48 use field_list, only : field_list_t
49 implicit none
50 private
51
62 type, public, extends(bc_t) :: field_dirichlet_t
65 type(field_t) :: field_bc
70 procedure(field_dirichlet_update), nopass, pointer :: update => null()
71 contains
73 procedure, pass(this) :: init_field => field_dirichlet_init
75 procedure, pass(this) :: apply_scalar => field_dirichlet_apply_scalar
77 procedure, pass(this) :: apply_vector => field_dirichlet_apply_vector
79 procedure, pass(this) :: apply_vector_dev => field_dirichlet_apply_vector_dev
81 procedure, pass(this) :: apply_scalar_dev => field_dirichlet_apply_scalar_dev
83 procedure, pass(this) :: free => field_dirichlet_free
84
85 end type field_dirichlet_t
86
96 abstract interface
97 subroutine field_dirichlet_update(dirichlet_field_list, dirichlet_bc_list, coef, t, tstep, which_solver)
98 import rp
99 import field_list_t
100 import bc_list_t
101 import coef_t
102 type(field_list_t), intent(inout) :: dirichlet_field_list
103 type(bc_list_t), intent(inout) :: dirichlet_bc_list
104 type(coef_t), intent(inout) :: coef
105 real(kind=rp), intent(in) :: t
106 integer, intent(in) :: tstep
107 character(len=*), intent(in) :: which_solver
108 end subroutine field_dirichlet_update
109 end interface
110
111 public :: field_dirichlet_update
112
113contains
114
117 subroutine field_dirichlet_init(this, bc_name)
118 class(field_dirichlet_t), target, intent(inout) :: this
119 character(len=*), intent(in) :: bc_name
120
121 call this%field_bc%init(this%dof, bc_name)
122 call this%field_list%init(1)
123 call this%field_list%assign_to_field(1, this%field_bc)
124
125 end subroutine field_dirichlet_init
126
128 subroutine field_dirichlet_free(this)
129 class(field_dirichlet_t), target, intent(inout) :: this
130
131 call this%free_base
132 call this%field_bc%free()
133 call this%field_list%free()
134
135 if (associated(this%update)) then
136 this%update => null()
137 end if
138
139 end subroutine field_dirichlet_free
140
146 subroutine field_dirichlet_apply_scalar(this, x, n, t, tstep)
147 class(field_dirichlet_t), intent(inout) :: this
148 integer, intent(in) :: n
149 real(kind=rp), intent(inout), dimension(n) :: x
150 real(kind=rp), intent(in), optional :: t
151 integer, intent(in), optional :: tstep
152
153 if (this%msk(0) .gt. 0) then
154 call masked_copy(x, this%field_bc%x, this%msk, n, this%msk(0))
155 end if
156
157 end subroutine field_dirichlet_apply_scalar
158
163 subroutine field_dirichlet_apply_scalar_dev(this, x_d, t, tstep)
164 class(field_dirichlet_t), intent(inout), target :: this
165 type(c_ptr) :: x_d
166 real(kind=rp), intent(in), optional :: t
167 integer, intent(in), optional :: tstep
168
169 if (this%msk(0) .gt. 0) then
170 call device_masked_copy(x_d, this%field_bc%x_d, this%msk_d, &
171 this%field_bc%dof%size(), this%msk(0))
172 end if
173
175
183 subroutine field_dirichlet_apply_vector(this, x, y, z, n, t, tstep)
184 class(field_dirichlet_t), intent(inout) :: this
185 integer, intent(in) :: n
186 real(kind=rp), intent(inout), dimension(n) :: x
187 real(kind=rp), intent(inout), dimension(n) :: y
188 real(kind=rp), intent(inout), dimension(n) :: z
189 real(kind=rp), intent(in), optional :: t
190 integer, intent(in), optional :: tstep
191
192 call neko_error("field_dirichlet cannot apply vector BCs.&
193&Use field_dirichlet_vector instead!")
194
195 end subroutine field_dirichlet_apply_vector
196
203 subroutine field_dirichlet_apply_vector_dev(this, x_d, y_d, z_d, t, tstep)
204 class(field_dirichlet_t), intent(inout), target :: this
205 type(c_ptr) :: x_d
206 type(c_ptr) :: y_d
207 type(c_ptr) :: z_d
208 real(kind=rp), intent(in), optional :: t
209 integer, intent(in), optional :: tstep
210
211 call neko_error("field_dirichlet cannot apply vector BCs.&
212&Use field_dirichlet_vector instead!")
213
215
216end module field_dirichlet
Abstract interface defining a dirichlet condition on a list of fields.
Defines a list of bc_t.
Definition bc_list.f90:34
Defines a boundary condition.
Definition bc.f90:34
Coefficients.
Definition coef.f90:34
subroutine, public device_masked_copy(a_d, b_d, mask_d, n, m)
Copy a masked vector .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
Defines a mapping of the degrees of freedom.
Definition dofmap.f90:35
Defines inflow dirichlet conditions.
subroutine field_dirichlet_apply_vector(this, x, y, z, n, t, tstep)
(No-op) Apply vector.
subroutine field_dirichlet_apply_scalar_dev(this, x_d, t, tstep)
Apply scalar (device).
subroutine field_dirichlet_apply_vector_dev(this, x_d, y_d, z_d, t, tstep)
(No-op) Apply vector (device).
subroutine field_dirichlet_apply_scalar(this, x, n, t, tstep)
Apply scalar by performing a masked copy.
subroutine field_dirichlet_init(this, bc_name)
Initializes thisfield_bc.
subroutine field_dirichlet_free(this)
Destructor. Currently thisfield_bc is being freed in fluid_scheme::free
Defines a field.
Definition field.f90:34
Definition math.f90:60
subroutine, public masked_copy(a, b, mask, n, m)
Copy a masked vector .
Definition math.f90:257
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Utilities.
Definition utils.f90:35
character(len=100) function, dimension(:), allocatable, public split_string(string, delimiter)
Split a string based on delimiter (tokenizer) OBS: very hacky, this should really be improved,...
Definition utils.f90:136
Base type for a boundary condition.
Definition bc.f90:51
A list of allocatable `bc_t`. Follows the standard interface of lists.
Definition bc_list.f90:46
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:44
User defined dirichlet condition, for which the user can work with an entire field....
field_list_t, To be able to group fields together