Skip to content

Commit

Permalink
tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Nov 2, 2024
1 parent 773d189 commit fde4e14
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 285 deletions.
8 changes: 4 additions & 4 deletions include/EquationDependencyParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class EquationDependencyParser
/*
* Method to strip excess whitespace for the dependency lists
*/
void
static void
strip_dependency_whitespace(std::string &dependency_list);

/**
* Method to parse the RHS dependency strings and populate the vectors for
* whether values, gradients, or hessians are needed.
*/
void
static void
parseDependencyListRHS(
std::vector<std::string> &variable_name_list,
std::vector<PDEType> variable_eq_type,
Expand All @@ -76,7 +76,7 @@ class EquationDependencyParser
* Method to parse the LHS dependency strings and populate the vectors for
* whether values, gradients, or hessians are needed.
*/
void
static void
parseDependencyListLHS(
std::vector<std::string> &variable_name_list,
std::vector<PDEType> variable_eq_type,
Expand All @@ -92,7 +92,7 @@ class EquationDependencyParser
* Method to parse the postprocessing dependency strings and populate the
* vectors for whether values, gradients, or hessians are needed.
*/
void
static void
parseDependencyListPP(
std::vector<std::string> &variable_name_list,
unsigned int variable_index,
Expand Down
4 changes: 2 additions & 2 deletions include/SolverParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class NonlinearSolverParameters : public SolverParametersBase
* Method to get the maximum number of allowed iterations for the nonlinear
* solver.
*/
double
getMaxIterations();
[[nodiscard]] double
getMaxIterations() const;

/**
* Method to load the parameters for one governing equation into the class.
Expand Down
16 changes: 8 additions & 8 deletions include/inputFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ class inputFileReader

// Method to get a list of entry values from multiple subsections in an input
// file
[[nodiscard]] std::vector<std::string>
[[nodiscard]] static std::vector<std::string>
get_subsection_entry_list(const std::string &parameters_file_name,
const std::string &subsec_name,
const std::string &entry_name,
const std::string &default_entry) const;
const std::string &default_entry);

// Method to count the number of related entries in an input file
[[nodiscard]] unsigned int
[[nodiscard]] static unsigned int
get_number_of_entries(const std::string &parameters_file_name,
const std::string &keyword,
const std::string &entry_name) const;
const std::string &entry_name);

// Get the trailing part of the entry name after a specified string (used to
// extract the model constant names)
[[nodiscard]] std::vector<std::string>
[[nodiscard]] static std::vector<std::string>
get_entry_name_ending_list(const std::string &parameters_file_name,
const std::string &keyword,
const std::string &entry_name_begining) const;
const std::string &entry_name_begining);

// Method to declare the parameters to be read from an input file
void
Expand All @@ -48,12 +48,12 @@ class inputFileReader
const std::vector<bool> &var_nucleates) const;

// Method to check if a line has the desired contents and if so, extract it
bool
static bool
parse_line(std::string line,
const std::string &keyword,
const std::string &entry_name,
std::string &out_string,
bool expect_equals_sign) const;
bool expect_equals_sign);

// Variables
dealii::ParameterHandler parameter_handler;
Expand Down
39 changes: 20 additions & 19 deletions src/EquationDependencyParser/EquationDependencyParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EquationDependencyParser::parse(std::vector<std::string> &var_name,
std::vector<bool> &var_nonlinear)
{
// Determine the number of variables
size_t n_variables = var_name.size();
const size_t n_variables = var_name.size();

// Resize the dependency evaluation flag vectors
eval_flags_explicit_RHS.resize(n_variables, dealii::EvaluationFlags::nothing);
Expand All @@ -47,7 +47,7 @@ EquationDependencyParser::parse(std::vector<std::string> &var_name,
// Now check for each variable_eq_type
if (var_eq_type[i] == EXPLICIT_TIME_DEPENDENT)
{
bool single_var_nonlinear;
bool single_var_nonlinear = false;

parseDependencyListRHS(var_name,
var_eq_type,
Expand All @@ -62,7 +62,7 @@ EquationDependencyParser::parse(std::vector<std::string> &var_name,
}
else if (var_eq_type[i] == AUXILIARY)
{
bool single_var_nonlinear;
bool single_var_nonlinear = false;

parseDependencyListRHS(var_name,
var_eq_type,
Expand All @@ -78,7 +78,8 @@ EquationDependencyParser::parse(std::vector<std::string> &var_name,
else if (var_eq_type[i] == IMPLICIT_TIME_DEPENDENT ||
var_eq_type[i] == TIME_INDEPENDENT)
{
bool single_var_nonlinear_RHS, single_var_nonlinear_LHS;
bool single_var_nonlinear_RHS = false;
bool single_var_nonlinear_LHS = false;

parseDependencyListRHS(var_name,
var_eq_type,
Expand Down Expand Up @@ -116,18 +117,18 @@ EquationDependencyParser::parseDependencyListRHS(
bool &is_nonlinear)
{
// Split the dependency strings into lists of entries
std::vector<std::string> split_value_dependency_list =
const std::vector<std::string> split_value_dependency_list =
dealii::Utilities::split_string_list(value_dependencies);
std::vector<std::string> split_gradient_dependency_list =
dealii::Utilities::split_string_list(gradient_dependencies);

// Check if either is empty and set value and gradient flags for the
// residual appropriately
if (split_value_dependency_list.size() > 0)
if (!split_value_dependency_list.empty())
{
residual_flags[variable_index] |= dealii::EvaluationFlags::values;
}
if (split_gradient_dependency_list.size() > 0)
if (!split_gradient_dependency_list.empty())
{
residual_flags[variable_index] |= dealii::EvaluationFlags::gradients;
}
Expand Down Expand Up @@ -166,15 +167,15 @@ EquationDependencyParser::parseDependencyListRHS(
variable.end());

// Is the variable we are finding the dependencies for explicit
bool variable_is_explicit =
const bool variable_is_explicit =
variable_eq_type[variable_index] == EXPLICIT_TIME_DEPENDENT;

// Is the dependency variable explicit
bool dependency_variable_is_explicit =
const bool dependency_variable_is_explicit =
variable_eq_type[dependency_variable_index] == EXPLICIT_TIME_DEPENDENT;

// Is the dependency the variable
bool same_variable = variable_index == dependency_variable_index;
const bool same_variable = variable_index == dependency_variable_index;

// Case if the dependency is x
if (dependency == variable)
Expand Down Expand Up @@ -225,18 +226,18 @@ EquationDependencyParser::parseDependencyListLHS(
bool &is_nonlinear)
{
// Split the dependency strings into lists of entries
std::vector<std::string> split_value_dependency_list =
const std::vector<std::string> split_value_dependency_list =
dealii::Utilities::split_string_list(value_dependencies);
std::vector<std::string> split_gradient_dependency_list =
dealii::Utilities::split_string_list(gradient_dependencies);

// Check if either is empty and set value and gradient flags for the
// residual appropriately
if (split_value_dependency_list.size() > 0)
if (!split_value_dependency_list.empty())
{
residual_flags[variable_index] |= dealii::EvaluationFlags::values;
}
if (split_gradient_dependency_list.size() > 0)
if (!split_gradient_dependency_list.empty())
{
residual_flags[variable_index] |= dealii::EvaluationFlags::gradients;
}
Expand Down Expand Up @@ -291,7 +292,7 @@ EquationDependencyParser::parseDependencyListLHS(
variable.end());

// Is the variable we are finding the dependencies for explicit
bool dependency_variable_is_explicit =
const bool dependency_variable_is_explicit =
variable_eq_type[dependency_variable_index] == EXPLICIT_TIME_DEPENDENT;

// Case if the dependency is x
Expand Down Expand Up @@ -380,8 +381,8 @@ EquationDependencyParser::pp_parse(std::vector<std::string> &var_name,
std::vector<std::string> sorted_dependencies_gradient)
{
// Determine the number of variables
size_t n_variables = var_name.size();
size_t n_postprocess_variables = pp_var_name.size();
const size_t n_variables = var_name.size();
const size_t n_postprocess_variables = pp_var_name.size();

// Resize the dependency evaluation flag vectors
eval_flags_postprocess.resize(n_variables, dealii::EvaluationFlags::nothing);
Expand Down Expand Up @@ -416,18 +417,18 @@ EquationDependencyParser::parseDependencyListPP(
std::vector<dealii::EvaluationFlags::EvaluationFlags> &residual_flags)
{
// Split the dependency strings into lists of entries
std::vector<std::string> split_value_dependency_list =
const std::vector<std::string> split_value_dependency_list =
dealii::Utilities::split_string_list(value_dependencies);
std::vector<std::string> split_gradient_dependency_list =
dealii::Utilities::split_string_list(gradient_dependencies);

// Check if either is empty and set value and gradient flags for the
// residual appropriately
if (split_value_dependency_list.size() > 0)
if (!split_value_dependency_list.empty())
{
residual_flags[variable_index] |= dealii::EvaluationFlags::values;
}
if (split_gradient_dependency_list.size() > 0)
if (!split_gradient_dependency_list.empty())
{
residual_flags[variable_index] |= dealii::EvaluationFlags::gradients;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SolverParameters/SolverParameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ NonlinearSolverParameters::setMaxIterations(unsigned int _max_iterations)
}

double
NonlinearSolverParameters::getMaxIterations()
NonlinearSolverParameters::getMaxIterations() const
{
return max_iterations;
}
Loading

0 comments on commit fde4e14

Please sign in to comment.