Neko 1.99.9
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-2026, 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 ! We explicitly import all necessary modules to work around an ifx 2026.1
38 ! internal compiler error even when they are only available through the
39 ! parent.
42 use user_intf, only : user_t
43 use utils, only : neko_type_error
45 use inflow, only : inflow_t
46 use blasius, only : blasius_t
47 use dirichlet, only : dirichlet_t
50 use symmetry, only : symmetry_t
52 use non_normal, only : non_normal_t
53 use no_slip, only : no_slip_t
62 implicit none
63
64 ! List of all possible types created by the boundary condition factories
65 character(len=25) :: FLUID_PNPN_KNOWN_BCS(17) = [character(len=25) :: &
66 "symmetry", &
67 "velocity_value", &
68 "expression_velocity", &
69 "expression_pressure", &
70 "no_slip", &
71 "outflow", &
72 "normal_outflow", &
73 "outflow+user", &
74 "normal_outflow+user", &
75 "outflow+dong", &
76 "normal_outflow+dong", &
77 "shear_stress", &
78 "user_velocity", &
79 "user_pressure", &
80 "blasius_profile", &
81 "wall_model", &
82 "overset_interface"]
83
84contains
85
92 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
93 class(bc_t), pointer, intent(inout) :: object
94 type(fluid_pnpn_t), intent(in) :: scheme
95 type(json_file), intent(inout) :: json
96 type(coef_t), target, intent(in) :: coef
97 type(user_t), target, intent(in) :: user
98 character(len=:), allocatable :: type
99 integer :: i, j, k
100 integer, allocatable :: zone_indices(:)
101 character(len=:), allocatable :: default_name
102 character(len=64) :: buf
103 logical :: temp_logical
104
105 if (associated(object)) then
106 call object%free()
107 nullify(object)
108 end if
109
110 call json_get(json, "type", type)
111
112 select case (trim(type))
113 case ("outflow", "normal_outflow")
114 allocate(zero_dirichlet_t::object)
115
116 case ("expression_pressure")
117 allocate(expression_dirichlet_t::object)
118
119 case ("outflow+dong", "normal_outflow+dong")
120 allocate(dong_outflow_t::object)
121
122 case ("user_pressure", "outflow+user", "normal_outflow+user")
123 allocate(field_dirichlet_t::object)
124 select type (obj => object)
125 type is (field_dirichlet_t)
126 obj%update => user%dirichlet_conditions
127 call json%add("field_name", scheme%p%name)
128 end select
129
130 case ("overset_interface")
131 call json_get_or_default(json, "couple_pressure", temp_logical, .false.)
132 if (temp_logical) then
133 allocate(overset_interface_t::object)
134 select type (obj => object)
135 type is (overset_interface_t)
136 call json%add("field_name", scheme%p%name)
137 obj%morph_interface => user%morph_interface
138 end select
139 else
140 return
141 end if
142
143 case default
144 do i = 1, size(fluid_pnpn_known_bcs)
145 if (trim(type) .eq. trim(fluid_pnpn_known_bcs(i))) return
146 end do
147 call neko_type_error("fluid_pnpn boundary conditions", type, &
148 FLUID_PNPN_KNOWN_BCS)
149 end select
150
151 call json_get_or_lookup(json, "zone_indices", zone_indices)
152 call object%init(coef, json)
153
154 do i = 1, size(zone_indices)
155 call object%mark_labeled_zone(zone_indices(i))
156 end do
157
158 write(buf, '("pressure_bc_", I0)') zone_indices(1)
159 default_name = trim(buf)
160 call json_get_or_default(json, "name", object%name, default_name)
161 object%zone_indices = zone_indices
162 call object%finalize()
163
164 ! All pressure bcs are currently strong, so for all of them we
165 ! mark with value 1 in the mesh
166 do i = 1, size(zone_indices)
167 do j = 1, scheme%msh%nelv
168 do k = 1, 2 * scheme%msh%gdim
169 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
170 scheme%msh%facet_type(k, j) = 1
171 end if
172 end do
173 end do
174 end do
175
176 if (allocated(type)) then
177 deallocate(type)
178 end if
179
180 if (allocated(zone_indices)) then
181 deallocate(zone_indices)
182 end if
183 end subroutine pressure_bc_factory
184
191 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
192 class(bc_t), pointer, intent(inout) :: object
193 type(fluid_pnpn_t), intent(inout) :: scheme
194 type(json_file), intent(inout) :: json
195 type(coef_t), target, intent(in) :: coef
196 type(user_t), target, intent(in) :: user
197 character(len=:), allocatable :: type
198 integer :: i, j, k
199 integer, allocatable :: zone_indices(:)
200 character(len=:), allocatable :: default_name
201 character(len=:), allocatable :: bc_name
202 character(len=64) :: buf
203
204 call json_get(json, "type", type)
205
206 select case (trim(type))
207 case ("symmetry")
208 if (scheme%full_stress_formulation) then
209 allocate(symmetry_t::object)
210 else
211 allocate(symmetry_aligned_t::object)
212 end if
213 case ("velocity_value")
214 allocate(inflow_t::object)
215 case ("expression_velocity")
216 allocate(expression_dirichlet_vector_t::object)
217 case ("no_slip")
218 allocate(no_slip_t::object)
219 case ("normal_outflow", "normal_outflow+dong", "normal_outflow+user")
220 if (scheme%full_stress_formulation) then
221 allocate(non_normal_t::object)
222 else
223 allocate(non_normal_aligned_t::object)
224 end if
225 case ("blasius_profile")
226 allocate(blasius_t::object)
227 case ("shear_stress")
228 allocate(shear_stress_t::object)
229 case ("wall_model")
230 allocate(wall_model_bc_t::object)
231 ! Kind of hack, but OK for now
232 call json%add("scheme_name", scheme%name)
233
234 select type (wall_bc => object)
235 type is (wall_model_bc_t)
236 wall_bc%user => user
237 end select
238
239 case ("user_velocity")
240 allocate(field_dirichlet_vector_t::object)
241 select type (obj => object)
243 obj%update => user%dirichlet_conditions
244 end select
245
246 case ("overset_interface")
247 allocate(overset_interface_vector_t::object)
248 select type (obj => object)
250 obj%morph_interface => user%morph_interface
251 end select
252
253 case default
254 do i = 1, size(fluid_pnpn_known_bcs)
255 if (trim(type) .eq. trim(fluid_pnpn_known_bcs(i))) return
256 end do
257 call neko_type_error("fluid_pnpn boundary conditions", type, &
258 FLUID_PNPN_KNOWN_BCS)
259 end select
260
261 call json_get_or_lookup(json, "zone_indices", zone_indices)
262 write(buf,'("velocity_bc_",I0)') zone_indices(1)
263 default_name = trim(buf)
264 call json_get_or_default(json, "name", bc_name, default_name)
265
266 call object%init(coef, json)
267 do i = 1, size(zone_indices)
268 call object%mark_labeled_zone(zone_indices(i))
269 end do
270
271 object%name = bc_name
272 object%zone_indices = zone_indices
273
274 call object%finalize()
275
276 ! Some bcs are marked in the pressure factory routine, and we should ignore
277 ! then here. This currently appears to only be the normal_outflow type and
278 ! its variants.
279 if (trim(type) .ne. "normal_outflow" .and. &
280 trim(type) .ne. "normal_outflow+dong" .and. &
281 trim(type) .ne. "normal_outflow+user") then
282 do i = 1, size(zone_indices)
283 do j = 1, scheme%msh%nelv
284 do k = 1, 2 * scheme%msh%gdim
285 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
286 scheme%msh%facet_type(k, j) = 2
287 end if
288 end do
289 end do
290 end do
291 end if
292
293 if (allocated(type)) then
294 deallocate(type)
295 end if
296
297 if (allocated(zone_indices)) then
298 deallocate(zone_indices)
299 end if
300 end subroutine velocity_bc_factory
301
302end 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 a vector valued Dirichlet condition prescribed by mathematical expressions.
Defines a Dirichlet condition prescribed by a mathematical expression.
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
Defines no-slip boundary condition (extends zero_dirichlet)
Definition no_slip.f90:34
Implements non_normal_aligned_t.
Implements non_normal_t.
Defines overset interface vector boundary conditions.
Defines overset interface scalar boundary conditions.
Defines a shear stress boundary condition for a vector field. Maintainer: Timofey Mukha.
Implements symmetry_aligned_t.
Implements symmetry_t.
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:365
Implements boundary condition projectors for vector fields. Two types concrete types are provided: se...
Defines the wall_model_bc_t type. Maintainer: Timofey Mukha.
Defines a zero-valued Dirichlet boundary condition.
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...
Dirichlet condition on , where is a mathematical expression given in the case file.
Vector valued Dirichlet condition, with one mathematical expression per component,...
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:48
Mixed Dirichlet condition constraining the tangential vector components.
Axis-aligned mixed Dirichlet condition in the non-normal direction.
Overset interface BC for a scalar field.
Extension of the user defined dirichlet condition overset_interface
A shear stress boundary condition.
Symmetry boundary condition constraining the normal vector component.
Definition symmetry.f90:50
Axis-aligned symmetry boundary condition.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...
A coupled projector for vector fields, suitable for mixed boundary conditions.
A projector for vector fields that acts component-wise.
A shear stress boundary condition, computing the stress values using a wall model.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...