Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
qmom_boundary_conditions.cc
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
5#include <core/utilities.h>
6
7#include <deal.II/base/parameter_handler.h>
8#include <deal.II/base/patterns.h>
9
10#include <string>
11#include <vector>
12
13using namespace dealii;
14
15DeclException1(QMOMBoundaryDuplicated,
16 types::boundary_id,
17 << "QMOM boundary id: " << arg1
18 << " has already been declared as a boundary condition");
19
20namespace BoundaryConditions
21{
22 template <int dim>
23 void
25 ParameterHandler &prm,
26 const types::boundary_id default_boundary_id)
27 {
29 "type",
31 "Type of boundary condition for the QMOM fields.");
32
33 prm.declare_entry("id",
34 Utilities::int_to_string(default_boundary_id, 2),
35 Patterns::List(Patterns::Integer()),
36 "Mesh id for boundary conditions");
37
38 prm.enter_subsection("dirichlet");
40 prm.leave_subsection();
41 }
42
43 template <int dim>
44 void
46 ParameterHandler &prm,
47 const unsigned int number_of_boundary_conditions)
48 {
49 prm.enter_subsection("boundary conditions qmom");
50 {
51 prm.declare_entry("number",
52 "0",
53 Patterns::Integer(),
54 "Number of boundary conditions");
55
56 prm.declare_entry(
57 "time dependent",
58 "false",
59 Patterns::Bool(),
60 "Bool to define if the boundary condition is time-dependent");
61
62 for (unsigned int i_bc = 0; i_bc < number_of_boundary_conditions; ++i_bc)
63 {
64 prm.enter_subsection("bc " + std::to_string(i_bc));
65 {
66 declare_default_entry(prm, i_bc);
67 }
68 prm.leave_subsection();
69 }
70 }
71 prm.leave_subsection();
72 }
73
74 template <int dim>
75 void
77 {
78 const std::vector<types::boundary_id> boundary_ids =
80
81 AssertThrow(
82 boundary_ids.size() > 0,
83 ExcMessage(
84 "A boundary id has not been set for one of the QMOM boundary conditions. Please ensure that the id is set for every boundary condition."));
85
86 const QMOMBoundaryType boundary_type =
87 string_to_enum<QMOMBoundaryType>(prm.get("type"));
88 for (const auto boundary_id : boundary_ids)
89 {
90 AssertThrow(this->type.find(boundary_id) == this->type.end(),
91 QMOMBoundaryDuplicated(boundary_id));
92
93 this->type[boundary_id] = boundary_type;
94 if (boundary_type == QMOMBoundaryType::dirichlet)
95 {
96 prm.enter_subsection("dirichlet");
97 dirichlet[boundary_id].parse_parameters(prm);
98 prm.leave_subsection();
99 }
100 }
101 }
102
103 template <int dim>
104 void
106 {
107 prm.enter_subsection("boundary conditions qmom");
108 {
109 this->number_of_boundary_conditions = prm.get_integer("number");
110 this->time_dependent = prm.get_bool("time dependent");
111
112 for (unsigned int i_bc = 0; i_bc < this->number_of_boundary_conditions;
113 ++i_bc)
114 {
115 prm.enter_subsection("bc " + std::to_string(i_bc));
116 {
117 parse_boundary(prm);
118 }
119 prm.leave_subsection();
120 }
121 }
122 prm.leave_subsection();
123 }
124
125 template class QMOMBoundaryConditions<2>;
126 template class QMOMBoundaryConditions<3>;
127} // namespace BoundaryConditions
std::map< types::boundary_id, QMOMBoundaryType > type
Boundary conditions of the QMOM physics. They apply to the advective flux of all the QMOM fields (sca...
void declare_default_entry(ParameterHandler &prm, const types::boundary_id default_boundary_id)
Declare the parameters of one boundary condition.
void declare_parameters(ParameterHandler &prm, const unsigned int number_of_boundary_conditions)
Declare the "boundary conditions qmom" subsection.
void parse_parameters(ParameterHandler &prm)
Parse the "boundary conditions qmom" subsection.
void parse_boundary(ParameterHandler &prm)
Parse one boundary condition.
std::map< types::boundary_id, Parameters::QMOMFunctions< dim > > dirichlet
std::vector< T > convert_string_to_vector(const ParameterHandler &prm, const std::string &entry_string)
Return the vector of size N of entry @entry_string. If the entry is specified in the ....
Definition utilities.h:1330
EnumType string_to_enum(const std::string &name)
Return the enumerator whose identifier is name, e.g. to parse the value of a parameter entry into its...
Definition utilities.h:734
void declare_enum_entry(ParameterHandler &prm, const std::string &entry_name, const EnumType default_value, const std::string &description, const DeprecatedEnumNames< EnumType > &deprecated_names={}, const std::vector< EnumType > &allowed_values={})
Declare a parameter entry whose value is an enumerator. The default value, the accepted values and th...
Definition utilities.h:888
QMOMBoundaryType
Boundary condition types of the QMOM physics.
DeclException1(QMOMBoundaryDuplicated, types::boundary_id,<< "QMOM boundary id: "<< arg1<< " has already been declared as a boundary condition")
static void declare_parameters(ParameterHandler &prm)
Declare the "scalars" and "distribution" subsections in the current subsection. All the functions are...