Skip to content

Commit

Permalink
added more intuitive insertion functions for equation dependencies (#371
Browse files Browse the repository at this point in the history
)

now the old functions just call the new ones
  • Loading branch information
fractalsbyx authored Dec 20, 2024
1 parent 28d406d commit a076c62
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 34 deletions.
64 changes: 58 additions & 6 deletions include/core/variableAttributeLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class variableAttributeLoader
set_variable_equation_type(const unsigned int &index, const PDEType &var_eq_type) const;

/**
* \brief Set the dependencies for the value term of the RHS equation of the variable at
* \brief Add dependencies for the value term of the RHS equation of the variable at
* `index`.
*
* \param index Index of variable
Expand All @@ -75,7 +75,7 @@ class variableAttributeLoader
const std::string &dependencies);

/**
* \brief Set the dependencies for the gradient term of the RHS equation of the variable
* \brief Add dependencies for the gradient term of the RHS equation of the variable
* at `index`.
*
* \param index Index of variable
Expand All @@ -87,7 +87,7 @@ class variableAttributeLoader
const std::string &dependencies);

/**
* \brief Set the dependencies for the value term of the LHS equation of the variable at
* \brief Add dependencies for the value term of the LHS equation of the variable at
* `index`.
*
* \param index Index of variable
Expand All @@ -99,7 +99,7 @@ class variableAttributeLoader
const std::string &dependencies) const;

/**
* \brief Set the dependencies for the gradient term of the LHS equation of the variable
* \brief Add dependencies for the gradient term of the LHS equation of the variable
* at `index`.
*
* \param index Index of variable
Expand All @@ -110,6 +110,58 @@ class variableAttributeLoader
set_dependencies_gradient_term_LHS(const unsigned int &index,
const std::string &dependencies) const;

/**
* \brief Insert dependencies for the value term of the RHS equation of the variable at
* `index`.
*
* \param index Index of variable
* \param dependencies Container containing list of dependency strings for
* variable at `index` Hint: {"variable", "grad(variable)", "hess(variable)"}
*/
template <typename Iterable>
void
insert_dependencies_value_term_RHS(const unsigned int &index,
const Iterable &dependencies);

/**
* \brief Insert dependencies for the gradient term of the RHS equation of the variable
* at `index`.
*
* \param index Index of variable
* \param dependencies Container containing list of dependency strings for
* variable at `index` Hint: {"variable", "grad(variable)", "hess(variable)"}
*/
template <typename Iterable>
void
insert_dependencies_gradient_term_RHS(const unsigned int &index,
const Iterable &dependencies);

/**
* \brief Insert dependencies for the value term of the LHS equation of the variable at
* `index`.
*
* \param index Index of variable
* \param dependencies Container containing list of dependency strings for
* variable at `index` Hint: {"variable", "grad(variable)", "hess(variable)"}
*/
template <typename Iterable>
void
insert_dependencies_value_term_LHS(const unsigned int &index,
const Iterable &dependencies) const;

/**
* \brief Insert dependencies for the gradient term of the LHS equation of the variable
* at `index`.
*
* \param index Index of variable
* \param dependencies Container containing list of dependency strings for
* variable at `index` Hint: {"variable", "grad(variable)", "hess(variable)"}
*/
template <typename Iterable>
void
insert_dependencies_gradient_term_LHS(const unsigned int &index,
const Iterable &dependencies) const;

/**
* \brief Flag whether the variable at `index` is needed to calculate the nucleation
* probability.
Expand Down Expand Up @@ -143,13 +195,13 @@ class variableAttributeLoader
/**
* \brief getter function for variable attributes list (copy).
*/
AttributesList
[[nodiscard]] AttributesList
get_var_attributes() const;

/**
* \brief getter function for postprocessing attributes list (copy).
*/
AttributesList
[[nodiscard]] AttributesList
get_pp_attributes() const;

/**
Expand Down
91 changes: 63 additions & 28 deletions src/core/variableAttributeLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,7 @@ variableAttributeLoader::set_dependencies_value_term_RHS(const unsigned int &ind
{
std::vector<std::string> dependencies_set =
dealii::Utilities::split_string_list(strip_whitespace(dependencies));
/* (*relevant_attributes)[index].dependencies_value_RHS =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end()); */
if (relevant_attributes != &pp_attributes)
{
var_attributes[index].dependencies_value_RHS =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
}
else
{
pp_attributes[index].dependencies_value_PP =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
}
insert_dependencies_value_term_RHS(index, dependencies_set);
}

void
Expand All @@ -130,18 +119,7 @@ variableAttributeLoader::set_dependencies_gradient_term_RHS(
{
std::vector<std::string> dependencies_set =
dealii::Utilities::split_string_list(strip_whitespace(dependencies));
/* (*relevant_attributes)[index].dependencies_gradient_RHS =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end()); */
if (relevant_attributes != &pp_attributes)
{
var_attributes[index].dependencies_gradient_RHS =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
}
else
{
pp_attributes[index].dependencies_gradient_PP =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
}
insert_dependencies_gradient_term_RHS(index, dependencies_set);
}

void
Expand All @@ -151,8 +129,7 @@ variableAttributeLoader::set_dependencies_value_term_LHS(
{
std::vector<std::string> dependencies_set =
dealii::Utilities::split_string_list(strip_whitespace(dependencies));
(*relevant_attributes)[index].dependencies_value_LHS =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
insert_dependencies_value_term_LHS(index, dependencies_set);
}

void
Expand All @@ -162,8 +139,66 @@ variableAttributeLoader::set_dependencies_gradient_term_LHS(
{
std::vector<std::string> dependencies_set =
dealii::Utilities::split_string_list(strip_whitespace(dependencies));
(*relevant_attributes)[index].dependencies_gradient_LHS =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
insert_dependencies_gradient_term_LHS(index, dependencies_set);
}

template <typename Iterable>
void
variableAttributeLoader::insert_dependencies_value_term_RHS(const unsigned int &index,
const Iterable &dependencies)
{
/* (*relevant_attributes)[index].dependencies_value_RHS.insert(dependencies.begin(),
* dependencies.end()); */
if (relevant_attributes != &pp_attributes)
{
var_attributes[index].dependencies_value_RHS.insert(dependencies.begin(),
dependencies.end());
}
else
{
pp_attributes[index].dependencies_value_PP.insert(dependencies.begin(),
dependencies.end());
}
}

template <typename Iterable>
void
variableAttributeLoader::insert_dependencies_gradient_term_RHS(
const unsigned int &index,
const Iterable &dependencies)
{
/* (*relevant_attributes)[index].dependencies_gradient_RHS.insert(dependencies.begin(),
* dependencies.end()); */
if (relevant_attributes != &pp_attributes)
{
var_attributes[index].dependencies_gradient_RHS.insert(dependencies.begin(),
dependencies.end());
}
else
{
pp_attributes[index].dependencies_gradient_PP.insert(dependencies.begin(),
dependencies.end());
}
}

template <typename Iterable>
void
variableAttributeLoader::insert_dependencies_value_term_LHS(
const unsigned int &index,
const Iterable &dependencies) const
{
(*relevant_attributes)[index].dependencies_value_LHS.insert(dependencies.begin(),
dependencies.end());
}

template <typename Iterable>
void
variableAttributeLoader::insert_dependencies_gradient_term_LHS(
const unsigned int &index,
const Iterable &dependencies) const
{
(*relevant_attributes)[index].dependencies_gradient_LHS.insert(dependencies.begin(),
dependencies.end());
}

void
Expand Down

0 comments on commit a076c62

Please sign in to comment.