Skip to content

Commit

Permalink
Template instantiations for vector, set, list of inserted dependencies
Browse files Browse the repository at this point in the history
also removed const qualifier from insert functions. (Pointer contents are being modified)
  • Loading branch information
fractalsbyx committed Jan 30, 2025
1 parent 7f6931e commit 34d3266
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 26 deletions.
20 changes: 10 additions & 10 deletions include/core/variableAttributeLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class variableAttributeLoader
* \param name Name of variable at `index`
*/
void
set_variable_name(const unsigned int &index, const std::string &name) const;
set_variable_name(const unsigned int &index, const std::string &name);

/**
* \brief Set the field type of the variable at `index` to `var_type` where `var_type`
Expand All @@ -61,7 +61,7 @@ class variableAttributeLoader
* \param var_type Field type of variable at `index` (`SCALAR` or `VECTOR`).
*/
void
set_variable_type(const unsigned int &index, const fieldType &var_type) const;
set_variable_type(const unsigned int &index, const fieldType &var_type);

/**
* \brief Set the PDE type of the variable at `index` to `var_eq_type` where
Expand All @@ -72,7 +72,7 @@ class variableAttributeLoader
* \param var_eq_type PDE type of variable at `index`.
*/
void
set_variable_equation_type(const unsigned int &index, const PDEType &var_eq_type) const;
set_variable_equation_type(const unsigned int &index, const PDEType &var_eq_type);

/**
* \brief Add dependencies for the value term of the RHS equation of the variable at
Expand Down Expand Up @@ -108,7 +108,7 @@ class variableAttributeLoader
*/
void
set_dependencies_value_term_LHS(const unsigned int &index,
const std::string &dependencies) const;
const std::string &dependencies);

/**
* \brief Add dependencies for the gradient term of the LHS equation of the variable
Expand All @@ -120,7 +120,7 @@ class variableAttributeLoader
*/
void
set_dependencies_gradient_term_LHS(const unsigned int &index,
const std::string &dependencies) const;
const std::string &dependencies);

/**
* \brief Insert dependencies for the value term of the RHS equation of the variable at
Expand Down Expand Up @@ -159,7 +159,7 @@ class variableAttributeLoader
template <typename Iterable>
void
insert_dependencies_value_term_LHS(const unsigned int &index,
const Iterable &dependencies) const;
const Iterable &dependencies);

/**
* \brief Insert dependencies for the gradient term of the LHS equation of the variable
Expand All @@ -172,7 +172,7 @@ class variableAttributeLoader
template <typename Iterable>
void
insert_dependencies_gradient_term_LHS(const unsigned int &index,
const Iterable &dependencies) const;
const Iterable &dependencies);

/**
* \brief Flag whether the variable at `index` is needed to calculate the nucleation
Expand All @@ -182,7 +182,7 @@ class variableAttributeLoader
* \param flag true: variable is needed, false: variable is not needed.
*/
void
set_need_value_nucleation(const unsigned int &index, const bool &flag) const;
set_need_value_nucleation(const unsigned int &index, const bool &flag);

/**
* \brief Flag whether the variable at `index` is can have a nucleation event.
Expand All @@ -191,7 +191,7 @@ class variableAttributeLoader
* \param flag true: variable can nucleate, false: variable can not nucleate.
*/
void
set_allowed_to_nucleate(const unsigned int &index, const bool &flag) const;
set_allowed_to_nucleate(const unsigned int &index, const bool &flag);

/**
* \brief (Postprocess only) Flag whether the postprocessing variable at `index` should
Expand All @@ -202,7 +202,7 @@ class variableAttributeLoader
* false: do nothing
*/
void
set_output_integral(const unsigned int &index, const bool &flag) const;
set_output_integral(const unsigned int &index, const bool &flag);

protected:
/**
Expand Down
81 changes: 65 additions & 16 deletions src/core/variableAttributeLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,42 +68,41 @@ variableAttributeLoader::get_pp_attributes() const
// Methods to set the various variable attributes
void
variableAttributeLoader::set_variable_name(const unsigned int &index,
const std::string &name) const
const std::string &name)
{
(*relevant_attributes)[index].name = name;
}

void
variableAttributeLoader::set_variable_type(const unsigned int &index,
const fieldType &var_type) const
const fieldType &var_type)
{
(*relevant_attributes)[index].var_type = var_type;
}

void
variableAttributeLoader::set_variable_equation_type(const unsigned int &index,
const PDEType &var_eq_type) const
const PDEType &var_eq_type)
{
(*relevant_attributes)[index].eq_type = var_eq_type;
}

void
variableAttributeLoader::set_need_value_nucleation(const unsigned int &index,
const bool &flag) const
const bool &flag)
{
(*relevant_attributes)[index].need_value_nucleation = flag;
}

void
variableAttributeLoader::set_allowed_to_nucleate(const unsigned int &index,
const bool &flag) const
const bool &flag)
{
(*relevant_attributes)[index].nucleating_variable = flag;
}

void
variableAttributeLoader::set_output_integral(const unsigned int &index,
const bool &flag) const
variableAttributeLoader::set_output_integral(const unsigned int &index, const bool &flag)
{
(*relevant_attributes)[index].output_integral = flag;
(*relevant_attributes)[index].calc_integral = flag;
Expand All @@ -129,9 +128,8 @@ variableAttributeLoader::set_dependencies_gradient_term_RHS(
}

void
variableAttributeLoader::set_dependencies_value_term_LHS(
const unsigned int &index,
const std::string &dependencies) const
variableAttributeLoader::set_dependencies_value_term_LHS(const unsigned int &index,
const std::string &dependencies)
{
std::vector<std::string> dependencies_set =
dealii::Utilities::split_string_list(strip_whitespace(dependencies));
Expand All @@ -141,7 +139,7 @@ variableAttributeLoader::set_dependencies_value_term_LHS(
void
variableAttributeLoader::set_dependencies_gradient_term_LHS(
const unsigned int &index,
const std::string &dependencies) const
const std::string &dependencies)
{
std::vector<std::string> dependencies_set =
dealii::Utilities::split_string_list(strip_whitespace(dependencies));
Expand Down Expand Up @@ -189,9 +187,8 @@ variableAttributeLoader::insert_dependencies_gradient_term_RHS(

template <typename Iterable>
void
variableAttributeLoader::insert_dependencies_value_term_LHS(
const unsigned int &index,
const Iterable &dependencies) const
variableAttributeLoader::insert_dependencies_value_term_LHS(const unsigned int &index,
const Iterable &dependencies)
{
(*relevant_attributes)[index].dependencies_value_LHS.insert(dependencies.begin(),
dependencies.end());
Expand All @@ -201,7 +198,7 @@ template <typename Iterable>
void
variableAttributeLoader::insert_dependencies_gradient_term_LHS(
const unsigned int &index,
const Iterable &dependencies) const
const Iterable &dependencies)
{
(*relevant_attributes)[index].dependencies_gradient_LHS.insert(dependencies.begin(),
dependencies.end());
Expand Down Expand Up @@ -379,4 +376,56 @@ variableAttributeLoader::strip_whitespace(const std::string &_text)
std::string text = _text;
text.erase(std::remove(text.begin(), text.end(), ' '), text.end());
return text;
}
}

// Template instantiations
template void
variableAttributeLoader::insert_dependencies_value_term_RHS<std::vector<std::string>>(
const unsigned int &index,
const std::vector<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_gradient_term_RHS<std::vector<std::string>>(
const unsigned int &index,
const std::vector<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_value_term_LHS<std::vector<std::string>>(
const unsigned int &index,
const std::vector<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_gradient_term_LHS<std::vector<std::string>>(
const unsigned int &index,
const std::vector<std::string> &dependencies);

template void
variableAttributeLoader::insert_dependencies_value_term_RHS<std::set<std::string>>(
const unsigned int &index,
const std::set<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_gradient_term_RHS<std::set<std::string>>(
const unsigned int &index,
const std::set<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_value_term_LHS<std::set<std::string>>(
const unsigned int &index,
const std::set<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_gradient_term_LHS<std::set<std::string>>(
const unsigned int &index,
const std::set<std::string> &dependencies);

template void
variableAttributeLoader::insert_dependencies_value_term_RHS<std::list<std::string>>(
const unsigned int &index,
const std::list<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_gradient_term_RHS<std::list<std::string>>(
const unsigned int &index,
const std::list<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_value_term_LHS<std::list<std::string>>(
const unsigned int &index,
const std::list<std::string> &dependencies);
template void
variableAttributeLoader::insert_dependencies_gradient_term_LHS<std::list<std::string>>(
const unsigned int &index,
const std::list<std::string> &dependencies);

0 comments on commit 34d3266

Please sign in to comment.