7#include <deal.II/numerics/vector_tools.h>
9#include <prismspf/config.h>
10#include <prismspf/core/constraint_handler.h>
11#include <prismspf/core/dof_handler.h>
12#include <prismspf/core/exceptions.h>
13#include <prismspf/core/initial_conditions.h>
14#include <prismspf/core/invm_handler.h>
15#include <prismspf/core/matrix_free_handler.h>
16#include <prismspf/core/solution_handler.h>
17#include <prismspf/core/type_enums.h>
18#include <prismspf/core/variable_attributes.h>
19#include <prismspf/user_inputs/user_input_parameters.h>
21PRISMS_PF_BEGIN_NAMESPACE
26template <
int dim,
int degree,
typename number>
32template <
int dim,
int degree>
46 const dealii::MappingQ1<dim> &_mapping,
141template <
int dim,
int degree>
148 const dealii::MappingQ1<dim> &_mapping,
150 : user_inputs(_user_inputs)
151 , matrix_free_handler(_matrix_free_handler)
152 , invm_handler(_invm_handler)
153 , constraint_handler(_constraint_handler)
154 , dof_handler(_dof_handler)
156 , solution_handler(_solution_handler)
159template <
int dim,
int degree>
162 const fieldSolveType &field_solve_type)
164 Assert((field_solve_type == fieldSolveType::EXPLICIT ||
165 field_solve_type == fieldSolveType::EXPLICIT_POSTPROCESS ||
166 field_solve_type == fieldSolveType::EXPLICIT_CONSTANT),
168 "compute_subset_attributes() should only be used for "
169 "EXPLICIT, EXPLICIT_POSTPROCESS, and EXPLICIT_CONSTANT fieldSolveTypes"));
171 subset_attributes.clear();
173 for (
const auto &[index, variable] : user_inputs.var_attributes)
175 if (variable.field_solve_type == field_solve_type)
177 subset_attributes.emplace(index, variable);
182template <
int dim,
int degree>
187 auto &dependency_flag_set = subset_attributes.begin()->second.eval_flag_set_RHS;
188 for (
const auto &[index, variable] : subset_attributes)
190 if (!variable.eval_flag_set_RHS.empty())
192 for (
const auto &[pair, flag] : variable.eval_flag_set_RHS)
194 dependency_flag_set[pair] |= flag;
198 for (
auto &[index, variable] : subset_attributes)
200 for (
const auto &[pair, flag] : dependency_flag_set)
202 variable.eval_flag_set_RHS[pair] |= flag;
207 auto &dependency_set = subset_attributes.begin()->second.dependency_set_RHS;
208 for (
const auto &[index, variable] : subset_attributes)
210 for (
const auto &[index, map] : variable.dependency_set_RHS)
212 for (
const auto &[dependency_type, field_type] : map)
214 dependency_set[index].emplace(dependency_type, field_type);
218 for (
auto &[index, variable] : subset_attributes)
220 variable.dependency_set_RHS = dependency_set;
228template <
int dim,
int degree>
232 for (
const auto &[index, variable] : subset_attributes)
234 Assert(dof_handler.get_dof_handlers().size() > index,
236 "The const DoFHandler set is smaller than the given index = " +
237 std::to_string(index)));
238 Assert(subset_attributes.find(index) != subset_attributes.end(),
240 "There is no entry in the attribute subset for the given index = " +
241 std::to_string(index)));
242 Assert(solution_handler.solution_set.find(
243 std::make_pair(index, dependencyType::NORMAL)) !=
244 solution_handler.solution_set.end(),
245 dealii::ExcMessage(
"There is no solution vector for the given index = " +
246 std::to_string(index) +
247 " and type = " + to_string(dependencyType::NORMAL)));
249 dealii::VectorTools::interpolate(
251 *(dof_handler.get_dof_handlers().at(index)),
253 *(solution_handler.solution_set.at(
254 std::make_pair(index, dependencyType::NORMAL))));
258template <
int dim,
int degree>
263 <<
" ==============================================\n"
264 <<
" Shared dependency set\n"
265 <<
" ==============================================\n";
266 const auto &dependency_set = subset_attributes.begin()->second.dependency_set_RHS;
267 for (
const auto &[index, map] : dependency_set)
269 for (
const auto &[dependency_type, field_type] : map)
272 <<
" Index: " << index <<
" Dependency: " << to_string(dependency_type)
273 <<
" Field: " << to_string(field_type) <<
"\n";
279PRISMS_PF_END_NAMESPACE
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:22
The class handles the generation and application of boundary conditions based on the user-inputs.
Definition constraint_handler.h:25
Definition explicit_base.h:27
Class that manages the deal.II DoFHandlers.
Definition dof_handler.h:25
Base class for explicit solves.
Definition explicit_base.h:34
const userInputParameters< dim > & user_inputs
User-inputs.
Definition explicit_base.h:98
explicitBase(const userInputParameters< dim > &_user_inputs, const matrixfreeHandler< dim > &_matrix_free_handler, const invmHandler< dim, degree > &_invm_handler, const constraintHandler< dim > &_constraint_handler, const dofHandler< dim > &_dof_handler, const dealii::MappingQ1< dim > &_mapping, solutionHandler< dim > &_solution_handler)
Constructor.
Definition explicit_base.h:142
const matrixfreeHandler< dim > & matrix_free_handler
Matrix-free object handler for non-multigrid data.
Definition explicit_base.h:103
solutionHandler< dim > & solution_handler
Solution handler.
Definition explicit_base.h:128
void set_initial_condition()
Set the initial condition according to subset_attributes.
Definition explicit_base.h:230
const constraintHandler< dim > & constraint_handler
Constraint handler.
Definition explicit_base.h:113
void compute_subset_attributes(const fieldSolveType &field_solve_type)
Compute the subset of variableAttributes that belongs to a given fieldSolveType. This function should...
Definition explicit_base.h:161
void compute_shared_dependencies()
Compute the shared dependency set and copy it to all eval_flag_set_RHS. Also do something similar wit...
Definition explicit_base.h:184
std::map< unsigned int, variableAttributes > subset_attributes
Subset of variable attributes.
Definition explicit_base.h:133
std::unique_ptr< SystemMatrixType > system_matrix
PDE operator.
Definition explicit_base.h:138
virtual void init()=0
Initialize system.
void print()
Print dependency_set_RHS to summary.log.
Definition explicit_base.h:260
const dealii::MappingQ1< dim > & mapping
Mappings to and from reference cell.
Definition explicit_base.h:123
virtual void solve()=0
Solve a single update step.
const dofHandler< dim > & dof_handler
DoF handler.
Definition explicit_base.h:118
~explicitBase()=default
Destructor.
const invmHandler< dim, degree > & invm_handler
invm handler.
Definition explicit_base.h:108
Function for user-implemented initial conditions. These are only ever calculated for explicit time de...
Definition initial_conditions.h:30
This class handles the computation and access of the inverted mass matrix for explicit solves.
Definition invm_handler.h:25
This class handlers the management and access of the matrix-free objects.
Definition matrix_free_handler.h:25
Class that manages solution initialization and swapping with old solutions.
Definition solution_handler.h:22