Skip to content

Commit

Permalink
minor refactor of inputFileReader and userInputs
Browse files Browse the repository at this point in the history
Mostly reorganization. Split the parameter_handler declarations into several functions rather than one 500-line function.
Object-oriented some functionality. Removed get_number_of_entries.
Renamed a few functions.
  • Loading branch information
fractalsbyx committed Dec 27, 2024
1 parent 062718f commit 05347e7
Show file tree
Hide file tree
Showing 4 changed files with 393 additions and 302 deletions.
106 changes: 86 additions & 20 deletions include/core/inputFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <string>
#include <vector>


/**
* \brief Input file reader.
* \brief Parameters file reader. Declares parameter names in a dealii parameter_handler
* and parses the file for the values. Variable assignment occurs in userInputParameters.
*/
class inputFileReader
{
Expand All @@ -28,35 +28,23 @@ class inputFileReader
* \brief Method to get a list of entry values from multiple subsections in an input
* file.
*/
[[nodiscard]] static std::vector<std::string>
get_subsection_entry_list(const std::string &parameters_file_name,
const std::string &subsec_name,
[[nodiscard]] std::vector<std::string>
get_subsection_entry_list(const std::string &subsec_name,
const std::string &entry_name,
const std::string &default_entry);

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

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

/**
* \brief Method to declare the parameters to be read from an input file.
*/
void
declare_parameters(dealii::ParameterHandler &parameter_handler,
const unsigned int num_of_constants) const;
declare_parameters();

/**
* \brief Method to check if a line has the desired contents and if so, extract it.
Expand All @@ -80,10 +68,88 @@ class inputFileReader
static bool
check_keyword_match(std::string &line, const std::string &keyword);

/**
* \brief Declare parameters for the mesh.
*/
void
declare_mesh();

/**
* \brief Declare parameters for timestepping.
*/
void
declare_time_discretization();

/**
* \brief Declare parameters for linear and nonlinear solvers.
*/
void
declare_solver_parameters();

/**
* \brief Declare parameters for outputs.
*/
void
declare_output_parameters();

/**
* \brief Declare parameters for loading ICs from files.
*/
void
declare_load_IC_parameters();

/**
* \brief Declare parameters for checkpoints.
*/
void
declare_checkpoint_parameters();

/**
* \brief Declare parameters for boundary conditions.
*/
void
declare_BC_parameters();

/**
* \brief Declare parameters for pinned points.
*/
void
declare_pinning_parameters();

/**
* \brief Declare parameters for nucleation
*/
void
declare_nucleation_parameters();

/**
* \brief Declare parameters for grain remapping.
*/
void
declare_grain_remapping_parameters();

/**
* \brief Declare parameters for grain structure loading.
*/
void
declare_grain_loading_parameters();

/**
* \brief Declare parameters for user-defined model constants.
*/
void
declare_model_constants();

/**
* \brief User defined parameter declarations.
*/
void
declare_user_constants();

const std::string parameters_file_name;
const AttributesList &var_attributes;
const AttributesList &pp_attributes;
dealii::ParameterHandler parameter_handler;
unsigned int num_constants;
std::set<std::string> model_constant_names;
unsigned int number_of_dimensions;
};
Expand Down
6 changes: 3 additions & 3 deletions include/core/userInputParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ class userInputParameters
const std::vector<unsigned int> &userGivenTimeStepList);

void
load_user_constants(inputFileReader &input_file_reader,
dealii::ParameterHandler &parameter_handler);
load_model_constants(inputFileReader &input_file_reader,
dealii::ParameterHandler &parameter_handler);

/**
* \brief Compute the number of tensor rows.
Expand Down Expand Up @@ -438,7 +438,7 @@ class userInputParameters
* \brief Assign the primitive user constants (e.g., int, double, bool).
*/
InputVariant<dim>
primitive_user_constant(std::vector<std::string> &model_constants_strings);
primitive_model_constant(std::vector<std::string> &model_constants_strings);

[[nodiscard]] dealii::Tensor<2, 2 * dim - 1 + dim / 3>
get_Cij_tensor(std::vector<double> elastic_constants,
Expand Down
Loading

0 comments on commit 05347e7

Please sign in to comment.