4#ifndef spatial_discretization_h
5#define spatial_discretization_h
7#include <prismspf/config.h>
8#include <prismspf/core/conditional_ostreams.h>
9#include <prismspf/core/exceptions.h>
10#include <prismspf/core/refinement_criterion.h>
11#include <prismspf/utilities/utilities.h>
13PRISMS_PF_BEGIN_NAMESPACE
35 : subdivisions(dim, 1) {};
53 dealii::Tensor<1, dim, double> size;
59 std::vector<unsigned int> subdivisions;
62 unsigned int global_refinement = 0;
65 unsigned int degree = 1;
68 bool has_adaptivity =
false;
71 unsigned int max_refinement = 0;
74 unsigned int min_refinement = 0;
77 unsigned int remeshing_period = UINT_MAX;
80 std::vector<GridRefinement::RefinementCriterion> refinement_criteria;
88 if (radius != 0.0 && size.norm() == 0.0)
90 type = TriangulationType::spherical;
92 else if (radius == 0.0 && size.norm() != 0.0)
94 type = TriangulationType::rectangular;
98 AssertThrow(
false, UnreachableCode());
103 (!has_adaptivity || dim != 1),
105 "Adaptive meshing for the matrix-free method is not currently supported."));
111 AssertThrow((max_refinement >= global_refinement),
113 "The maximum refinement level must be greater than or equal to the "
114 "global refinement level."));
115 AssertThrow((min_refinement <= global_refinement),
117 "The minimum refinement level must be less than or equal to the "
118 "global refinement level."));
119 AssertThrow((max_refinement >= min_refinement),
121 "The maximum refinement level must be greater than or equal to the "
122 "minimum refinement level."));
125 for (
const auto &criterion : refinement_criteria)
127 AssertThrow((criterion.value_lower_bound <= criterion.value_upper_bound),
129 "The lower bound of the value-based refinement "
130 "criteria must be less than or equal to the upper bound."));
140 <<
"================================================\n"
141 <<
" Spatial Discretization\n"
142 <<
"================================================\n";
144 if (type == TriangulationType::spherical)
148 else if (type == TriangulationType::rectangular)
150 if constexpr (dim == 1)
153 <<
"Domain size: x=" << size[0] <<
"\n"
154 <<
"Subdivisions: x=" << subdivisions[0] <<
"\n";
156 else if constexpr (dim == 2)
159 <<
"Domain size: x=" << size[0] <<
", y=" << size[1] <<
"\n"
160 <<
"Subdivisions: x=" << subdivisions[0] <<
", y=" << subdivisions[1] <<
"\n";
162 else if constexpr (dim == 3)
165 <<
"Domain size: x=" << size[0] <<
", y=" << size[1] <<
", z=" << size[2]
167 <<
"Subdivisions: x=" << subdivisions[0] <<
", y=" << subdivisions[1]
168 <<
", z=" << subdivisions[2] <<
"\n";
173 AssertThrow(
false, UnreachableCode());
177 <<
"Global refinement: " << global_refinement <<
"\n"
178 <<
"Degree: " << degree <<
"\n"
179 <<
"Adaptivity enabled: " << bool_to_string(has_adaptivity) <<
"\n"
180 <<
"Max refinement: " << max_refinement <<
"\n"
181 <<
"Min refinement: " << min_refinement <<
"\n"
182 <<
"Remeshing period: " << remeshing_period <<
"\n";
184 if (!refinement_criteria.empty())
188 for (
const auto &criterion : refinement_criteria)
191 <<
" Variable name: " << criterion.variable_name <<
"\n"
192 <<
" Variable index: " << criterion.variable_index <<
"\n"
193 <<
" Criterion type: " << criterion.criterion_to_string() <<
"\n"
194 <<
" Value lower bound: " << criterion.value_lower_bound <<
"\n"
195 <<
" Value upper bound: " << criterion.value_upper_bound <<
"\n"
196 <<
" Gradient lower bound: " << criterion.gradient_lower_bound <<
"\n\n";
201PRISMS_PF_END_NAMESPACE
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:22
Struct that holds spatial discretization parameters.
Definition spatial_discretization.h:20
TriangulationType
Internal enum for various triangulation types.
Definition spatial_discretization.h:26
void postprocess_and_validate()
Postprocess and validate parameters.
Definition spatial_discretization.h:85
void print_parameter_summary() const
Print parameters to summary.log.
Definition spatial_discretization.h:137
spatialDiscretization()
Constructor.
Definition spatial_discretization.h:34