6#include <deal.II/base/exceptions.h>
7#include <deal.II/base/parameter_handler.h>
8#include <deal.II/base/types.h>
10#include <boost/algorithm/string/predicate.hpp>
15#include <prismspf/config.h>
113 [[nodiscard]]
unsigned int
122 [[nodiscard]]
const std::vector<InitialConditionFile> &
133 unsigned int max_criteria = 5)
const;
140 unsigned int max_criteria = 5);
153 for (
const auto &ic_file :
ic_files)
156 AssertThrow(ic_file.file_variable_names.size() ==
157 ic_file.simulation_variable_names.size(),
158 dealii::ExcMessage(
"The number of file variables must be the same as "
159 "the number of simulation variables"));
172 <<
"================================================\n"
173 <<
" Load IC Parameters\n"
174 <<
"================================================\n";
176 for (
const auto &ic_file :
ic_files)
179 <<
"File name: " << ic_file.filename <<
"\n"
180 <<
"Dataset format: " <<
to_string(ic_file.dataset_format) <<
"\n"
181 <<
"File variable names: ";
182 for (
const auto &file_variable_name : ic_file.file_variable_names)
187 <<
"Simulation variable names: ";
188 for (
const auto &simulation_variable_name : ic_file.simulation_variable_names)
195 for (
const auto &n_data_points : ic_file.n_data_points)
208 dealii::ParameterHandler ¶meter_handler,
209 unsigned int max_criteria)
const
211 parameter_handler.declare_entry(
"read initial conditions from file",
213 dealii::Patterns::Bool(),
214 "Whether to read any initial conditions from file.");
216 for (
unsigned int i = 0; i < max_criteria; i++)
218 parameter_handler.enter_subsection(
"initial condition file " + std::to_string(i));
220 parameter_handler.declare_entry(
"file name",
222 dealii::Patterns::Anything(),
223 "The file name to load from for each variable.");
224 parameter_handler.declare_entry(
"dataset format",
225 "vtk_unstructured_grid",
226 dealii::Patterns::Anything(),
227 "The type of grid in the file.");
228 parameter_handler.declare_entry(
"file variable names",
230 dealii::Patterns::List(
231 dealii::Patterns::Anything()),
232 "The name of the variable in the file.");
233 parameter_handler.declare_entry(
"simulation variable names",
235 dealii::Patterns::List(
236 dealii::Patterns::Anything()),
237 "The name of the variable in the file.");
238 parameter_handler.declare_entry(
239 "data points in x direction",
241 dealii::Patterns::Integer(-1, INT_MAX),
242 "The number of data points of the input file in the x direction.");
243 parameter_handler.declare_entry(
244 "data points in y direction",
246 dealii::Patterns::Integer(-1, INT_MAX),
247 "The number of data points of the input file in the y direction.");
248 parameter_handler.declare_entry(
249 "data points in z direction",
251 dealii::Patterns::Integer(-1, INT_MAX),
252 "The number of data points of the input file in the z direction.");
254 parameter_handler.leave_subsection();
260 dealii::ParameterHandler ¶meter_handler,
261 unsigned int max_criteria)
264 parameter_handler.get_bool(
"read initial conditions from file"));
265 static std::array<std::string, 3> axis_labels = {
268 for (
unsigned int i = 0; i < max_criteria; i++)
270 parameter_handler.enter_subsection(
"initial condition file " + std::to_string(i));
273 if (!parameter_handler.get(
"file name").empty())
277 ic_file.
filename = parameter_handler.get(
"file name");
278 const std::string type_string = parameter_handler.get(
"dataset format");
279 bool found_type =
false;
280 for (
unsigned int j = 0;
284 if (boost::iequals(type_string,
292 AssertThrow(found_type,
293 dealii::ExcMessage(
"Unsupported dataset format: " + type_string));
295 parameter_handler.get(
"file variable names"));
297 parameter_handler.get(
"simulation variable names"));
299 for (
unsigned int k = 0; k < 3; ++k)
302 static_cast<unsigned int>(parameter_handler.get_integer(
303 "data points in " + axis_labels.at(k) +
" direction"));
308 parameter_handler.leave_subsection();
312PRISMS_PF_END_NAMESPACE
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:35
Definition conditional_ostreams.cc:20
Struct that store the read-in information for a single file.
Definition load_initial_condition_parameters.h:28
std::vector< std::string > simulation_variable_names
Definition load_initial_condition_parameters.h:39
std::array< dealii::types::global_dof_index, 3 > n_data_points
Definition load_initial_condition_parameters.h:42
std::vector< std::string > file_variable_names
Definition load_initial_condition_parameters.h:36
DataFormatType dataset_format
Definition load_initial_condition_parameters.h:33
std::string filename
Definition load_initial_condition_parameters.h:30
Struct that stores relevant load initial condition information.
Definition load_initial_condition_parameters.h:51
void postprocess_and_validate()
Postprocess and validate parameters.
Definition load_initial_condition_parameters.h:151
bool read_initial_conditions_from_file
Definition load_initial_condition_parameters.h:144
unsigned int get_n_initial_condition_files() const
Get the number of initial condition files.
Definition load_initial_condition_parameters.h:114
void print_parameter_summary() const
Print parameters to summary.log.
Definition load_initial_condition_parameters.h:167
static constexpr unsigned int max_files
Maximum number of initial condition files.
Definition load_initial_condition_parameters.h:56
std::vector< InitialConditionFile > ic_files
Definition load_initial_condition_parameters.h:147
void add_initial_condition_file(InitialConditionFile _ic_file)
Add a initial condition file.
Definition load_initial_condition_parameters.h:102
const std::vector< InitialConditionFile > & get_initial_condition_files() const
Get the initial condition files.
Definition load_initial_condition_parameters.h:123
void declare_parameters(dealii::ParameterHandler ¶meter_handler, unsigned int max_criteria=5) const
Declare the parameters to be read from an input file.
Definition load_initial_condition_parameters.h:207
bool get_read_initial_conditions_from_file() const
Get the read initial conditions from file flag.
Definition load_initial_condition_parameters.h:93
void assign_parameters(dealii::ParameterHandler ¶meter_handler, unsigned int max_criteria=5)
Assign the parameters read from an input file to this object.
Definition load_initial_condition_parameters.h:259
void set_read_initial_conditions_from_file(bool _read_initial_conditions_from_file)
Set the read initial conditions from file flag.
Definition load_initial_condition_parameters.h:84
void clear()
Clear the initial condition parameters.
Definition load_initial_condition_parameters.h:74
std::string to_string(ElasticityModel type)
Enum to string for ElasticityModel.
Definition type_enums.h:164
DataFormatType
Data formats for input initial conditions. LastEntry is used for loop bounds.
Definition type_enums.h:154
@ FlatBinary
Definition type_enums.h:156
@ LastEntry
Definition type_enums.h:157