Skip to content

Commit

Permalink
unit test for nonlinear variables
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Jan 3, 2025
1 parent 6a88f68 commit cfd334e
Show file tree
Hide file tree
Showing 4 changed files with 386 additions and 15 deletions.
13 changes: 13 additions & 0 deletions include/core/variableAttributeLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class variableAttributeLoader
*/
variableAttributeLoader();

/**
* \brief Destructor.
*/
virtual ~variableAttributeLoader() = default;

/**
* \brief User-facing method where the variable attributes are set.
*/
Expand Down Expand Up @@ -204,6 +209,14 @@ class variableAttributeLoader
[[nodiscard]] AttributesList
get_pp_attributes() const;

protected:
/**
* \brief Initialize the attributes of the variables. This is done is the constructor of
* this class and must be called in constructors of child classes.
*/
void
init_attributes();

private:
/**
* \brief The solutions variable attributes
Expand Down
2 changes: 1 addition & 1 deletion include/core/variableAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using AttributesList = std::map<uint, variableAttributes>;
struct variableAttributes
{
// Variable attributes
std::string name = "";
std::string name;
fieldType var_type = UNDEFINED_FIELD;
PDEType eq_type = UNDEFINED_PDE;
bool need_value_nucleation = false;
Expand Down
42 changes: 28 additions & 14 deletions src/core/variableAttributeLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@

// NOLINTBEGIN(cppcoreguidelines-prefer-member-initializer)
variableAttributeLoader::variableAttributeLoader()
{
this->init_attributes();
}

// NOLINTEND(cppcoreguidelines-prefer-member-initializer)

void
variableAttributeLoader::loadVariableAttributes()
{}

void
variableAttributeLoader::loadPostProcessorVariableAttributes()
{}

void
variableAttributeLoader::init_attributes()
{
relevant_attributes = &var_attributes;
loadVariableAttributes();
Expand Down Expand Up @@ -45,8 +61,6 @@ variableAttributeLoader::variableAttributeLoader()
}
}

// NOLINTEND(cppcoreguidelines-prefer-member-initializer)

AttributesList
variableAttributeLoader::get_var_attributes() const
{
Expand Down Expand Up @@ -213,7 +227,7 @@ variableAttributeLoader::validate_variable_name(
" Variable names must not be empty.\nProblem index: " +
std::to_string(index)));

for (const std::string &forbidden_name : forbidden_names)
for ([[maybe_unused]] const std::string &forbidden_name : forbidden_names)
{
std::string error_message = "PRISMS-PF Error: " + context +
" Variable names must not contain \"grad()\", "
Expand Down Expand Up @@ -243,12 +257,12 @@ variableAttributeLoader::populate_dependencies(

void
variableAttributeLoader::validate_dependencies(
const std::set<std::string> &dependencies,
const std::string &context,
unsigned int index,
const std::string &variable_name,
const std::set<std::string> &reg_possible_deps,
const std::map<uint, std::set<std::string>> &change_possible_deps)
const std::set<std::string> &dependencies,
const std::string &context,
unsigned int index,
const std::string &variable_name,
[[maybe_unused]] const std::set<std::string> &reg_possible_deps,
[[maybe_unused]] const std::map<uint, std::set<std::string>> &change_possible_deps)
{
for (const std::string &dependency : dependencies)
{
Expand All @@ -270,11 +284,11 @@ variableAttributeLoader::validate_dependencies(

void
variableAttributeLoader::variableAttributeLoader::validate_postprocess_variable(
const std::string &name,
const std::set<std::string> &name_list,
const std::set<std::string> &reg_possible_deps,
const variableAttributes &pp_variable,
unsigned int index)
const std::string &name,
[[maybe_unused]] const std::set<std::string> &name_list,
[[maybe_unused]] const std::set<std::string> &reg_possible_deps,
const variableAttributes &pp_variable,
unsigned int index)
{
Assert(name_list.find(name) == name_list.end(),
dealii::ExcMessage("PRISMS-PF Error: Postprocess variable names must be "
Expand Down
Loading

0 comments on commit cfd334e

Please sign in to comment.