Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
fluid_dynamics_boundary_conditions.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_fluid_dynamics_boundary_conditions_h
5#define lethe_fluid_dynamics_boundary_conditions_h
6
8#include <core/utilities.h>
9
10#include <deal.II/base/function.h>
11#include <deal.II/base/parameter_handler.h>
12#include <deal.II/base/parsed_function.h>
13
14#include <map>
15#include <memory>
16#include <utility>
17#include <vector>
18
19using namespace dealii;
20
21namespace BoundaryConditions
22{
23 /// Boundary condition types of the fluid dynamics. periodic_neighbor is not
24 /// a user choice: it is assigned to the boundary matching a periodic
25 /// boundary.
40
41 /// Deprecated strings of the fluid dynamics boundary condition "type"
42 /// parameter, which remain accepted in parameter files
48
49 /// Boundary condition types of the fluid dynamics which can be selected in
50 /// the parameter file
51 inline const std::vector<FluidDynamicsBoundaryType>
63
64 /**
65 * @brief This class manages the functions associated with function-type boundary conditions
66 * of the Navier-Stokes equations
67 */
68 template <int dim>
70 {
71 public:
72 // Velocity components
73 Functions::ParsedFunction<dim> u;
74 Functions::ParsedFunction<dim> v;
75 Functions::ParsedFunction<dim> w;
76
77 /// Pressure
78 Functions::ParsedFunction<dim> p;
79
80 // Neumann Traction σ = 2με(u)− pI
81 // σ.n = g
82 Functions::ParsedFunction<dim> traction_fn;
83
84 /// Point for the center of rotation
86
87 /*
88 Constructor required to avoid vector-valued function t of ParsedFunction
89 type which in-turn initializes the function_parser object with
90 n_components = 1 by default if n_components is not passed.
91
92 Moreover, the test and trial function is dim+1 components including
93 pressure. Hence, we have the traction function as a vector-valued function
94 with dim components for the traction vector and 1 component for the
95 pressure value at the boundary which is dummy and is needed to properly
96 assemble the traction term as FEFaceIntegrator uses MatrixFree which in
97 turn is based on the DoFHandler which in turn is based on the FE system
98 that has dim velocity components and 1 pressure component.
99 t = (t₁, t₂, …, t_dim, 0.0 (dummy pressure component))
100 φ = (φ₁, φ₂, …, φ_dim, φ_p)
101 ∫_{Γ_t} = t · φ ds
102 */
103
105 : traction_fn(dim + 1) // The traction function has dim components for the
106 // traction vector plus 1 for the pressure.
107 {}
108 };
109
110 /**
111 * @brief This class manages the boundary conditions forhe fluid dynamics solver
112 * It introduces the boundary functions and declares the boundary conditions
113 * coherently.
114 */
115 template <int dim>
117 : public BoundaryConditions<FluidDynamicsBoundaryType>
118 {
119 public:
120 /// Map containing the penalization parameter for weak Dirichlet BCs and
121 /// outlets for a corresponding id.
122 std::map<types::boundary_id, double> beta;
123
124 /// Map containing the boundary layer thickness used to compute the tangent
125 /// penalization parameter of partial slip BCs for a corresponding id.
126 std::map<types::boundary_id, double> boundary_layer_thickness;
127
128 /// Functions for (u : x component of the velocity, v : y component of the
129 /// velocity, w : z-component of the velocity, p : pressure, Neumann
130 /// traction: traction_fn) for all boundaries
131 std::map<types::boundary_id,
132 std::shared_ptr<NavierStokesBoundaryFunctions<dim>>>
134
135 /**
136 * @brief Declare the default parameters for one fluid dynamics boundary condition
137 *
138 * @param[in,out] prm The parameter handler object.
139 * @param[in] default_boundary_id The default mesh boundary id.
140 */
141 void
142 declare_default_entry(ParameterHandler &prm,
143 types::boundary_id default_boundary_id);
144
145 /**
146 * @brief Declare the fluid dynamics boundary conditions
147 *
148 * @param[in,out] prm The parameter handler object.
149 * @param[in] number_of_boundary_conditions The number of boundary
150 * conditions to declare.
151 */
152 void
153 declare_parameters(ParameterHandler &prm,
154 unsigned int number_of_boundary_conditions);
155
156 /**
157 * @brief Parse the information for one fluid dynamics boundary condition.
158 *
159 * @param[in] prm The parameter handler containing the boundary
160 * condition.
161 */
162 void
163 parse_boundary(ParameterHandler &prm);
164
165 /**
166 * @brief Parse the fluid dynamics boundary conditions
167 *
168 * @param[in] prm The parameter handler object.
169 */
170 void
171 parse_parameters(ParameterHandler &prm);
172
173 /**
174 * @brief Creates a noslip boundary condition for id=0. Used in tests only
175 */
176 void
177 createNoSlip();
178
179 /// Fix pressure constant using a node
181 };
182
183 template <int dim>
184 void
191} // namespace BoundaryConditions
192
193
194/**
195 * @brief This class implements a boundary conditions for the fluid dynamics solver
196 * where the velocity component are defined using individual functions
197 */
198template <int dim>
199class FluidDynamicsVelocityFunctionDefined : public Function<dim>
200{
201 Functions::ParsedFunction<dim> *u;
202 Functions::ParsedFunction<dim> *v;
203 Functions::ParsedFunction<dim> *w;
204
205public:
206 /**
207 * @brief Initialize the fluid dynamics boundary function with its velocity
208 * components.
209 *
210 * @param[in] p_u The parsed function defining the x-velocity component.
211 * @param[in] p_v The parsed function defining the y-velocity component.
212 * @param[in] p_w The parsed function defining the z-velocity component.
213 */
214 FluidDynamicsVelocityFunctionDefined(Functions::ParsedFunction<dim> *p_u,
215 Functions::ParsedFunction<dim> *p_v,
216 Functions::ParsedFunction<dim> *p_w)
217 : Function<dim>(dim + 1)
218 , u(p_u)
219 , v(p_v)
220 , w(p_w)
221 {}
222
223 /**
224 * @brief Calculates the value of a Function-type fluid dynamics equations
225 *
226 * @param[in] point A point at which the function will be evaluated
227 * @param[in] component The vector component of the boundary condition (0-x,
228 * 1-y and 2-z)
229 */
230 double
231 value(const Point<dim> &point, const unsigned int component) const override;
232};
233
234/**
235 * @brief This class implements a pressure boundary condition for the Navier-Stokes equations.
236 */
237template <int dim>
238class FluidDynamicsPressureFunctionDefined : public Function<dim>
239{
240 Functions::ParsedFunction<dim> *p;
241
242public:
243 /**
244 * @brief Initialize the fluid dynamics pressure boundary function.
245 *
246 * @param[in] p_p The parsed function defining the pressure.
247 */
248 FluidDynamicsPressureFunctionDefined(Functions::ParsedFunction<dim> *p_p)
249 : Function<dim>(dim + 1)
250 , p(p_p)
251 {}
252
253 /**
254 * @brief Calculates the value of a Function-type fluid dynamics equations
255 *
256 * @param[in] point A point (generally a gauss point)
257 * @param[in] component The vector component of the boundary condition (0-x,
258 * 1-y and 2-z)
259 */
260 double
261 value(const Point<dim> &point, unsigned int component) const override;
262};
263
264#endif
std::map< types::boundary_id, FluidDynamicsBoundaryType > type
This class manages the boundary conditions forhe fluid dynamics solver It introduces the boundary fun...
void parse_boundary(ParameterHandler &prm)
Parse the information for one fluid dynamics boundary condition.
void declare_default_entry(ParameterHandler &prm, types::boundary_id default_boundary_id)
Declare the default parameters for one fluid dynamics boundary condition.
std::map< types::boundary_id, std::shared_ptr< NavierStokesBoundaryFunctions< dim > > > navier_stokes_functions
void parse_parameters(ParameterHandler &prm)
Parse the fluid dynamics boundary conditions.
void declare_parameters(ParameterHandler &prm, unsigned int number_of_boundary_conditions)
Declare the fluid dynamics boundary conditions.
void createNoSlip()
Creates a noslip boundary condition for id=0. Used in tests only.
Point< dim > center_of_rotation
Point for the center of rotation.
double value(const Point< dim > &point, unsigned int component) const override
Calculates the value of a Function-type fluid dynamics equations.
FluidDynamicsPressureFunctionDefined(Functions::ParsedFunction< dim > *p_p)
Initialize the fluid dynamics pressure boundary function.
double value(const Point< dim > &point, const unsigned int component) const override
Calculates the value of a Function-type fluid dynamics equations.
FluidDynamicsVelocityFunctionDefined(Functions::ParsedFunction< dim > *p_u, Functions::ParsedFunction< dim > *p_v, Functions::ParsedFunction< dim > *p_w)
Initialize the fluid dynamics boundary function with its velocity components.
std::vector< std::pair< std::string, EnumType > > DeprecatedEnumNames
Deprecated strings of an enum parameter, each paired with the enumerator it stands for....
Definition utilities.h:765
const DeprecatedEnumNames< FluidDynamicsBoundaryType > deprecated_fluid_dynamics_boundary_type_names
const std::vector< FluidDynamicsBoundaryType > fluid_dynamics_boundary_types