6#include <deal.II/base/parameter_handler.h>
7#include <deal.II/base/point.h>
8#include <deal.II/base/tensor.h>
9#include <deal.II/base/types.h>
10#include <deal.II/base/utilities.h>
12#include <boost/algorithm/string/predicate.hpp>
20#include <prismspf/config.h>
25#include <unordered_set>
47[[nodiscard]]
inline std::string
50 switch (boundary_type)
59 return "TimeDependentDirichlet";
61 return "TimeDependentNeumann";
63 return "UniformDirichlet";
65 return "UniformNeumann";
79 if (boundary_string ==
"Natural")
83 if (boundary_string ==
"Dirichlet")
87 if (boundary_string ==
"Neumann")
91 if (boundary_string ==
"TimeDependentDirichlet")
95 if (boundary_string ==
"TimeDependentNeumann")
99 if (boundary_string ==
"UniformDirichlet")
103 if (boundary_string ==
"UniformNeumann")
107 if (boundary_string ==
"Periodic")
111 AssertThrow(
false, dealii::ExcMessage(
"Invalid boundary condition " + boundary_string));
132 [](
const auto &dir_cond)
134 return dir_cond.second == Condition::TimeDependentDirichlet ||
135 dir_cond.second == Condition::TimeDependentNeumann;
140template <
unsigned int dim>
152 return comp.has_time_dependent_bcs();
160template <
unsigned int dim>
190 unsigned int max_criteria = 5)
const;
197 unsigned int max_criteria = 5);
203template <
unsigned int dim>
209template <
unsigned int dim>
214 <<
"================================================\n"
215 <<
" Boundary Parameters\n"
216 <<
"================================================\n";
226template <
unsigned int dim>
229 unsigned int max_criteria)
const
231 for (
unsigned int criterion_id = 0; criterion_id < max_criteria; criterion_id++)
233 std::string subsection_text =
234 "boundary conditions: " + std::to_string(criterion_id);
235 parameter_handler.enter_subsection(subsection_text);
237 parameter_handler.declare_entry(
240 dealii::Patterns::Anything(),
241 "The names of the fields that will use these constraints.");
242 parameter_handler.declare_entry(
"conditions",
244 dealii::Patterns::Anything(),
245 "List of conditions.");
247 parameter_handler.leave_subsection();
251template <
unsigned int dim>
254 unsigned int max_criteria)
256 static const std::vector<std::string> axis_labels = {
"x",
"y",
"z"};
257 for (
unsigned int criterion_id = 0; criterion_id < max_criteria; criterion_id++)
259 std::string subsection_text =
260 "boundary conditions: " + std::to_string(criterion_id);
261 parameter_handler.enter_subsection(subsection_text);
263 std::vector<std::string> field_names =
264 dealii::Utilities::split_string_list(parameter_handler.get(
"variables"));
265 std::vector<std::string> conditions_strings =
266 dealii::Utilities::split_string_list(parameter_handler.get(
"conditions"));
269 if (conditions_strings.size() == 1)
272 for (
unsigned int boundary_id = 0; boundary_id < 2 * dim; boundary_id++)
274 component_conditions.
conditions[boundary_id] =
280 for (
unsigned int boundary_id = 0; boundary_id < conditions_strings.size();
283 component_conditions.
conditions[boundary_id] =
289 for (
const auto &field_comp_name : field_names)
291 int pos = field_comp_name.length() - 2;
292 const std::string end = field_comp_name.substr(pos > 0 ? pos : 0);
293 std::string field_name;
294 std::set<unsigned int> comps;
298 field_name = field_comp_name.substr(0, pos);
300 else if (end ==
":y")
303 field_name = field_comp_name.substr(0, pos);
305 else if (end ==
":z")
308 field_name = field_comp_name.substr(0, pos);
312 for (
unsigned int comp = 0; comp < dim; ++comp)
316 field_name = field_comp_name;
318 for (
unsigned int component : comps)
323 component) = component_conditions;
328 parameter_handler.leave_subsection();
332PRISMS_PF_END_NAMESPACE
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:35
Condition condition_from_string(const std::string &boundary_string)
Enum to string for type.
Definition constraint_parameters.h:77
Condition
Condition of boundary condition.
Definition constraint_parameters.h:33
@ Neumann
Definition constraint_parameters.h:36
@ UniformDirichlet
Definition constraint_parameters.h:39
@ TimeDependentDirichlet
Definition constraint_parameters.h:37
@ Periodic
Definition constraint_parameters.h:41
@ Natural
Definition constraint_parameters.h:34
@ Dirichlet
Definition constraint_parameters.h:35
@ TimeDependentNeumann
Definition constraint_parameters.h:38
@ UniformNeumann
Definition constraint_parameters.h:40
std::string to_string(Condition boundary_type)
Enum to string for type.
Definition constraint_parameters.h:48
Definition conditional_ostreams.cc:20
Struct that holds boundary parameters.
Definition constraint_parameters.h:162
void declare_parameters(dealii::ParameterHandler ¶meter_handler, unsigned int max_criteria=5) const
Declare the parameters to be read from an input file.
Definition constraint_parameters.h:228
void print_parameter_summary() const
Print parameters to summary.log.
Definition constraint_parameters.h:211
void assign_parameters(dealii::ParameterHandler ¶meter_handler, unsigned int max_criteria=5)
Assign the parameters read from an input file to this object.
Definition constraint_parameters.h:253
void validate()
Postprocess and validate parameters.
Definition constraint_parameters.h:205
bool has_time_dependent_bcs() const
Whether there are time-dependent boundary conditions.
Definition constraint_parameters.h:180
std::unordered_map< std::string, FieldConstraints< dim > > boundary_condition_list
Definition constraint_parameters.h:200
Struct that stores relevant information for boundary conditions of a certain field.
Definition constraint_parameters.h:120
bool has_time_dependent_bcs() const
Definition constraint_parameters.h:128
std::map< unsigned int, Condition > conditions
Definition constraint_parameters.h:125
Definition constraint_parameters.h:142
bool has_time_dependent_bcs() const
Definition constraint_parameters.h:146
std::array< ComponentConditions, dim > component_constraints
Definition constraint_parameters.h:143