20 "Base class for Post-Processors. For more general"
21 "information see \\ref doc_PostProcessors");
26 "Name of the post processor. This name will be used in many places so make "
27 "sure it's a useful name.");
30 std::vector<std::string>{
"SolverInitialized",
34 "List of events at which the post-processor will execute.");
38 std::vector<std::string>{
"SolverInitialized",
42 "List of events at which the post-processor will print. Make sure that "
44 "events are also set for the `PostProcessorPrinter` otherwise it wont "
51 "print_numeric_format",
"general",
"Numeric format to use.");
55 "print_numeric_format",
56 AllowableRangeList::New(
57 {
"fixed",
"floating_point",
"scientific",
"general"}));
60 "print_precision", 6,
"Number of digits to display after decimal point");
65 "Controls update events to only execute on the relevant solver's"
73 name_(params.GetParamValue<std::string>(
"name")),
74 subscribed_events_for_execution_(
75 params.GetParamVectorValue<std::string>(
"execute_on")),
76 subscribed_events_for_printing_(
77 params.GetParamVectorValue<std::string>(
"print_on")),
79 print_numeric_format_(ConstructNumericFormat(
80 params.GetParamValue<std::string>(
"print_numeric_format"))),
81 print_precision_(params.GetParamValue<size_t>(
"print_precision")),
82 solvername_filter_(params.GetParamValue<std::string>(
"solvername_filter"))
85 if (user_params.Has(
"initial_value"))
96 else if (format_string ==
"floating_point")
98 else if (format_string ==
"scientific")
100 else if (format_string ==
"general")
103 ChiLogicalError(
"Invalid numeric format string \"" + format_string +
"\"");
121 auto pp_ptr = std::dynamic_pointer_cast<PostProcessor>(new_object);
123 "Failure to cast new object to chi::PostProcessor");
128 auto new_subscriber = std::dynamic_pointer_cast<chi::EventSubscriber>(pp_ptr);
132 "Failure to cast chi::PostProcessor to chi::EventSubscriber");
135 publisher.AddSubscriber(new_subscriber);
146 if (event.
Code() >= 31 and event.
Code() <= 38 and
159 <<
event.Name() <<
"\".";
165const std::vector<PostProcessor::TimeHistoryEntry>&
181 std::string value_string;
184 value_string = value.
GetValue<
bool>() ?
"true" :
"false";
188 const auto dblval = value.
GetValue<
double>();
194 const std::string format_spec =
"%." + std::to_string(precision) +
"e";
195 snprintf(buffer, 30, format_spec.c_str(), dblval);
199 const std::string format_spec =
"%." + std::to_string(precision) +
"f";
200 snprintf(buffer, 30, format_spec.c_str(), dblval);
206 const std::string format_spec =
"%." + std::to_string(precision) +
"e";
207 snprintf(buffer, 30, format_spec.c_str(), dblval);
209 else if (dblval >= 1.0e-4 and dblval < 1.0e6)
211 const std::string format_spec =
"%." + std::to_string(precision) +
"f";
212 snprintf(buffer, 30, format_spec.c_str(), dblval);
216 const std::string format_spec =
"%." + std::to_string(precision) +
"e";
217 snprintf(buffer, 30, format_spec.c_str(), dblval);
221 value_string = buffer;
225 value_string = value.
GetValue<std::string>();
229 const auto intval = value.
GetValue<int64_t>();
231 snprintf(buffer, 30,
"%lld", intval);
232 value_string = buffer;
246 const auto& first_entry = value.
GetParam(0);
247 const auto first_entry_type = first_entry.
Type();
250 "The entries of the vector value of post-processor \"" +
251 Name() +
"\" must all be SCALAR.");
254 for (
const auto& entry : value)
257 entry.Type() != first_entry_type,
258 "Mixed typed encountered in the vector values of post-processor \"" +
269 std::replace(outstr.begin(), outstr.end(),
'\n',
' ');
276 const std::vector<ParameterBlockType> scalar_types = {
285 return std::find(scalar_types.begin(), scalar_types.end(), block_type) !=
291 else if (IsScalar(value.
Type()))
#define ChiLogicalErrorIf(condition, message)
#define ChiLogicalError(message)
static std::vector< chi::PostProcessorPtr > postprocessor_stack
static chi::InputParameters GetInputParameters()
const ParameterBlock & Parameters() const
const std::string & Name() const
size_t NumParameters() const
void RecursiveDumpToString(std::string &outstr, const std::string &offset="") const
T GetParamValue(const std::string ¶m_name) const
ParameterBlockType Type() const
ParameterBlock & GetParam(const std::string ¶m_name)
static PPNumericFormat ConstructNumericFormat(const std::string &format_string)
const size_t print_precision_
PostProcessor(const InputParameters ¶ms, PPType type)
virtual const std::vector< TimeHistoryEntry > & GetTimeHistory() const
std::vector< std::string > subscribed_events_for_printing_
static PPType FigureTypeFromValue(const ParameterBlock &value)
const PPNumericFormat print_numeric_format_
virtual const ParameterBlock & GetValue() const
std::vector< std::string > subscribed_events_for_execution_
void ReceiveEventUpdate(const Event &event) override
const std::string & Name() const
virtual void Execute(const Event &event_context)=0
size_t NumericPrecision() const
void SetType(PPType type)
std::string solvername_filter_
void PushOntoStack(std::shared_ptr< ChiObject > &new_object) override
std::vector< TimeHistoryEntry > time_history_
std::string ConvertValueToString(const ParameterBlock &value) const
std::string ConvertScalarValueToString(const ParameterBlock &value) const
static InputParameters GetInputParameters()
PPNumericFormat NumericFormat() const
const std::vector< std::string > & PrintScope() const
static PhysicsEventPublisher & GetInstance()
RegisterChiObjectParametersOnly(chi, PostProcessor)