PRISMS-PF Manual v3.0-pre
All Classes Functions Variables Enumerations Pages
variable_attributes.h
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#ifndef variable_attributes_h
5#define variable_attributes_h
6
7#include <deal.II/matrix_free/evaluation_flags.h>
8
9#include <prismspf/config.h>
10#include <prismspf/core/type_enums.h>
11#include <prismspf/core/types.h>
12
13#include <map>
14#include <set>
15#include <string>
16#include <unordered_map>
17
18PRISMS_PF_BEGIN_NAMESPACE
19
24{
25public:
26 template <typename T, typename U>
27 std::size_t
28 operator()(const std::pair<T, U> &x) const
29 {
30 return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
31 }
32};
33
39{
43 std::string name;
44
48 types::index field_index = numbers::invalid_index;
49
53 fieldType field_type = fieldType::UNDEFINED_FIELD;
54
58 PDEType pde_type = PDEType::UNDEFINED_PDE;
59
63 bool is_postprocess = false;
64
65#ifdef ADDITIONAL_OPTIMIZATIONS
69 mutable types::index duplicate_field_index = numbers::invalid_index;
70#endif
71
76 fieldSolveType field_solve_type = fieldSolveType::UNDEFINED_SOLVE;
77
81 std::set<std::string> dependencies_value_RHS;
82
86 std::set<std::string> dependencies_gradient_RHS;
87
92 std::set<std::string> dependencies_RHS;
93
97 std::set<std::string> dependencies_value_LHS;
98
102 std::set<std::string> dependencies_gradient_LHS;
103
108 std::set<std::string> dependencies_LHS;
109
115 std::unordered_map<std::pair<unsigned int, dependencyType>,
116 dealii::EvaluationFlags::EvaluationFlags,
117 pairHash>
119
125 std::unordered_map<std::pair<unsigned int, dependencyType>,
126 dealii::EvaluationFlags::EvaluationFlags,
127 pairHash>
129
134 dealii::EvaluationFlags::EvaluationFlags eval_flags_residual_RHS =
135 dealii::EvaluationFlags::nothing;
136
141 dealii::EvaluationFlags::EvaluationFlags eval_flags_residual_LHS =
142 dealii::EvaluationFlags::nothing;
143
149 std::map<unsigned int, std::map<dependencyType, fieldType>> dependency_set_RHS;
150
156 std::map<unsigned int, std::map<dependencyType, fieldType>> dependency_set_LHS;
157
165 std::set<unsigned int> simplified_dependency_set;
166
171 void
173
178 void
180
185 void
186 parse_dependencies(std::map<unsigned int, variableAttributes> &other_var_attributes);
187
192 void
194 std::map<unsigned int, variableAttributes> &other_var_attributes);
195
199 void
200 print() const;
201
202private:
206 void
207 validate_dependency(const std::string &variation,
208 dependencyType dep_type,
209 const unsigned int &other_index,
210 const std::string &context) const;
211
216 void
217 compute_dependency_set(
218 const std::map<unsigned int, variableAttributes> &other_var_attributes);
219
224 void
225 compute_simplified_dependency_set(
226 const std::map<unsigned int, variableAttributes> &other_var_attributes);
227
231 void
232 find_circular_dependencies(
233 const std::map<unsigned int, variableAttributes> &other_var_attributes);
234
238 void
239 recursive_DFS(const std::map<unsigned int, variableAttributes> &other_var_attributes,
240 std::set<unsigned int> &visited,
241 std::set<unsigned int> &current_stack,
242 const unsigned int &vertex);
243};
244
245PRISMS_PF_END_NAMESPACE
246
247#endif
Simple hash function for pairs.
Definition variable_attributes.h:24
Structure to hold the variable attributes of a field. This includes things like the name,...
Definition variable_attributes.h:39
std::set< std::string > dependencies_gradient_RHS
The user-inputted dependencies for the RHS gradient term.
Definition variable_attributes.h:86
void parse_dependencies(std::map< unsigned int, variableAttributes > &other_var_attributes)
Take user-defined dependency sets to set the evaluation flags for each variable.
Definition variable_attributes.cc:60
types::index field_index
Field index.
Definition variable_attributes.h:48
std::unordered_map< std::pair< unsigned int, dependencyType >, dealii::EvaluationFlags::EvaluationFlags, pairHash > eval_flag_set_LHS
A map of evaluation flags for the dependencies of the current variable's LHS. This will tell deal....
Definition variable_attributes.h:128
PDEType pde_type
PDE type (EXPLICIT/NONEXPLICIT).
Definition variable_attributes.h:58
std::set< std::string > dependencies_value_RHS
The user-inputted dependencies for the RHS value term.
Definition variable_attributes.h:81
std::set< std::string > dependencies_gradient_LHS
The user-inputted dependencies for the LHS gradient term.
Definition variable_attributes.h:102
std::map< unsigned int, std::map< dependencyType, fieldType > > dependency_set_RHS
A dependency set where the RHS evaluation flags that are not 0 (not nothing) are included....
Definition variable_attributes.h:149
std::set< std::string > dependencies_value_LHS
The user-inputted dependencies for the LHS value term.
Definition variable_attributes.h:97
dealii::EvaluationFlags::EvaluationFlags eval_flags_residual_RHS
Evaluation flags for the types of residual the user is expected to submit to on the RHS.
Definition variable_attributes.h:134
bool is_postprocess
Postprocess variable.
Definition variable_attributes.h:63
std::set< std::string > dependencies_LHS
The collection of value and gradient dependencies for the LHS.
Definition variable_attributes.h:108
std::map< unsigned int, std::map< dependencyType, fieldType > > dependency_set_LHS
A dependency set where the LHS evaluation flags that are not 0 (not nothing) are included....
Definition variable_attributes.h:156
std::string name
Field name.
Definition variable_attributes.h:43
std::set< unsigned int > simplified_dependency_set
A simplified set of evaluation flags for the dependencies of the current variable's LHS & RHS....
Definition variable_attributes.h:165
void format_dependencies()
Combine 'value' and 'gradient' residual dependencies to one dependency set per RHS and LHS....
Definition variable_attributes.cc:24
std::set< std::string > dependencies_RHS
The collection of value and gradient dependencies for the RHS.
Definition variable_attributes.h:92
fieldType field_type
Field type (SCALAR/VECTOR).
Definition variable_attributes.h:53
void determine_field_solve_type(std::map< unsigned int, variableAttributes > &other_var_attributes)
Using the assigned evaluation flags determine the solve type for this equation.
Definition variable_attributes.cc:197
void parse_residual_dependencies()
Take user-defined dependency sets to set the residual flags for each variable.
Definition variable_attributes.cc:36
std::unordered_map< std::pair< unsigned int, dependencyType >, dealii::EvaluationFlags::EvaluationFlags, pairHash > eval_flag_set_RHS
A map of evaluation flags for the dependencies of the current variable's RHS. This will tell deal....
Definition variable_attributes.h:118
fieldSolveType field_solve_type
Internal classification for the field solve type.
Definition variable_attributes.h:76
void print() const
Print variable attributes to summary.log.
Definition variable_attributes.cc:269
dealii::EvaluationFlags::EvaluationFlags eval_flags_residual_LHS
Evaluation flags for the types of residual the user is expected to submit to on the LHS....
Definition variable_attributes.h:141