PRISMS-PF Manual v3.0-pre
All Classes Functions Variables Enumerations Pages
variable_attribute_loader.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_attribute_loader_h
5#define variable_attribute_loader_h
6
7#include <prismspf/config.h>
8#include <prismspf/core/type_enums.h>
9#include <prismspf/core/variable_attributes.h>
10
11#include <map>
12#include <string>
13
14PRISMS_PF_BEGIN_NAMESPACE
15
20{
21public:
26
30 virtual ~variableAttributeLoader() = default;
31
37 void
39
43 [[nodiscard]] std::map<unsigned int, variableAttributes>
44 get_var_attributes() const;
45
46protected:
51 virtual void
53
60 void
61 set_variable_name(const unsigned int &index, const std::string &name);
62
70 void
71 set_variable_type(const unsigned int &index, const fieldType &field_type);
72
81 void
82 set_variable_equation_type(const unsigned int &index, const PDEType &pde_type);
83
90 void
91 set_is_postprocessed_field(const unsigned int &index, const bool &is_postprocess);
92
101 void
102 set_dependencies_value_term_RHS(const unsigned int &index,
103 const std::string &dependencies);
104
113 void
114 set_dependencies_gradient_term_RHS(const unsigned int &index,
115 const std::string &dependencies);
116
125 void
126 set_dependencies_value_term_LHS(const unsigned int &index,
127 const std::string &dependencies);
128
137 void
138 set_dependencies_gradient_term_LHS(const unsigned int &index,
139 const std::string &dependencies);
140
149 template <typename Iterable>
150 void
151 insert_dependencies_value_term_RHS(const unsigned int &index,
152 const Iterable &dependencies);
153
162 template <typename Iterable>
163 void
164 insert_dependencies_gradient_term_RHS(const unsigned int &index,
165 const Iterable &dependencies);
166
175 template <typename Iterable>
176 void
177 insert_dependencies_value_term_LHS(const unsigned int &index,
178 const Iterable &dependencies);
179
188 template <typename Iterable>
189 void
190 insert_dependencies_gradient_term_LHS(const unsigned int &index,
191 const Iterable &dependencies);
192
193private:
197 std::map<unsigned int, variableAttributes> var_attributes;
198
203 void
204 validate_attributes();
205
210 void
211 validate_variable_name(const std::string &name,
212 const std::set<std::string> &forbidden_names,
213 const std::string &context,
214 unsigned int index);
215
219 void
220 populate_dependencies(
221 const std::set<std::pair<std::string, std::string>> &reg_delimiters,
222 const std::set<std::pair<std::string, std::string>> &dep_type_delimiters,
223 const std::string &variable_name,
224 unsigned int index,
225 std::set<std::string> &reg_possible_deps,
226 std::map<unsigned int, std::set<std::string>> &change_possible_deps);
227
231 void
232 validate_dependencies(
233 const std::set<std::string> &dependencies,
234 const std::string &context,
235 unsigned int index,
236 const std::string &variable_name,
237 const std::set<std::string> &reg_possible_deps,
238 const std::map<unsigned int, std::set<std::string>> &change_possible_deps);
239
245 void
246 validate_old_solution_dependencies();
247
251 static std::string
252 strip_whitespace(const std::string &text);
253 // The above function should be moved to a 'utilities' module
254};
255
256// Template derived class for variableAttributeLoader for applications.
257// `loadVariableAttributes()` and `loadPostProcessorVariableAttributes()` are should be
258// filled out in all the applications.
260{
261public:
262 ~customAttributeLoader() override = default;
263
264 void
266};
267
268PRISMS_PF_END_NAMESPACE
269
270#endif
Definition variable_attribute_loader.h:260
void loadVariableAttributes() override
User-facing method where the variable attributes are set for solution fields and postprocess fields.
Class to manage the variable attributes that the user specifies.
Definition variable_attribute_loader.h:20
variableAttributeLoader()=default
Constructor.
std::map< unsigned int, variableAttributes > get_var_attributes() const
getter function for variable attributes list (copy).
Definition variable_attribute_loader.cc:59
void set_variable_equation_type(const unsigned int &index, const PDEType &pde_type)
Set the PDE type of the variable at index to pde_type where pde_typecan be EXPLICIT_TIME_DEPENDENT,...
Definition variable_attribute_loader.cc:89
void set_is_postprocessed_field(const unsigned int &index, const bool &is_postprocess)
Set the whether the field is a postprocessed field.
Definition variable_attribute_loader.cc:108
virtual ~variableAttributeLoader()=default
Destructor.
void set_variable_type(const unsigned int &index, const fieldType &field_type)
Set the field type of the variable at index to field_type where field_type can be SCALAR or VECTOR.
Definition variable_attribute_loader.cc:73
void set_dependencies_gradient_term_LHS(const unsigned int &index, const std::string &dependencies)
Add dependencies for the gradient term of the LHS equation of the variable at index.
Definition variable_attribute_loader.cc:143
void insert_dependencies_value_term_LHS(const unsigned int &index, const Iterable &dependencies)
Insert dependencies for the value term of the LHS equation of the variable at index.
Definition variable_attribute_loader.cc:173
virtual void loadVariableAttributes()
User-facing method where the variable attributes are set for solution fields and postprocess fields.
Definition variable_attribute_loader.cc:27
void insert_dependencies_value_term_RHS(const unsigned int &index, const Iterable &dependencies)
Insert dependencies for the value term of the RHS equation of the variable at index.
Definition variable_attribute_loader.cc:154
void insert_dependencies_gradient_term_LHS(const unsigned int &index, const Iterable &dependencies)
Insert dependencies for the gradient term of the LHS equation of the variable at index.
Definition variable_attribute_loader.cc:182
void set_dependencies_gradient_term_RHS(const unsigned int &index, const std::string &dependencies)
Add dependencies for the gradient term of the RHS equation of the variable at index.
Definition variable_attribute_loader.cc:124
void set_variable_name(const unsigned int &index, const std::string &name)
Set the name of the variable at index to name.
Definition variable_attribute_loader.cc:65
void insert_dependencies_gradient_term_RHS(const unsigned int &index, const Iterable &dependencies)
Insert dependencies for the gradient term of the RHS equation of the variable at index.
Definition variable_attribute_loader.cc:163
void init_variable_attributes()
Initialize the variable attributes from the two user-facing methods loadVariableAttributes() and load...
Definition variable_attribute_loader.cc:31
void set_dependencies_value_term_LHS(const unsigned int &index, const std::string &dependencies)
Add dependencies for the value term of the LHS equation of the variable at index.
Definition variable_attribute_loader.cc:134
void set_dependencies_value_term_RHS(const unsigned int &index, const std::string &dependencies)
Add dependencies for the value term of the RHS equation of the variable at index.
Definition variable_attribute_loader.cc:115