6#include <deal.II/base/exceptions.h>
7#include <deal.II/base/parameter_handler.h>
16#include <prismspf/config.h>
50 template <
typename ListType>
63 if (num_increments == 0)
72 unsigned int period = std::max(1U, num_increments / num_outputs);
73 for (
unsigned int output = 0; output <= num_increments; output += period)
89 for (
unsigned int output = 1; output <= num_outputs; output++)
91 output_list.insert(
static_cast<unsigned int>(std::round(
92 std::pow(
double(num_increments),
double(output) /
double(num_outputs)))));
106 AssertThrow(num_increments > 1,
107 dealii::ExcMessage(
"For n per decaded spaced outputs, the number of "
108 "increments must be greater than 1."));
112 for (
unsigned int iteration = 2; iteration <= num_increments; iteration++)
114 const auto decade =
static_cast<unsigned int>(std::ceil(std::log10(iteration)));
115 const auto step_size =
116 static_cast<unsigned int>(std::pow(10, decade) / num_outputs);
117 if (iteration % step_size == 0)
136 [[nodiscard]]
unsigned int
193 <<
"================================================\n"
194 <<
" Output Parameters\n"
195 <<
"================================================\n"
196 <<
"Output file type: " <<
file_type <<
"\n"
197 <<
"Output file name: " <<
file_name <<
"\n"
214 parameter_handler.enter_subsection(
"output");
216 parameter_handler.declare_entry(
"directory",
218 dealii::Patterns::Anything(),
219 "The name of the output directory.");
220 parameter_handler.declare_entry(
"file name",
222 dealii::Patterns::Anything(),
223 "The prefix of the output files, before the "
224 "time step and processor info are added.");
225 parameter_handler.declare_entry(
228 dealii::Patterns::Selection(
"vtu|vtk|pvtu|xdmf"),
229 "The output file type (either vtu, pvtu, vtk, or xdmf).");
230 parameter_handler.declare_entry(
233 dealii::Patterns::Integer(0, INT_MAX),
234 "The number of subdivisions to apply to the mesh when building output patches.");
235 parameter_handler.declare_entry(
238 dealii::Patterns::Selection(
"EQUAL_SPACING|LOG_SPACING|N_PER_DECADE|LIST"),
239 "The spacing type for outputting the solution fields (either EQUAL_SPACING, "
240 "LOG_SPACING, N_PER_DECADE, or LIST).");
241 parameter_handler.declare_entry(
244 dealii::Patterns::List(dealii::Patterns::Integer(0, INT_MAX), 0, INT_MAX,
","),
245 "The list of time steps to output, used for the LIST type.");
246 parameter_handler.declare_entry(
"number",
248 dealii::Patterns::Integer(0, INT_MAX),
249 "The number of outputs (or number of outputs "
250 "per decade for the N_PER_DECADE type).");
251 parameter_handler.declare_entry(
254 dealii::Patterns::Integer(1, INT_MAX),
255 "The number of time steps between updates to the screen.");
256 parameter_handler.declare_entry(
257 "timing information with output",
259 dealii::Patterns::Bool(),
260 "Whether to print the summary table of the wall time and wall time for "
261 "individual subroutines every time the code outputs.");
262 parameter_handler.declare_alias(
"directory",
"folder name");
264 parameter_handler.leave_subsection();
271 parameter_handler.enter_subsection(
"output");
273 directory = parameter_handler.get(
"directory");
274 file_name = parameter_handler.get(
"file name");
275 file_type = parameter_handler.get(
"file type");
277 static_cast<unsigned int>(parameter_handler.get_integer(
"subdivisions"));
279 std::string condition = parameter_handler.get(
"condition");
280 unsigned int num_outputs =
281 static_cast<unsigned int>(parameter_handler.get_integer(
"number"));
282 unsigned int num_increments = temporal_discretization.
num_increments;
283 if (condition ==
"EQUAL_SPACING")
287 else if (condition ==
"LOG_SPACING")
291 else if (condition ==
"N_PER_DECADE")
296 dealii::Utilities::split_string_list(parameter_handler.get(
"list"))));
299 static_cast<unsigned int>(parameter_handler.get_integer(
"print step period"));
301 parameter_handler.get_bool(
"timing information with output");
303 parameter_handler.leave_subsection();
306PRISMS_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 holds output parameters.
Definition output_parameters.h:28
bool print_timing_with_output
Definition output_parameters.h:173
unsigned int patch_subdivisions
Definition output_parameters.h:166
void declare_parameters(dealii::ParameterHandler ¶meter_handler) const
Declare the parameters to be read from an input file.
Definition output_parameters.h:212
void add_log_spacing_outputs(unsigned int num_outputs, unsigned int num_increments)
Set the user output list.
Definition output_parameters.h:83
void clear_output_list()
Set the user output list.
Definition output_parameters.h:128
unsigned int print_output_period
Definition output_parameters.h:169
void add_output_list(const ListType &list)
Set the user output list.
Definition output_parameters.h:52
std::string file_name
Definition output_parameters.h:162
void print_parameter_summary() const
Print parameters to summary.log.
Definition output_parameters.h:190
std::set< unsigned int > output_list
Definition output_parameters.h:176
bool should_output(unsigned int increment) const
Return if the increment should be outputted.
Definition output_parameters.h:180
std::string file_type
Definition output_parameters.h:159
void add_n_per_decade_outputs(unsigned int num_outputs, unsigned int num_increments)
Set the user output list.
Definition output_parameters.h:100
void validate()
Postprocess and validate parameters.
Definition output_parameters.h:186
unsigned int get_num_outputs() const
Get the number of outputs that will be made.
Definition output_parameters.h:137
void add_equal_spacing_outputs(unsigned int num_outputs, unsigned int num_increments)
Set the user output list.
Definition output_parameters.h:61
void assign_parameters(dealii::ParameterHandler ¶meter_handler, const TemporalDiscretization &temporal_discretization)
Assign the parameters read from an input file to this object.
Definition output_parameters.h:268
std::string directory
Definition output_parameters.h:156
Struct that holds temporal discretization parameters.
Definition temporal_discretization.h:21
unsigned int num_increments
Definition temporal_discretization.h:68
const char * bool_to_string(bool boolean)
Convert bool to string.
Definition utilities.h:399