PRISMS-PF Manual
Loading...
Searching...
No Matches
constraint_parameters.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#pragma once
5
6#include <deal.II/base/point.h>
7#include <deal.II/base/tensor.h>
8#include <deal.II/base/types.h>
9#include <deal.II/base/utilities.h>
10
11#include <boost/algorithm/string/predicate.hpp>
12
17#include <prismspf/core/types.h>
18
19#include <prismspf/config.h>
20
21#include <algorithm>
22#include <map>
23#include <string>
24#include <unordered_set>
25
27
42
46[[nodiscard]] inline std::string
48{
49 switch (boundary_type)
50 {
52 return "Natural";
54 return "Dirichlet";
56 return "Neumann";
58 return "TimeDependentDirichlet";
60 return "TimeDependentNeumann";
62 return "UniformDirichlet";
64 return "UniformNeumann";
66 return "Periodic";
67 default:
68 return "UNKNOWN";
69 }
70}
71
75[[nodiscard]] inline Condition
77{
78 if (boundary_string == "Natural")
79 {
80 return Condition::Natural;
81 }
82 if (boundary_string == "Dirichlet")
83 {
85 }
86 if (boundary_string == "Neumann")
87 {
88 return Condition::Neumann;
89 }
90 if (boundary_string == "TimeDependentDirichlet")
91 {
93 }
94 if (boundary_string == "TimeDependentNeumann")
95 {
97 }
98 if (boundary_string == "UniformDirichlet")
99 {
101 }
102 if (boundary_string == "UniformNeumann")
103 {
105 }
106 if (boundary_string == "Periodic")
107 {
108 return Condition::Periodic;
109 }
110 AssertThrow(false, dealii::ExcMessage("Invalid boundary condition " + boundary_string));
111 return Condition::Natural;
112}
113
119{
120 // Map of boundary conditions and domain boundary for which they correspond to. For a
121 // simple geometry like a square the boundary ids are marked, in order, by x=0, x=max,
122 // y=0, y=max. More complex geometries can have somewhat arbitrary ordering, but will
123 // render some of our assertions moot.
124 std::map<unsigned int, Condition> conditions;
125
126 [[nodiscard]] bool
128 {
129 return std::any_of(conditions.begin(),
130 conditions.end(),
131 [](const auto &dir_cond)
132 {
133 return dir_cond.second == Condition::TimeDependentDirichlet ||
134 dir_cond.second == Condition::TimeDependentNeumann;
135 });
136 }
137};
138
139template <unsigned int dim>
141{
142 std::array<ComponentConditions, dim> component_constraints;
143
144 // std::unordered_set<std::pair<dealii::Point<dim>, dealii::Tensor<1, dim>>>
145 // pinned_points;
146
147 [[nodiscard]] bool
149 {
150 return std::any_of(component_constraints.begin(),
152 [](const ComponentConditions &comp)
153 {
154 return comp.has_time_dependent_bcs();
155 });
156 }
157};
158
162template <unsigned int dim>
164{
165public:
169 void
170 validate();
171
175 void
177
181 [[nodiscard]] bool
183 { // todo
184 }
185
186 // Map of boundary conditions. The first key is the field index.
187 std::unordered_map<std::string, FieldConstraints<dim>> boundary_condition_list;
188};
189
190template <unsigned int dim>
191inline void
195
196template <unsigned int dim>
197inline void
199{
201 << "================================================\n"
202 << " Boundary Parameters\n"
203 << "================================================\n";
204
205 for (const auto &[index, component_map] : boundary_condition_list)
206 {
207 // Todo
208 }
209 // TODO print pinned points
210
211 ConditionalOStreams::pout_summary() << "\n" << std::flush;
212}
213
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:34
Condition condition_from_string(const std::string &boundary_string)
Enum to string for type.
Definition constraint_parameters.h:76
Condition
Condition of boundary condition.
Definition constraint_parameters.h:32
@ Neumann
Definition constraint_parameters.h:35
@ UniformDirichlet
Definition constraint_parameters.h:38
@ TimeDependentDirichlet
Definition constraint_parameters.h:36
@ Periodic
Definition constraint_parameters.h:40
@ Natural
Definition constraint_parameters.h:33
@ Dirichlet
Definition constraint_parameters.h:34
@ TimeDependentNeumann
Definition constraint_parameters.h:37
@ UniformNeumann
Definition constraint_parameters.h:39
std::string to_string(Condition boundary_type)
Enum to string for type.
Definition constraint_parameters.h:47
@ Value
Use value of the variable as a criterion for refinement.
Definition grid_refiner_criterion.h:31
Definition conditional_ostreams.cc:20
Struct that holds boundary parameters.
Definition constraint_parameters.h:164
void print_parameter_summary() const
Print parameters to summary.log.
Definition constraint_parameters.h:198
void validate()
Postprocess and validate parameters.
Definition constraint_parameters.h:192
bool has_time_dependent_bcs() const
Whether there are time-dependent boundary conditions.
Definition constraint_parameters.h:182
std::unordered_map< std::string, FieldConstraints< dim > > boundary_condition_list
Definition constraint_parameters.h:187
Struct that stores relevant information for boundary conditions of a certain field.
Definition constraint_parameters.h:119
bool has_time_dependent_bcs() const
Definition constraint_parameters.h:127
std::map< unsigned int, Condition > conditions
Definition constraint_parameters.h:124
Definition constraint_parameters.h:141
bool has_time_dependent_bcs() const
Definition constraint_parameters.h:148
std::array< ComponentConditions, dim > component_constraints
Definition constraint_parameters.h:142