https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AdvancedOutput.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10// Standard includes
11#include <math.h>
12
13// MOOSE includes
14#include "AdvancedOutput.h"
15#include "DisplacedProblem.h"
16#include "FEProblem.h"
17#include "FileMesh.h"
18#include "FileOutput.h"
19#include "InfixIterator.h"
20#include "MooseApp.h"
21#include "MooseUtils.h"
22#include "MooseVariableFE.h"
23#include "Postprocessor.h"
24#include "Restartable.h"
25#include "VectorPostprocessor.h"
26
27#include "libmesh/fe_interface.h"
28
29// A function, only available in this file, for adding the AdvancedOutput parameters. This is
30// used to eliminate code duplication between the difference specializations of the validParams
31// function.
32namespace
33{
34void
35addAdvancedOutputParams(InputParameters & params)
36{
37 // Hide/show variable output options
38 params.addParam<std::vector<VariableName>>(
39 "hide",
40 {},
41 "A list of the variables and postprocessors that should NOT be output to the Exodus "
42 "file (may include Variables, ScalarVariables, and Postprocessor names).");
43
44 params.addParam<std::vector<VariableName>>(
45 "show",
46 {},
47 "A list of the variables and postprocessors that should be output to the Exodus file "
48 "(may include Variables, ScalarVariables, and Postprocessor names).");
49
50 // Enable output of PP/VPP to JSON
51 params.addParam<bool>(
52 "postprocessors_as_reporters", false, "Output Postprocessors values as Reporter values.");
53 params.addParam<bool>("vectorpostprocessors_as_reporters",
54 false,
55 "Output VectorsPostprocessors vectors as Reporter values.");
56
57 // Group for selecting the output
58 params.addParamNamesToGroup("hide show", "Selection/restriction of output");
59
60 // Group for converting outputs
61 params.addParamNamesToGroup("postprocessors_as_reporters vectorpostprocessors_as_reporters",
62 "Conversions before output");
63
64 // **** DEPRECATED PARAMS ****
65 params.addDeprecatedParam<bool>("output_postprocessors",
66 true,
67 "Enable/disable the output of postprocessors",
68 "'execute_postprocessors_on' has replaced this parameter");
69 params.addDeprecatedParam<bool>("execute_vector_postprocessors",
70 true,
71 "Enable/disable the output of vector postprocessors",
72 "'execute_vector_postprocessors_on' has replaced this parameter");
73 params.addDeprecatedParam<bool>("execute_system_information",
74 true,
75 "Enable/disable the output of the simulation information",
76 "'execute_system_information_on' has replaced this parameter");
77 params.addDeprecatedParam<bool>("execute_elemental_variables",
78 true,
79 "Enable/disable the output of elemental variables",
80 "'execute_elemental_on' has replaced this parameter");
81 params.addDeprecatedParam<bool>("execute_nodal_variables",
82 true,
83 "Enable/disable the output of nodal variables",
84 "'execute_nodal_on' has replaced this parameter");
85 params.addDeprecatedParam<bool>("execute_scalar_variables",
86 true,
87 "Enable/disable the output of aux scalar variables",
88 "'execute_scalars_on' has replaced this parameter");
89 params.addDeprecatedParam<bool>("execute_input",
90 true,
91 "Enable/disable the output of input file information",
92 "'execute_input_on' has replaced this parameter");
93}
94}
95
98{
99 // Get the parameters from the parent object
101 addAdvancedOutputParams(params);
102 return params;
103}
104
105// Defines the output types to enable for the AdvancedOutput object
108{
109 return MultiMooseEnum("nodal=0 elemental=1 scalar=2 postprocessor=3 vector_postprocessor=4 "
110 "input=5 system_information=6 reporter=7");
111}
112
113// Enables the output types (see getOutputTypes) for an AdvancedOutput object
115AdvancedOutput::enableOutputTypes(const std::string & names)
116{
117 // The parameters object that will be returned
119
120 // Get the MultiEnum of output types
121 MultiMooseEnum output_types = getOutputTypes();
122
123 // Update the enum of output types to append
124 if (names.empty())
125 output_types = output_types.getRawNames();
126 else
127 output_types = names;
128
129 // Add the parameters and return them
130 addValidParams(params, output_types);
131 return params;
132}
133
134// Constructor
136 : FileOutput(parameters),
137 _elemental_as_nodal(isParamValid("elemental_as_nodal") ? getParam<bool>("elemental_as_nodal")
138 : false),
139 _scalar_as_nodal(isParamValid("scalar_as_nodal") ? getParam<bool>("scalar_as_nodal") : false),
140 _reporter_data(_problem_ptr->getReporterData()),
141 _last_execute_time(declareRecoverableData<std::map<std::string, Real>>("last_execute_time")),
142 _postprocessors_as_reporters(getParam<bool>("postprocessors_as_reporters")),
143 _vectorpostprocessors_as_reporters(getParam<bool>("vectorpostprocessors_as_reporters"))
144{
145 _is_advanced = true;
147}
148
149void
154
155void
157{
158 // Initialize the execution flags
159 for (auto & [name, input] : _advanced_execute_on)
160 initExecutionTypes(name, input);
161
162 // Clear existing execute information lists
164
165 // Initialize the available output
167
168 // Separate the hide/show list into components
169 initShowHideLists(getParam<std::vector<VariableName>>("show"),
170 getParam<std::vector<VariableName>>("hide"));
171
172 // If 'elemental_as_nodal = true' the elemental variable names must be appended to the
173 // nodal variable names. Thus, when libMesh::EquationSystem::build_solution_vector is called
174 // it will create the correct nodal variable from the elemental
176 {
177 OutputData & nodal = _execute_data["nodal"];
178 OutputData & elemental = _execute_data["elemental"];
179 nodal.show.insert(elemental.show.begin(), elemental.show.end());
180 nodal.hide.insert(elemental.hide.begin(), elemental.hide.end());
181 nodal.available.insert(elemental.available.begin(), elemental.available.end());
182 }
183
184 // Similarly as above, if 'scalar_as_nodal = true' append the elemental variable lists
186 {
187 OutputData & nodal = _execute_data["nodal"];
188 OutputData & scalar = _execute_data["scalars"];
189 nodal.show.insert(scalar.show.begin(), scalar.show.end());
190 nodal.hide.insert(scalar.hide.begin(), scalar.hide.end());
191 nodal.available.insert(scalar.available.begin(), scalar.available.end());
192 }
193
194 // Initialize the show/hide/output lists for each of the types of output
195 for (auto & it : _execute_data)
196 initOutputList(it.second);
197}
198
200
201void
203{
204 mooseError("Individual output of nodal variables is not support for the output object named '",
205 name(),
206 "'");
207}
208
209void
211{
213 "Individual output of elemental variables is not support for this output object named '",
214 name(),
215 "'");
216}
217
218void
220{
221 mooseError("Individual output of postprocessors is not support for this output object named '",
222 name(),
223 "'");
224}
225
226void
228{
230 "Individual output of VectorPostprocessors is not support for this output object named '",
231 name(),
232 "'");
233}
234
235void
237{
239 "Individual output of scalars is not support for this output object named '", name(), "'");
240}
241
242void
244{
246 "Output of system information is not support for this output object named '", name(), "'");
247}
248
249void
251{
252 mooseError("Output of the input file information is not support for this output object named '",
253 name(),
254 "'");
255}
256
257void
259{
261 "Output of the Reporter value(s) is not support for this output object named '", name(), "'");
262}
263
264bool
266{
267 if (!checkFilename())
268 return false;
269
271 return true;
272 else
273 return Output::shouldOutput();
274}
275
276void
278{
279 const auto & type = _current_execute_flag;
280
281 // (re)initialize the list of available items for output
282 init();
283
284 // Call the various output types, if data exists
285 if (wantOutput("nodal", type))
286 {
288 _last_execute_time["nodal"] = _time;
289 }
290
291 if (wantOutput("elemental", type))
292 {
294 _last_execute_time["elemental"] = _time;
295 }
296
297 if (wantOutput("postprocessors", type))
298 {
300 _last_execute_time["postprocessors"] = _time;
301 }
302
303 if (wantOutput("vector_postprocessors", type))
304 {
306 _last_execute_time["vector_postprocessors"] = _time;
307 }
308
309 if (wantOutput("scalars", type))
310 {
312 _last_execute_time["scalars"] = _time;
313 }
314
315 if (wantOutput("system_information", type))
316 {
318 _last_execute_time["system_information"] = _time;
319 }
320
321 if (wantOutput("input", type))
322 {
323 outputInput();
324 _last_execute_time["input"] = _time;
325 }
326
327 if (wantOutput("reporters", type))
328 {
330 _last_execute_time["reporters"] = _time;
331 }
332}
333
334void
339
340bool
341AdvancedOutput::wantOutput(const std::string & name, const ExecFlagType & type)
342{
343 // Ignore EXEC_FORCED for system information and input, there is no reason to force this
344 if (type == EXEC_FORCED && (name == "system_information" || name == "input"))
345 return false;
346
347 // Do not output if the 'none' is contained by the execute_on
348 if (_advanced_execute_on.contains(name) && _advanced_execute_on[name].isValueSet("none"))
349 return false;
350
351 // Data output flag, true if data exists to be output
352 bool execute_data_flag = true;
353
354 // Set flag to false, if the OutputData exists and the output variable list is empty
355 std::map<std::string, OutputData>::const_iterator iter = _execute_data.find(name);
356 if (iter != _execute_data.end() && iter->second.output.empty())
357 execute_data_flag = false;
358
359 // Set flag to false, if the OutputOnWarehouse DOES NOT contain an entry
361 execute_data_flag = false;
362
363 // Force the output, if there is something to output and the time has not been output
364 if (type == EXEC_FORCED && execute_data_flag && _last_execute_time[name] != _time)
365 return true;
366
367 // Return true (output should occur) if three criteria are satisfied, else do not output:
368 // (1) The execute_data_flag = true (i.e, there is data to output)
369 // (2) The current output type is contained in the list of output execution types
370 // (3) The current execution time is "final" or "forced" and the data has not already been
371 // output
372 if (execute_data_flag && _advanced_execute_on[name].isValueSet(type) &&
374 return true;
375 else
376 return false;
377}
378
379bool
381{
382 // If any of the component outputs are true, then there is some output to perform
383 for (const auto & it : _advanced_execute_on)
384 if (wantOutput(it.first, type))
385 return true;
386
387 // There is nothing to output
388 return false;
389}
390
391bool
393{
394 // Test that variables exist for output AND that output execution flags are valid
395 for (const auto & it : _execute_data)
396 if (!(it.second).output.empty() && _advanced_execute_on.contains(it.first) &&
397 _advanced_execute_on[it.first].isValid())
398 return true;
399
400 // Test execution flags for non-variable output
401 if (_advanced_execute_on.contains("system_information") &&
402 _advanced_execute_on["system_information"].isValid())
403 return true;
404 if (_advanced_execute_on.contains("input") && _advanced_execute_on["input"].isValid())
405 return true;
406
407 return false;
408}
409
410void
412{
413 // Initialize Postprocessor list
414 // This flag is set to true if any postprocessor has the 'outputs' parameter set, it is then used
415 // to produce an warning if postprocessor output is disabled
417 initPostprocessorOrVectorPostprocessorLists<Postprocessor>("postprocessors");
418
419 // Initialize vector postprocessor list
420 // This flag is set to true if any vector postprocessor has the 'outputs' parameter set, it is
421 // then used
422 // to produce an warning if vector postprocessor output is disabled
424 initPostprocessorOrVectorPostprocessorLists<VectorPostprocessor>("vector_postprocessors");
425
426 // Get a list of the available variables
427 std::vector<VariableName> variables = _problem_ptr->getVariableNames();
428
429 // Loop through the variables and store the names in the correct available lists
430 for (const auto & var_name : variables)
431 {
432 if (_problem_ptr->hasVariable(var_name))
433 {
436
437 // Skip if the 'outputs' parameter has been set to exclude this output
438 if (var.isParamValid("outputs"))
439 {
440 const auto & outputs = var.getParam<std::vector<OutputName>>("outputs");
441 if (outputs.size() && std::find(outputs.begin(), outputs.end(), name()) == outputs.end() &&
442 outputs[0] != "all")
443 continue;
444 }
445
446 const FEType type = var.feType();
447 for (unsigned int i = 0; i < var.count(); ++i)
448 {
449 VariableName vname = var_name;
450 if (var.isArray())
451 vname = var.arrayVariableComponent(i);
452
453 // A note that if we have p-refinement we assume "worst-case" scenario that our constant
454 // monomial/monomial-vec families have been refined and we can no longer write them as
455 // elemental
456 if (type.order == CONSTANT && !_problem_ptr->havePRefinement() &&
457 type.family != MONOMIAL_VEC)
458 _execute_data["elemental"].available.insert(vname);
459 else if (FEInterface::field_type(type) == libMesh::TYPE_VECTOR)
460 {
461 const auto geom_type = ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT) &&
463 ? "elemental"
464 : "nodal";
466 {
467 case 0:
468 case 1:
469 _execute_data[geom_type].available.insert(vname);
470 break;
471 case 2:
472 _execute_data[geom_type].available.insert(vname + "_x");
473 _execute_data[geom_type].available.insert(vname + "_y");
474 break;
475 case 3:
476 _execute_data[geom_type].available.insert(vname + "_x");
477 _execute_data[geom_type].available.insert(vname + "_y");
478 _execute_data[geom_type].available.insert(vname + "_z");
479 break;
480 }
481 }
482 else
483 _execute_data["nodal"].available.insert(vname);
484 }
485 }
486
487 else if (_problem_ptr->hasScalarVariable(var_name))
488 _execute_data["scalars"].available.insert(var_name);
489 }
490
491 // Initialize Reporter name list
492 for (auto && r_name : _reporter_data.getReporterNames())
493 if ((_postprocessors_as_reporters || !r_name.isPostprocessor()) &&
494 (_vectorpostprocessors_as_reporters || !r_name.isVectorPostprocessor()))
495 _execute_data["reporters"].available.insert(r_name);
496}
497
498void
499AdvancedOutput::initExecutionTypes(const std::string & name, ExecFlagEnum & input)
500{
501 // Build the input parameter name
502 std::string param_name = "execute_";
503 param_name += name + "_on";
504
505 // The parameters exists and has been set by the user
506 if (_pars.have_parameter<ExecFlagEnum>(param_name) && isParamValid(param_name))
507 input = getParam<ExecFlagEnum>(param_name);
508
509 // If the parameter does not exists; set it to a state where no valid entries exists so nothing
510 // gets executed
511 else if (!_pars.have_parameter<ExecFlagEnum>(param_name))
512 {
513 input = _execute_on;
514 input.clearSetValues();
515 }
516}
517
518void
519AdvancedOutput::initShowHideLists(const std::vector<VariableName> & show,
520 const std::vector<VariableName> & hide)
521{
522
523 // Storage for user-supplied input that is unknown as a variable or postprocessor
524 std::set<std::string> unknown;
525
526 // If a show hide/list exists, let the data warehouse know about it. This allows for the proper
527 // handling of output lists (see initOutputList)
528 if (show.size() > 0)
530
531 // Populate the show lists
532 for (const auto & var_name : show)
533 {
534 if (_problem_ptr->hasVariable(var_name))
535 {
538 const FEType type = var.feType();
539 for (unsigned int i = 0; i < var.count(); ++i)
540 {
541 VariableName vname = var_name;
542 if (var.isArray())
543 vname = var.arrayVariableComponent(i);
544
545 if (type.order == CONSTANT)
546 _execute_data["elemental"].show.insert(vname);
547 else if (FEInterface::field_type(type) == libMesh::TYPE_VECTOR)
548 {
549 const auto geom_type =
550 ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT)) ? "elemental" : "nodal";
552 {
553 case 0:
554 case 1:
555 _execute_data[geom_type].show.insert(vname);
556 break;
557 case 2:
558 _execute_data[geom_type].show.insert(vname + "_x");
559 _execute_data[geom_type].show.insert(vname + "_y");
560 break;
561 case 3:
562 _execute_data[geom_type].show.insert(vname + "_x");
563 _execute_data[geom_type].show.insert(vname + "_y");
564 _execute_data[geom_type].show.insert(vname + "_z");
565 break;
566 }
567 }
568 else
569 _execute_data["nodal"].show.insert(vname);
570 }
571 }
572 else if (_problem_ptr->hasScalarVariable(var_name))
573 _execute_data["scalars"].show.insert(var_name);
574 else if (hasPostprocessorByName(var_name))
575 _execute_data["postprocessors"].show.insert(var_name);
576 else if (hasVectorPostprocessorByName(var_name))
577 _execute_data["vector_postprocessors"].show.insert(var_name);
578 else if ((var_name.find("/") != std::string::npos) &&
580 _execute_data["reporters"].show.insert(var_name);
581 else
582 unknown.insert(var_name);
583 }
584
585 // Populate the hide lists
586 for (const auto & var_name : hide)
587 {
588 if (_problem_ptr->hasVariable(var_name))
589 {
592 const FEType type = var.feType();
593 for (unsigned int i = 0; i < var.count(); ++i)
594 {
595 VariableName vname = var_name;
596 if (var.isArray())
597 vname = var.arrayVariableComponent(i);
598
599 if (type.order == CONSTANT)
600 _execute_data["elemental"].hide.insert(vname);
601 else if (FEInterface::field_type(type) == libMesh::TYPE_VECTOR)
602 {
604 {
605 case 0:
606 case 1:
607 _execute_data["nodal"].hide.insert(vname);
608 break;
609 case 2:
610 _execute_data["nodal"].hide.insert(vname + "_x");
611 _execute_data["nodal"].hide.insert(vname + "_y");
612 break;
613 case 3:
614 _execute_data["nodal"].hide.insert(vname + "_x");
615 _execute_data["nodal"].hide.insert(vname + "_y");
616 _execute_data["nodal"].hide.insert(vname + "_z");
617 break;
618 }
619 }
620 else
621 _execute_data["nodal"].hide.insert(vname);
622 }
623 }
624 else if (_problem_ptr->hasScalarVariable(var_name))
625 _execute_data["scalars"].hide.insert(var_name);
626 else if (hasPostprocessorByName(var_name))
627 _execute_data["postprocessors"].hide.insert(var_name);
628 else if (hasVectorPostprocessorByName(var_name))
629 _execute_data["vector_postprocessors"].hide.insert(var_name);
630 else if ((var_name.find("/") != std::string::npos) &&
632 _execute_data["reporters"].hide.insert(var_name);
633
634 else
635 unknown.insert(var_name);
636 }
637
638 // Error if an unknown variable or postprocessor is found
639 if (!unknown.empty())
640 {
641 std::ostringstream oss;
642 oss << "Output(s) do not exist (must be variable, scalar, postprocessor, or vector "
643 "postprocessor): ";
644 std::copy(unknown.begin(), unknown.end(), infix_ostream_iterator<std::string>(oss, " "));
645 mooseError(oss.str());
646 }
647}
648
649void
651{
652 // References to the vectors of variable names
653 std::set<std::string> & hide = data.hide;
654 std::set<std::string> & show = data.show;
655 std::set<std::string> & avail = data.available;
656 std::set<std::string> & output = data.output;
657
658 // Get the hide list from OutputInterface objects
659 std::set<std::string> interface_hide_all_types;
660 _app.getOutputWarehouse().buildInterfaceHideVariables(name(), interface_hide_all_types);
661
662 // OutputInterface hide list includes all types; only include those that are available
663 std::set<std::string> interface_hide;
664 std::set_intersection(interface_hide_all_types.begin(),
665 interface_hide_all_types.end(),
666 avail.begin(),
667 avail.end(),
668 std::inserter(interface_hide, interface_hide.begin()));
669
670 // Append to the hide list from OutputInterface objects
671 hide.insert(interface_hide.begin(), interface_hide.end());
672
673 // Both show and hide are empty and no show/hide settings were provided (show all available)
674 if (!_execute_data.hasShowList() && hide.empty())
675 output = avail;
676
677 // Only hide is empty (show all the variables listed)
678 else if (_execute_data.hasShowList() && hide.empty())
679 output = show;
680
681 // Only show is empty (show all except those hidden)
682 else if (!_execute_data.hasShowList() && !hide.empty())
683 std::set_difference(avail.begin(),
684 avail.end(),
685 hide.begin(),
686 hide.end(),
687 std::inserter(output, output.begin()));
688
689 // Both hide and show are present (show all those listed)
690 else // (_execute_data.hasShowList() && !hide.empty())
691 {
692 // Check if variables are in both, which is invalid
693 std::vector<std::string> tmp;
694 std::set_intersection(
695 hide.begin(), hide.end(), show.begin(), show.end(), std::inserter(tmp, tmp.begin()));
696 if (!tmp.empty())
697 {
698 std::ostringstream oss;
699 oss << "Output(s) specified to be both shown and hidden: ";
700 std::copy(tmp.begin(), tmp.end(), infix_ostream_iterator<std::string>(oss, " "));
701 mooseError(oss.str());
702 }
703
704 // Define the output variable list
705 output = show;
706 }
707}
708
709void
711{
713 empty_execute_on.addAvailableFlags(EXEC_FAILED);
714
715 // Nodal output
716 if (types.isValueSet("nodal"))
717 {
718 params.addParam<ExecFlagEnum>(
719 "execute_nodal_on", empty_execute_on, "Control the output of nodal variables");
720 params.addParamNamesToGroup("execute_nodal_on", "Selection/restriction of output");
721 }
722
723 // Elemental output
724 if (types.isValueSet("elemental"))
725 {
726 params.addParam<ExecFlagEnum>(
727 "execute_elemental_on", empty_execute_on, "Control the output of elemental variables");
728 params.addParamNamesToGroup("execute_elemental_on", "Selection/restriction of output");
729
730 // Add material output control, which are output via elemental variables
731 params.addParam<bool>("output_material_properties",
732 false,
733 "Flag indicating if material properties should be output");
734 params.addParam<std::vector<std::string>>(
735 "show_material_properties",
736 "List of material properties that should be written to the output");
737 params.addParamNamesToGroup("output_material_properties show_material_properties", "Materials");
738
739 // Add mesh extra element id control, which are output via elemental variables
740 params.addParam<bool>(
741 "output_extra_element_ids",
742 false,
743 "Flag indicating if extra element ids defined on the mesh should be outputted");
744 params.addParam<std::vector<std::string>>(
745 "extra_element_ids_to_output",
746 "List of extra element ids defined on the mesh that should be written to the output.");
747 params.addParamNamesToGroup("output_extra_element_ids extra_element_ids_to_output", "Mesh");
748 }
749
750 // Scalar variable output
751 if (types.isValueSet("scalar"))
752 {
753 params.addParam<ExecFlagEnum>(
754 "execute_scalars_on", empty_execute_on, "Control the output of scalar variables");
755 params.addParamNamesToGroup("execute_scalars_on", "Selection/restriction of output");
756 }
757
758 // Nodal and scalar output
759 if (types.isValueSet("nodal") && types.isValueSet("scalar"))
760 {
761 params.addParam<bool>("scalar_as_nodal", false, "Output scalar variables as nodal");
762 params.addParamNamesToGroup("scalar_as_nodal", "Conversions before output");
763 }
764
765 // Elemental and nodal
766 if (types.isValueSet("elemental") && types.isValueSet("nodal"))
767 {
768 params.addParam<bool>(
769 "elemental_as_nodal", false, "Output elemental nonlinear variables as nodal");
770 params.addParamNamesToGroup("elemental_as_nodal", "Conversions before output");
771 }
772
773 // Postprocessors
774 if (types.isValueSet("postprocessor"))
775 {
776 params.addParam<ExecFlagEnum>(
777 "execute_postprocessors_on", empty_execute_on, "Control of when postprocessors are output");
778 params.addParamNamesToGroup("execute_postprocessors_on", "Selection/restriction of output");
779 }
780
781 // Vector Postprocessors
782 if (types.isValueSet("vector_postprocessor"))
783 {
784 params.addParam<ExecFlagEnum>("execute_vector_postprocessors_on",
785 empty_execute_on,
786 "Enable/disable the output of VectorPostprocessors");
787 params.addParamNamesToGroup("execute_vector_postprocessors_on",
788 "Selection/restriction of output");
789 }
790
791 // Reporters
792 if (types.isValueSet("reporter"))
793 {
794 params.addParam<ExecFlagEnum>(
795 "execute_reporters_on", empty_execute_on, "Control of when Reporter values are output");
796 params.addParamNamesToGroup("execute_reporters_on", "Selection/restriction of output");
797 }
798
799 // Input file
800 if (types.isValueSet("input"))
801 {
802 params.addParam<ExecFlagEnum>(
803 "execute_input_on", empty_execute_on, "Enable/disable the output of the input file");
804 params.addParamNamesToGroup("execute_input_on", "Selection/restriction of output");
805 }
806
807 // System Information
808 if (types.isValueSet("system_information"))
809 {
810 params.addParam<ExecFlagEnum>("execute_system_information_on",
811 empty_execute_on,
812 "Control when the output of the simulation information occurs");
813 params.addParamNamesToGroup("execute_system_information_on", "Selection/restriction of output");
814 }
815}
816
817bool
818AdvancedOutput::hasOutputHelper(const std::string & name)
819{
820 return !_execute_data[name].output.empty() && _advanced_execute_on.contains(name) &&
821 _advanced_execute_on[name].isValid() && !_advanced_execute_on[name].isValueSet("none");
822}
823
824bool
829
830const std::set<std::string> &
832{
833 return _execute_data["nodal"].output;
834}
835
836bool
841
842const std::set<std::string> &
844{
845 return _execute_data["elemental"].output;
846}
847
848bool
850{
851 return hasOutputHelper("scalars");
852}
853
854const std::set<std::string> &
856{
857 return _execute_data["scalars"].output;
858}
859
860bool
862{
863 return hasOutputHelper("postprocessors");
864}
865
866const std::set<std::string> &
868{
869 return _execute_data["postprocessors"].output;
870}
871
872bool
874{
875 return hasOutputHelper("vector_postprocessors");
876}
877
878const std::set<std::string> &
880{
881 return _execute_data["vector_postprocessors"].output;
882}
883
884bool
886{
887 return hasOutputHelper("reporters");
888}
889
890const std::set<std::string> &
892{
893 return _execute_data["reporters"].output;
894}
895
896const OutputOnWarehouse &
InputParameters emptyInputParameters()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ExecFlagType EXEC_FORCED
Definition Moose.C:50
const ExecFlagType EXEC_FAILED
Definition Moose.C:51
const ExecFlagType EXEC_FINAL
Definition Moose.C:49
virtual bool hasOutput()
Returns true if any of the other has methods return true.
bool hasReporterOutput()
Returns true if there exists Reporter for output.
bool hasOutputHelper(const std::string &name)
Helper method for checking if output types exists.
virtual void outputScalarVariables()
Performs output of scalar variables The child class must define this method to output the scalar vari...
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
void initExecutionTypes(const std::string &name, ExecFlagEnum &input)
Initialize the possible execution types.
void initAvailableLists()
Initializes the available lists for each of the output types.
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
virtual void initialSetup()
Call init() method on setup.
virtual void outputSystemInformation()
bool hasElementalVariableOutput()
Returns true if there exists elemental nonlinear variables for output.
virtual bool shouldOutput()
Handles logic for determining if a step should be output.
const std::set< std::string > & getElementalVariableOutput()
The list of elemental nonlinear variables names that are set for output.
bool hasNodalVariableOutput()
Returns true if there exists nodal nonlinear variables for output.
const bool _postprocessors_as_reporters
Flags for outputting PP/VPP data as a reporter.
bool _elemental_as_nodal
Flags to control nodal output.
bool hasPostprocessorOutput()
Returns true if there exists postprocessors for output.
AdvancedOutput(const InputParameters &parameters)
Class constructor.
std::map< std::string, Real > & _last_execute_time
Storage for the last output time for the various output types, this is used to avoid duplicate output...
const ReporterData & _reporter_data
Storage for Reporter values.
void clearLastExecuteTime()
Clears bookkeeping used to suppress duplicate EXEC_FINAL output at the same time.
const bool _vectorpostprocessors_as_reporters
const std::set< std::string > & getNodalVariableOutput()
The list of nodal nonlinear variables names that are set for output.
static InputParameters validParams()
static MultiMooseEnum getOutputTypes()
Get the supported types of output (e.g., postprocessors, etc.)
bool hasScalarOutput()
Returns true if there exists scalar variables for output.
const std::set< std::string > & getScalarOutput()
The list of scalar variables names that are set for output.
void initShowHideLists(const std::vector< VariableName > &show, const std::vector< VariableName > &hide)
Parses the user-supplied input for hiding and showing variables and postprocessors into a list for ea...
bool wantOutput(const std::string &name, const ExecFlagType &type)
Handles logic for determining if a step should be output.
virtual void outputElementalVariables()
Performs output of elemental nonlinear variables The child class must define this method to output th...
virtual ~AdvancedOutput()
Class destructor.
virtual void outputReporters()
Output Reporter values.
bool hasVectorPostprocessorOutput()
Returns true if there exists VectorPostprocessors for output.
virtual void outputPostprocessors()
Performs output of postprocessors The child class must define this method to output the postprocessor...
virtual void outputVectorPostprocessors()
Performs output of VectorPostprocessors The child class must define this method to output the VectorP...
const std::set< std::string > & getVectorPostprocessorOutput()
The list of VectorPostprocessor names that are set for output.
virtual void outputInput()
Performs the output of the input file By default this method does nothing and is not called,...
virtual void init()
Populates the various data structures needed to control the output.
OutputDataWarehouse _execute_data
Storage structures for the various output types.
virtual void outputNodalVariables()
Performs output of nodal nonlinear variables The child class must define this method to output the no...
void initOutputList(OutputData &data)
Initializes the list of items to be output using the available, show, and hide lists.
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
static void addValidParams(InputParameters &params, const MultiMooseEnum &types)
Method for defining the available parameters based on the types of outputs.
const OutputOnWarehouse & advancedExecuteOn() const
Get the current advanced 'execute_on' selections for display.
A MultiMooseEnum object to hold "execute_on" flags.
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
virtual bool hasScalarVariable(const std::string &var_name) const override
Returns a Boolean indicating whether any system contains a variable with the name provided.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual bool hasVariable(const std::string &var_name) const override
Whether or not this problem has the variable.
virtual std::vector< VariableName > getVariableNames()
Returns a list of all the variables in the problem (both from the NL and Aux systems.
An outputter with filename support.
Definition FileOutput.h:21
static InputParameters validParams()
Definition FileOutput.C:24
bool checkFilename()
Checks the filename for output Checks the output against the 'output_if_base_contians' list.
Definition FileOutput.C:96
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition MooseApp.C:2414
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
const InputParameters & _pars
The object's parameters.
Definition MooseBase.h:384
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
std::string getRawNames() const
Method for returning the raw name strings for this instance.
Class for containing MooseEnum item information.
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
const libMesh::FEType & feType() const
Get the type of finite element object.
virtual bool isArray() const
const std::string & arrayVariableComponent(const unsigned int i) const
Returns the variable name of a component of an array variable.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
This class provides an interface for common operations on field variables of both FE and FV types wit...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
void clearSetValues()
Clear the MultiMooseEnum.
void reset()
Clear existing lists for re-initialization.
bool hasShowList()
False when the show lists for all variables is empty.
void setHasShowList(bool value)
Set the show list bool.
std::map< std::string, T >::iterator end()
bool contains(const std::string &name) const
A method for testing of a key exists.
std::map< std::string, T >::iterator find(const std::string &name)
A helper warehouse class for storing the "execute_on" settings for the various output types.
void buildInterfaceHideVariables(const std::string &output_name, std::set< std::string > &hide)
Return the list of hidden variables for the given output name.
ExecFlagEnum _execute_on
The common Execution types; this is used as the default execution type for everything except system i...
Definition Output.h:203
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition Output.h:185
virtual bool shouldOutput()
Handles logic for determining if a step should be output.
Definition Output.C:272
bool _is_advanced
Flag for advanced output testing.
Definition Output.h:271
ExecFlagType _current_execute_flag
Current execute on flag.
Definition Output.h:211
libMesh::EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
Definition Output.h:194
Real & _time
The current time for output purposes.
Definition Output.h:214
OutputOnWarehouse _advanced_execute_on
Storage for the individual component execute flags.
Definition Output.h:277
bool hasPostprocessorByName(const PostprocessorName &name) const
Determine if the Postprocessor data exists.
std::set< ReporterName > getReporterNames() const
Return a list of all reporter names.
bool hasReporterValueByName(const ReporterName &reporter_name) const
The Reporter system is comprised of objects that can contain any number of data values.
bool havePRefinement() const
Query whether p-refinement has been requested at any point during the simulation.
bool hasVectorPostprocessorByName(const VectorPostprocessorName &name, const std::string &vector_name) const
Determine if the VectorPostprocessor data exists by name.
GCC9 currently hits a "no type named 'value_type'" error during build if this is removed and iterator...
const MeshBase & get_mesh() const
unsigned int spatial_dimension() const
ExecFlagEnum getDefaultExecFlagEnum()
Definition MooseUtils.C:972
@ VAR_FIELD_ANY
Definition MooseTypes.h:781
@ VAR_ANY
Definition MooseTypes.h:772
A structure for storing the various lists that contain the names of the items to be exported.
std::set< std::string > show
User-supplied list of outputs to display.
std::set< std::string > available
A list of all possible outputs.
std::set< std::string > output
A list of the outputs to write.
std::set< std::string > hide
User-supplied list of outputs to hide.