Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fluid_pnpn_bc_fctry.f90
Go to the documentation of this file.
1
2! Copyright (c) 2024, The Neko Authors
3! All rights reserved.
4!
5! Redistribution and use in source and binary forms, with or without
6! modification, are permitted provided that the following conditions
7! are met:
8!
9! * Redistributions of source code must retain the above copyright
10! notice, this list of conditions and the following disclaimer.
11!
12! * Redistributions in binary form must reproduce the above
13! copyright notice, this list of conditions and the following
14! disclaimer in the documentation and/or other materials provided
15! with the distribution.
16!
17! * Neither the name of the authors nor the names of its
18! contributors may be used to endorse or promote products derived
19! from this software without specific prior written permission.
20!
21! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32! POSSIBILITY OF SUCH DAMAGE.
33!
34!
36submodule(fluid_pnpn) fluid_pnpn_bc_fctry
37 use user_intf, only : user_t
38 use utils, only : neko_type_error
40 use inflow, only : inflow_t
41 use blasius, only : blasius_t
42 use dirichlet, only : dirichlet_t
44 use symmetry, only : symmetry_t
45 use non_normal, only : non_normal_t
47 implicit none
48
49 ! List of all possible types created by the boundary condition factories
50 character(len=25) :: FLUID_PNPN_KNOWN_BCS(14) = [character(len=25) :: &
51 "symmetry", &
52 "velocity_value", &
53 "no_slip", &
54 "outflow", &
55 "normal_outflow", &
56 "outflow+user", &
57 "normal_outflow+user", &
58 "outflow+dong", &
59 "normal_outflow+dong", &
60 "shear_stress", &
61 "user_velocity", &
62 "user_pressure", &
63 "blasius_profile", &
64 "wall_model"]
65
66contains
67
74 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
75 class(bc_t), pointer, intent(inout) :: object
76 type(fluid_pnpn_t), intent(in) :: scheme
77 type(json_file), intent(inout) :: json
78 type(coef_t), target, intent(in) :: coef
79 type(user_t), intent(in) :: user
80 character(len=:), allocatable :: type
81 integer :: i, j, k
82 integer, allocatable :: zone_indices(:)
83 character(len=:), allocatable :: default_name
84 character(len=64) :: buf
85
86 if (associated(object)) then
87 call object%free()
88 nullify(object)
89 end if
90
91 call json_get(json, "type", type)
92
93 select case (trim(type))
94 case ("outflow", "normal_outflow")
95 allocate(zero_dirichlet_t::object)
96
97 case ("outflow+dong", "normal_outflow+dong")
98 allocate(dong_outflow_t::object)
99
100 case ("user_pressure", "outflow+user", "normal_outflow+user")
101 allocate(field_dirichlet_t::object)
102 select type (obj => object)
103 type is (field_dirichlet_t)
104 obj%update => user%dirichlet_conditions
105 call json%add("field_name", scheme%p%name)
106 end select
107
108 case default
109 do i = 1, size(fluid_pnpn_known_bcs)
110 if (trim(type) .eq. trim(fluid_pnpn_known_bcs(i))) return
111 end do
112 call neko_type_error("fluid_pnpn boundary conditions", type, &
113 FLUID_PNPN_KNOWN_BCS)
114 end select
115
116 call json_get_or_lookup(json, "zone_indices", zone_indices)
117 call object%init(coef, json)
118
119 do i = 1, size(zone_indices)
120 call object%mark_zone(coef%msh%labeled_zones(zone_indices(i)))
121 end do
122
123 write(buf,'("pressure_bc_",I0)') zone_indices(1)
124 default_name = trim(buf)
125 call json_get_or_default(json, "name", object%name, default_name)
126 object%zone_indices = zone_indices
127 call object%finalize()
128
129 ! All pressure bcs are currently strong, so for all of them we
130 ! mark with value 1 in the mesh
131 do i = 1, size(zone_indices)
132 do j = 1, scheme%msh%nelv
133 do k = 1, 2 * scheme%msh%gdim
134 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
135 scheme%msh%facet_type(k, j) = 1
136 end if
137 end do
138 end do
139 end do
140
141 if (allocated(type)) then
142 deallocate(type)
143 end if
144
145 if (allocated(zone_indices)) then
146 deallocate(zone_indices)
147 end if
148 end subroutine pressure_bc_factory
149
156 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
157 class(bc_t), pointer, intent(inout) :: object
158 type(fluid_pnpn_t), intent(inout) :: scheme
159 type(json_file), intent(inout) :: json
160 type(coef_t), target, intent(in) :: coef
161 type(user_t), intent(in) :: user
162 character(len=:), allocatable :: type
163 integer :: i, j, k
164 integer, allocatable :: zone_indices(:)
165 character(len=:), allocatable :: default_name
166 character(len=64) :: buf
167
168 call json_get(json, "type", type)
169
170 select case (trim(type))
171 case ("symmetry")
172 allocate(symmetry_t::object)
173 case ("velocity_value")
174 allocate(inflow_t::object)
175 case ("no_slip")
176 allocate(zero_dirichlet_t::object)
177 case ("normal_outflow", "normal_outflow+dong", "normal_outflow+user")
178 allocate(non_normal_t::object)
179 case ("blasius_profile")
180 allocate(blasius_t::object)
181 case ("shear_stress")
182 allocate(shear_stress_t::object)
183 case ("wall_model")
184 allocate(wall_model_bc_t::object)
185 ! Kind of hack, but OK for now
186 call json%add("scheme_name", scheme%name)
187
188 case ("user_velocity")
189 allocate(field_dirichlet_vector_t::object)
190 select type (obj => object)
192 obj%update => user%dirichlet_conditions
193 end select
194
195 case default
196 do i = 1, size(fluid_pnpn_known_bcs)
197 if (trim(type) .eq. trim(fluid_pnpn_known_bcs(i))) return
198 end do
199 call neko_type_error("fluid_pnpn boundary conditions", type, &
200 FLUID_PNPN_KNOWN_BCS)
201 end select
202
203 call json_get_or_lookup(json, "zone_indices", zone_indices)
204 call object%init(coef, json)
205 do i = 1, size(zone_indices)
206 call object%mark_zone(coef%msh%labeled_zones(zone_indices(i)))
207 end do
208
209 write(buf,'("velocity_bc_",I0)') zone_indices(1)
210 default_name = trim(buf)
211 call json_get_or_default(json, "name", object%name, default_name)
212 object%zone_indices = zone_indices
213 call object%finalize()
214
215 ! Exclude these two because they are bcs for the residual, not velocity
216 if (trim(type) .ne. "normal_outflow" .and. &
217 trim(type) .ne. "normal_outflow+dong") then
218 do i = 1, size(zone_indices)
219 do j = 1, scheme%msh%nelv
220 do k = 1, 2 * scheme%msh%gdim
221 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
222 scheme%msh%facet_type(k, j) = 2
223 end if
224 end do
225 end do
226 end do
227 end if
228
229 if (allocated(type)) then
230 deallocate(type)
231 end if
232
233 if (allocated(zone_indices)) then
234 deallocate(zone_indices)
235 end if
236 end subroutine velocity_bc_factory
237
238end submodule fluid_pnpn_bc_fctry
Defines a Blasius profile dirichlet condition.
Definition blasius.f90:34
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
Defines a dong outflow condition.
Defines inflow dirichlet conditions.
Defines user dirichlet condition for a scalar field.
Modular version of the Classic Nek5000 Pn/Pn formulation for fluids.
Defines inflow dirichlet conditions.
Definition inflow.f90:34
Dirichlet condition on axis aligned plane in the non normal direction.
Mixed Dirichlet-Neumann axis aligned symmetry plane.
Definition symmetry.f90:34
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
Utilities.
Definition utils.f90:35
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Definition utils.f90:313
Blasius profile for inlet (vector valued).
Definition blasius.f90:55
Generic Dirichlet boundary condition on .
Definition dirichlet.f90:49
Dong outflow condition Follows "A Convective-like Energy-Stable Open Boundary Condition for Simulati...
User defined dirichlet condition, for which the user can work with an entire field....
Extension of the user defined dirichlet condition field_dirichlet
Dirichlet condition for inlet (vector valued)
Definition inflow.f90:47
Dirichlet condition in non normal direction of a plane.
Mixed Dirichlet-Neumann symmetry plane condition.
Definition symmetry.f90:50
A type collecting all the overridable user routines and flag to suppress type injection from custom m...