Neko 1.99.3
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
46 use no_slip, only : no_slip_t
48
49 implicit none
50
51 ! List of all possible types created by the boundary condition factories
52 character(len=25) :: FLUID_PNPN_KNOWN_BCS(14) = [character(len=25) :: &
53 "symmetry", &
54 "velocity_value", &
55 "no_slip", &
56 "outflow", &
57 "normal_outflow", &
58 "outflow+user", &
59 "normal_outflow+user", &
60 "outflow+dong", &
61 "normal_outflow+dong", &
62 "shear_stress", &
63 "user_velocity", &
64 "user_pressure", &
65 "blasius_profile", &
66 "wall_model"]
67
68contains
69
76 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
77 class(bc_t), pointer, intent(inout) :: object
78 type(fluid_pnpn_t), intent(in) :: scheme
79 type(json_file), intent(inout) :: json
80 type(coef_t), target, intent(in) :: coef
81 type(user_t), intent(in) :: user
82 character(len=:), allocatable :: type
83 integer :: i, j, k
84 integer, allocatable :: zone_indices(:)
85 character(len=:), allocatable :: default_name
86 character(len=64) :: buf
87
88 if (associated(object)) then
89 call object%free()
90 nullify(object)
91 end if
92
93 call json_get(json, "type", type)
94
95 select case (trim(type))
96 case ("outflow", "normal_outflow")
97 allocate(zero_dirichlet_t::object)
98
99 case ("outflow+dong", "normal_outflow+dong")
100 allocate(dong_outflow_t::object)
101
102 case ("user_pressure", "outflow+user", "normal_outflow+user")
103 allocate(field_dirichlet_t::object)
104 select type (obj => object)
105 type is (field_dirichlet_t)
106 obj%update => user%dirichlet_conditions
107 call json%add("field_name", scheme%p%name)
108 end select
109
110 case default
111 do i = 1, size(fluid_pnpn_known_bcs)
112 if (trim(type) .eq. trim(fluid_pnpn_known_bcs(i))) return
113 end do
114 call neko_type_error("fluid_pnpn boundary conditions", type, &
115 FLUID_PNPN_KNOWN_BCS)
116 end select
117
118 call json_get_or_lookup(json, "zone_indices", zone_indices)
119 call object%init(coef, json)
120
121 do i = 1, size(zone_indices)
122 call object%mark_zone(coef%msh%labeled_zones(zone_indices(i)))
123 end do
124
125 write(buf, '("pressure_bc_", I0)') zone_indices(1)
126 default_name = trim(buf)
127 call json_get_or_default(json, "name", object%name, default_name)
128 object%zone_indices = zone_indices
129 call object%finalize()
130
131 ! All pressure bcs are currently strong, so for all of them we
132 ! mark with value 1 in the mesh
133 do i = 1, size(zone_indices)
134 do j = 1, scheme%msh%nelv
135 do k = 1, 2 * scheme%msh%gdim
136 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
137 scheme%msh%facet_type(k, j) = 1
138 end if
139 end do
140 end do
141 end do
142
143 if (allocated(type)) then
144 deallocate(type)
145 end if
146
147 if (allocated(zone_indices)) then
148 deallocate(zone_indices)
149 end if
150 end subroutine pressure_bc_factory
151
158 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
159 class(bc_t), pointer, intent(inout) :: object
160 type(fluid_pnpn_t), intent(inout) :: scheme
161 type(json_file), intent(inout) :: json
162 type(coef_t), target, intent(in) :: coef
163 type(user_t), intent(in) :: user
164 character(len=:), allocatable :: type
165 integer :: i, j, k
166 integer, allocatable :: zone_indices(:)
167 character(len=:), allocatable :: default_name
168 character(len=64) :: buf
169
170 call json_get(json, "type", type)
171
172 select case (trim(type))
173 case ("symmetry")
174 allocate(symmetry_t::object)
175 case ("velocity_value")
176 allocate(inflow_t::object)
177 case ("no_slip")
178 allocate(no_slip_t::object)
179 case ("normal_outflow", "normal_outflow+dong", "normal_outflow+user")
180 allocate(non_normal_t::object)
181 case ("blasius_profile")
182 allocate(blasius_t::object)
183 case ("shear_stress")
184 allocate(shear_stress_t::object)
185 case ("wall_model")
186 allocate(wall_model_bc_t::object)
187 ! Kind of hack, but OK for now
188 call json%add("scheme_name", scheme%name)
189
190 case ("user_velocity")
191 allocate(field_dirichlet_vector_t::object)
192 select type (obj => object)
194 obj%update => user%dirichlet_conditions
195 end select
196
197 case default
198 do i = 1, size(fluid_pnpn_known_bcs)
199 if (trim(type) .eq. trim(fluid_pnpn_known_bcs(i))) return
200 end do
201 call neko_type_error("fluid_pnpn boundary conditions", type, &
202 FLUID_PNPN_KNOWN_BCS)
203 end select
204
205 call json_get_or_lookup(json, "zone_indices", zone_indices)
206 call object%init(coef, json)
207 do i = 1, size(zone_indices)
208 call object%mark_zone(coef%msh%labeled_zones(zone_indices(i)))
209 end do
210
211 write(buf,'("velocity_bc_",I0)') zone_indices(1)
212 default_name = trim(buf)
213 call json_get_or_default(json, "name", object%name, default_name)
214 object%zone_indices = zone_indices
215 call object%finalize()
216
217 ! Exclude these two because they are bcs for the residual, not velocity
218 if (trim(type) .ne. "normal_outflow" .and. &
219 trim(type) .ne. "normal_outflow+dong") then
220 do i = 1, size(zone_indices)
221 do j = 1, scheme%msh%nelv
222 do k = 1, 2 * scheme%msh%gdim
223 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
224 scheme%msh%facet_type(k, j) = 2
225 end if
226 end do
227 end do
228 end do
229 end if
230
231 if (allocated(type)) then
232 deallocate(type)
233 end if
234
235 if (allocated(zone_indices)) then
236 deallocate(zone_indices)
237 end if
238 end subroutine velocity_bc_factory
239
240end 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
Defines no-slip boundary condition (extends zero_dirichlet)
Definition no_slip.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...