Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
compressible_ns_bc_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2025-2026, 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!
33!
34submodule(fluid_scheme_compressible_ns) compressible_ns_bc_fctry
35 use dirichlet, only : dirichlet_t
36 use inflow, only : inflow_t
38 use symmetry, only : symmetry_t
40 implicit none
41
42 ! List of all possible types created by the boundary condition factories
43 character(len=25) :: COMPRESSIBLE_KNOWN_BCS(8) = [character(len=25) :: &
44 "velocity_value", &
45 "density_value", &
46 "pressure_value", &
47 "no_slip", &
48 "slip", &
49 "symmetry", &
50 "outflow", &
51 "normal_outflow"]
52
53contains
60 module subroutine density_bc_factory(object, scheme, json, coef, user)
61 class(bc_t), pointer, intent(inout) :: object
62 type(fluid_scheme_compressible_ns_t), intent(in) :: scheme
63 type(json_file), intent(inout) :: json
64 type(coef_t), intent(in) :: coef
65 type(user_t), intent(in) :: user
66 character(len=:), allocatable :: type
67 integer :: i, j, k
68 integer, allocatable :: zone_indices(:)
69 character(len=:), allocatable :: default_name
70 character(len=64) :: buf
71
72 call json_get(json, "type", type)
73
74 select case (trim(type))
75 case ("density_value")
76 allocate(dirichlet_t::object)
77 case default
78 do i = 1, size(compressible_known_bcs)
79 if (trim(type) .eq. trim(compressible_known_bcs(i))) return
80 end do
81 call neko_type_error("compressible boundary conditions", type, &
82 COMPRESSIBLE_KNOWN_BCS)
83 end select
84
85 call json_get_or_lookup(json, "zone_indices", zone_indices)
86 call object%init(coef, json)
87
88 do i = 1, size(zone_indices)
89 call object%mark_labeled_zone(zone_indices(i))
90 end do
91
92 write(buf, '("density_bc_",I0)') zone_indices(1)
93 default_name = trim(buf)
94 call json_get_or_default(json, "name", object%name, default_name)
95 object%zone_indices = zone_indices
96 call object%finalize()
97 end subroutine density_bc_factory
98
105 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
106 class(bc_t), pointer, intent(inout) :: object
107 type(fluid_scheme_compressible_ns_t), intent(inout) :: scheme
108 type(json_file), intent(inout) :: json
109 type(coef_t), intent(in) :: coef
110 type(user_t), intent(in) :: user
111 character(len=:), allocatable :: type
112 integer :: i, j, k
113 integer, allocatable :: zone_indices(:)
114 character(len=:), allocatable :: default_name
115 character(len=64) :: buf
116
117 call json_get(json, "type", type)
118
119 select case (trim(type))
120 case ("outflow", "normal_outflow")
121 allocate(zero_dirichlet_t::object)
122 case ("pressure_value")
123 allocate(dirichlet_t::object)
124 case default
125 do i = 1, size(compressible_known_bcs)
126 if (trim(type) .eq. trim(compressible_known_bcs(i))) return
127 end do
128 call neko_type_error("compressible boundary conditions", type, &
129 COMPRESSIBLE_KNOWN_BCS)
130 end select
131
132 call json_get_or_lookup(json, "zone_indices", zone_indices)
133 call object%init(coef, json)
134
135 do i = 1, size(zone_indices)
136 call object%mark_labeled_zone(zone_indices(i))
137 end do
138
139 write(buf, '("pressure_bc_",I0)') zone_indices(1)
140 default_name = trim(buf)
141 call json_get_or_default(json, "name", object%name, default_name)
142 object%zone_indices = zone_indices
143 call object%finalize()
144
145 ! All pressure bcs are currently strong, so for all of them we
146 ! mark with value 1 in the mesh
147 do i = 1, size(zone_indices)
148 do j = 1, scheme%msh%nelv
149 do k = 1, 2 * scheme%msh%gdim
150 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
151 scheme%msh%facet_type(k, j) = 1
152 end if
153 end do
154 end do
155 end do
156 end subroutine pressure_bc_factory
157
164 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
165 class(bc_t), pointer, intent(inout) :: object
166 type(fluid_scheme_compressible_ns_t), intent(in) :: scheme
167 type(json_file), intent(inout) :: json
168 type(coef_t), intent(in) :: coef
169 type(user_t), intent(in) :: user
170 character(len=:), allocatable :: type
171 integer :: i, j, k
172 integer, allocatable :: zone_indices(:)
173 character(len=:), allocatable :: default_name
174 character(len=64) :: buf
175
176 call json_get(json, "type", type)
177
178 select case (trim(type))
179 case ("symmetry")
180 allocate(symmetry_t::object)
181 case ("slip")
182 allocate(symmetry_t::object)
183 case ("no_slip")
184 allocate(zero_dirichlet_t::object)
185 case ("velocity_value")
186 allocate(inflow_t::object)
187 case default
188 do i = 1, size(compressible_known_bcs)
189 if (trim(type) .eq. trim(compressible_known_bcs(i))) return
190 end do
191 call neko_type_error("compressible boundary conditions", type, &
192 COMPRESSIBLE_KNOWN_BCS)
193 end select
194
195 call json_get_or_lookup(json, "zone_indices", zone_indices)
196 call object%init(coef, json)
197 do i = 1, size(zone_indices)
198 call object%mark_labeled_zone(zone_indices(i))
199 end do
200
201 write(buf, '("velocity_bc_",I0)') zone_indices(1)
202 default_name = trim(buf)
203 call json_get_or_default(json, "name", object%name, default_name)
204 object%zone_indices = zone_indices
205 call object%finalize()
206
207 end subroutine velocity_bc_factory
208
209end submodule compressible_ns_bc_fctry
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
Defines inflow dirichlet conditions.
Definition inflow.f90:34
Utilities for retrieving parameters from the case files.
Implements symmetry_t.
Definition symmetry.f90:34
Defines a zero-valued Dirichlet boundary condition.
Generic Dirichlet boundary condition on .
Definition dirichlet.f90:49
Dirichlet condition for inlet (vector valued)
Definition inflow.f90:48
Symmetry boundary condition constraining the normal vector component.
Definition symmetry.f90:50
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...