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/equation_systems.h"
28#include "libmesh/fe_interface.h"
29
30// A function, only available in this file, for adding the AdvancedOutput parameters. This is
31// used to eliminate code duplication between the difference specializations of the validParams
32// function.
33namespace
34{
35bool
36isElementalDataFEType(const FEType & type, const FEProblemBase & problem)
37{
38 return EquationSystems::is_elemental_data_fe_type(type) &&
39 (!type.p_refinement || !problem.doingPRefinement());
40}
41
42void
43addAdvancedOutputParams(InputParameters & params)
44{
45 // Hide/show variable output options
46 params.addParam<std::vector<VariableName>>(
47 "hide",
48 {},
49 "A list of the variables and postprocessors that should NOT be output to the Exodus "
50 "file (may include Variables, ScalarVariables, and Postprocessor names).");
51
52 params.addParam<std::vector<VariableName>>(
53 "show",
54 {},
55 "A list of the variables and postprocessors that should be output to the Exodus file "
56 "(may include Variables, ScalarVariables, and Postprocessor names).");
57
58 // Enable output of PP/VPP to JSON
59 params.addParam<bool>(
60 "postprocessors_as_reporters", false, "Output Postprocessors values as Reporter values.");
61 params.addParam<bool>("vectorpostprocessors_as_reporters",
62 false,
63 "Output VectorsPostprocessors vectors as Reporter values.");
64
65 // Group for selecting the output
66 params.addParamNamesToGroup("hide show", "Selection/restriction of output");
67
68 // Group for converting outputs
69 params.addParamNamesToGroup("postprocessors_as_reporters vectorpostprocessors_as_reporters",
70 "Conversions before output");
71
72 // **** DEPRECATED PARAMS ****
73 params.addDeprecatedParam<bool>("output_postprocessors",
74 true,
75 "Enable/disable the output of postprocessors",
76 "'execute_postprocessors_on' has replaced this parameter");
77 params.addDeprecatedParam<bool>("execute_vector_postprocessors",
78 true,
79 "Enable/disable the output of vector postprocessors",
80 "'execute_vector_postprocessors_on' has replaced this parameter");
81 params.addDeprecatedParam<bool>("execute_system_information",
82 true,
83 "Enable/disable the output of the simulation information",
84 "'execute_system_information_on' has replaced this parameter");
85 params.addDeprecatedParam<bool>("execute_elemental_variables",
86 true,
87 "Enable/disable the output of elemental variables",
88 "'execute_elemental_on' has replaced this parameter");
89 params.addDeprecatedParam<bool>("execute_nodal_variables",
90 true,
91 "Enable/disable the output of nodal variables",
92 "'execute_nodal_on' has replaced this parameter");
93 params.addDeprecatedParam<bool>("execute_scalar_variables",
94 true,
95 "Enable/disable the output of aux scalar variables",
96 "'execute_scalars_on' has replaced this parameter");
97 params.addDeprecatedParam<bool>("execute_input",
98 true,
99 "Enable/disable the output of input file information",
100 "'execute_input_on' has replaced this parameter");
101}
102}
103
106{
107 // Get the parameters from the parent object
109 addAdvancedOutputParams(params);
110 return params;
111}
112
113// Defines the output types to enable for the AdvancedOutput object
116{
117 return MultiMooseEnum("nodal=0 elemental=1 scalar=2 postprocessor=3 vector_postprocessor=4 "
118 "input=5 system_information=6 reporter=7");
119}
120
121// Enables the output types (see getOutputTypes) for an AdvancedOutput object
123AdvancedOutput::enableOutputTypes(const std::string & names)
124{
125 // The parameters object that will be returned
127
128 // Get the MultiEnum of output types
129 MultiMooseEnum output_types = getOutputTypes();
130
131 // Update the enum of output types to append
132 if (names.empty())
133 output_types = output_types.getRawNames();
134 else
135 output_types = names;
136
137 // Add the parameters and return them
138 addValidParams(params, output_types);
139 return params;
140}
141
142// Constructor
144 : FileOutput(parameters),
145 _elemental_as_nodal(isParamValid("elemental_as_nodal") ? getParam<bool>("elemental_as_nodal")
146 : false),
147 _scalar_as_nodal(isParamValid("scalar_as_nodal") ? getParam<bool>("scalar_as_nodal") : false),
148 _reporter_data(_problem_ptr->getReporterData()),
149 _last_execute_time(declareRecoverableData<std::map<std::string, Real>>("last_execute_time")),
150 _postprocessors_as_reporters(getParam<bool>("postprocessors_as_reporters")),
151 _vectorpostprocessors_as_reporters(getParam<bool>("vectorpostprocessors_as_reporters"))
152{
153 _is_advanced = true;
155}
156
157void
162
163void
165{
166 // Initialize the execution flags
167 for (auto & [name, input] : _advanced_execute_on)
168 initExecutionTypes(name, input);
169
170 // Clear existing execute information lists
172
173 // Initialize the available output
175
176 // Separate the hide/show list into components
177 initShowHideLists(getParam<std::vector<VariableName>>("show"),
178 getParam<std::vector<VariableName>>("hide"));
179
180 // If 'elemental_as_nodal = true' the elemental variable names must be appended to the
181 // nodal variable names. Thus, when libMesh::EquationSystem::build_solution_vector is called
182 // it will create the correct nodal variable from the elemental
184 {
185 OutputData & nodal = _execute_data["nodal"];
186 OutputData & elemental = _execute_data["elemental"];
187 nodal.show.insert(elemental.show.begin(), elemental.show.end());
188 nodal.hide.insert(elemental.hide.begin(), elemental.hide.end());
189 nodal.available.insert(elemental.available.begin(), elemental.available.end());
190 }
191
192 // Similarly as above, if 'scalar_as_nodal = true' append the elemental variable lists
194 {
195 OutputData & nodal = _execute_data["nodal"];
196 OutputData & scalar = _execute_data["scalars"];
197 nodal.show.insert(scalar.show.begin(), scalar.show.end());
198 nodal.hide.insert(scalar.hide.begin(), scalar.hide.end());
199 nodal.available.insert(scalar.available.begin(), scalar.available.end());
200 }
201
202 // Initialize the show/hide/output lists for each of the types of output
203 for (auto & it : _execute_data)
204 initOutputList(it.second);
205}
206
208
209void
211{
212 mooseError("Individual output of nodal variables is not support for the output object named '",
213 name(),
214 "'");
215}
216
217void
219{
221 "Individual output of elemental variables is not support for this output object named '",
222 name(),
223 "'");
224}
225
226void
228{
229 mooseError("Individual output of postprocessors is not support for this output object named '",
230 name(),
231 "'");
232}
233
234void
236{
238 "Individual output of VectorPostprocessors is not support for this output object named '",
239 name(),
240 "'");
241}
242
243void
245{
247 "Individual output of scalars is not support for this output object named '", name(), "'");
248}
249
250void
252{
254 "Output of system information is not support for this output object named '", name(), "'");
255}
256
257void
259{
260 mooseError("Output of the input file information is not support for this output object named '",
261 name(),
262 "'");
263}
264
265void
267{
269 "Output of the Reporter value(s) is not support for this output object named '", name(), "'");
270}
271
272bool
274{
275 if (!checkFilename())
276 return false;
277
279 return true;
280 else
281 return Output::shouldOutput();
282}
283
284void
286{
287 const auto & type = _current_execute_flag;
288
289 // (re)initialize the list of available items for output
290 init();
291
292 // Call the various output types, if data exists
293 if (wantOutput("nodal", type))
294 {
296 _last_execute_time["nodal"] = _time;
297 }
298
299 if (wantOutput("elemental", type))
300 {
302 _last_execute_time["elemental"] = _time;
303 }
304
305 if (wantOutput("postprocessors", type))
306 {
308 _last_execute_time["postprocessors"] = _time;
309 }
310
311 if (wantOutput("vector_postprocessors", type))
312 {
314 _last_execute_time["vector_postprocessors"] = _time;
315 }
316
317 if (wantOutput("scalars", type))
318 {
320 _last_execute_time["scalars"] = _time;
321 }
322
323 if (wantOutput("system_information", type))
324 {
326 _last_execute_time["system_information"] = _time;
327 }
328
329 if (wantOutput("input", type))
330 {
331 outputInput();
332 _last_execute_time["input"] = _time;
333 }
334
335 if (wantOutput("reporters", type))
336 {
338 _last_execute_time["reporters"] = _time;
339 }
340}
341
342void
347
348bool
349AdvancedOutput::wantOutput(const std::string & name, const ExecFlagType & type)
350{
351 // Ignore EXEC_FORCED for system information and input, there is no reason to force this
352 if (type == EXEC_FORCED && (name == "system_information" || name == "input"))
353 return false;
354
355 // Do not output if the 'none' is contained by the execute_on
356 if (_advanced_execute_on.contains(name) && _advanced_execute_on[name].isValueSet("none"))
357 return false;
358
359 // Data output flag, true if data exists to be output
360 bool execute_data_flag = true;
361
362 // Set flag to false, if the OutputData exists and the output variable list is empty
363 std::map<std::string, OutputData>::const_iterator iter = _execute_data.find(name);
364 if (iter != _execute_data.end() && iter->second.output.empty())
365 execute_data_flag = false;
366
367 // Set flag to false, if the OutputOnWarehouse DOES NOT contain an entry
369 execute_data_flag = false;
370
371 // Force the output, if there is something to output and the time has not been output
372 if (type == EXEC_FORCED && execute_data_flag && _last_execute_time[name] != _time)
373 return true;
374
375 // Return true (output should occur) if three criteria are satisfied, else do not output:
376 // (1) The execute_data_flag = true (i.e, there is data to output)
377 // (2) The current output type is contained in the list of output execution types
378 // (3) The current execution time is "final" or "forced" and the data has not already been
379 // output
380 if (execute_data_flag && _advanced_execute_on[name].isValueSet(type) &&
382 return true;
383 else
384 return false;
385}
386
387bool
389{
390 // If any of the component outputs are true, then there is some output to perform
391 for (const auto & it : _advanced_execute_on)
392 if (wantOutput(it.first, type))
393 return true;
394
395 // There is nothing to output
396 return false;
397}
398
399bool
401{
402 // Test that variables exist for output AND that output execution flags are valid
403 for (const auto & it : _execute_data)
404 if (!(it.second).output.empty() && _advanced_execute_on.contains(it.first) &&
405 _advanced_execute_on[it.first].isValid())
406 return true;
407
408 // Test execution flags for non-variable output
409 if (_advanced_execute_on.contains("system_information") &&
410 _advanced_execute_on["system_information"].isValid())
411 return true;
412 if (_advanced_execute_on.contains("input") && _advanced_execute_on["input"].isValid())
413 return true;
414
415 return false;
416}
417
418void
420{
421 // Initialize Postprocessor list
422 // This flag is set to true if any postprocessor has the 'outputs' parameter set, it is then used
423 // to produce an warning if postprocessor output is disabled
425 initPostprocessorOrVectorPostprocessorLists<Postprocessor>("postprocessors");
426
427 // Initialize vector postprocessor list
428 // This flag is set to true if any vector postprocessor has the 'outputs' parameter set, it is
429 // then used
430 // to produce an warning if vector postprocessor output is disabled
432 initPostprocessorOrVectorPostprocessorLists<VectorPostprocessor>("vector_postprocessors");
433
434 // Get a list of the available variables
435 std::vector<VariableName> variables = _problem_ptr->getVariableNames();
436
437 // Loop through the variables and store the names in the correct available lists
438 for (const auto & var_name : variables)
439 {
440 if (_problem_ptr->hasVariable(var_name))
441 {
444
445 // Skip if the 'outputs' parameter has been set to exclude this output
446 if (var.isParamValid("outputs"))
447 {
448 const auto & outputs = var.getParam<std::vector<OutputName>>("outputs");
449 if (outputs.size() && std::find(outputs.begin(), outputs.end(), name()) == outputs.end() &&
450 outputs[0] != "all")
451 continue;
452 }
453
454 const FEType type = var.feType();
455 const bool is_elemental_data = isElementalDataFEType(type, *_problem_ptr);
456 for (unsigned int i = 0; i < var.count(); ++i)
457 {
458 VariableName vname = var_name;
459 if (var.isArray())
460 vname = var.arrayVariableComponent(i);
461
462 if (is_elemental_data && FEInterface::field_type(type) != libMesh::TYPE_VECTOR)
463 _execute_data["elemental"].available.insert(vname);
464 else if (FEInterface::field_type(type) == libMesh::TYPE_VECTOR)
465 {
466 const auto geom_type = is_elemental_data ? "elemental" : "nodal";
468 {
469 case 0:
470 case 1:
471 _execute_data[geom_type].available.insert(vname);
472 break;
473 case 2:
474 _execute_data[geom_type].available.insert(vname + "_x");
475 _execute_data[geom_type].available.insert(vname + "_y");
476 break;
477 case 3:
478 _execute_data[geom_type].available.insert(vname + "_x");
479 _execute_data[geom_type].available.insert(vname + "_y");
480 _execute_data[geom_type].available.insert(vname + "_z");
481 break;
482 }
483 }
484 else
485 _execute_data["nodal"].available.insert(vname);
486 }
487 }
488
489 else if (_problem_ptr->hasScalarVariable(var_name))
490 _execute_data["scalars"].available.insert(var_name);
491 }
492
493 // Initialize Reporter name list
494 for (auto && r_name : _reporter_data.getReporterNames())
495 if ((_postprocessors_as_reporters || !r_name.isPostprocessor()) &&
496 (_vectorpostprocessors_as_reporters || !r_name.isVectorPostprocessor()))
497 _execute_data["reporters"].available.insert(r_name);
498}
499
500void
501AdvancedOutput::initExecutionTypes(const std::string & name, ExecFlagEnum & input)
502{
503 // Build the input parameter name
504 std::string param_name = "execute_";
505 param_name += name + "_on";
506
507 // The parameters exists and has been set by the user
508 if (_pars.have_parameter<ExecFlagEnum>(param_name) && isParamValid(param_name))
509 input = getParam<ExecFlagEnum>(param_name);
510
511 // If the parameter does not exists; set it to a state where no valid entries exists so nothing
512 // gets executed
513 else if (!_pars.have_parameter<ExecFlagEnum>(param_name))
514 {
515 input = _execute_on;
516 input.clearSetValues();
517 }
518}
519
520void
521AdvancedOutput::initShowHideLists(const std::vector<VariableName> & show,
522 const std::vector<VariableName> & hide)
523{
524
525 // Storage for user-supplied input that is unknown as a variable or postprocessor
526 std::set<std::string> unknown;
527
528 // If a show hide/list exists, let the data warehouse know about it. This allows for the proper
529 // handling of output lists (see initOutputList)
530 if (show.size() > 0)
532
533 // Populate the show lists
534 for (const auto & var_name : show)
535 {
536 if (_problem_ptr->hasVariable(var_name))
537 {
540 const FEType type = var.feType();
541 const bool is_elemental_data = isElementalDataFEType(type, *_problem_ptr);
542 for (unsigned int i = 0; i < var.count(); ++i)
543 {
544 VariableName vname = var_name;
545 if (var.isArray())
546 vname = var.arrayVariableComponent(i);
547
548 if (is_elemental_data && FEInterface::field_type(type) != libMesh::TYPE_VECTOR)
549 _execute_data["elemental"].show.insert(vname);
550 else if (FEInterface::field_type(type) == libMesh::TYPE_VECTOR)
551 {
552 const auto geom_type = is_elemental_data ? "elemental" : "nodal";
554 {
555 case 0:
556 case 1:
557 _execute_data[geom_type].show.insert(vname);
558 break;
559 case 2:
560 _execute_data[geom_type].show.insert(vname + "_x");
561 _execute_data[geom_type].show.insert(vname + "_y");
562 break;
563 case 3:
564 _execute_data[geom_type].show.insert(vname + "_x");
565 _execute_data[geom_type].show.insert(vname + "_y");
566 _execute_data[geom_type].show.insert(vname + "_z");
567 break;
568 }
569 }
570 else
571 _execute_data["nodal"].show.insert(vname);
572 }
573 }
574 else if (_problem_ptr->hasScalarVariable(var_name))
575 _execute_data["scalars"].show.insert(var_name);
576 else if (hasPostprocessorByName(var_name))
577 _execute_data["postprocessors"].show.insert(var_name);
578 else if (hasVectorPostprocessorByName(var_name))
579 _execute_data["vector_postprocessors"].show.insert(var_name);
580 else if ((var_name.find("/") != std::string::npos) &&
582 _execute_data["reporters"].show.insert(var_name);
583 else
584 unknown.insert(var_name);
585 }
586
587 // Populate the hide lists
588 for (const auto & var_name : hide)
589 {
590 if (_problem_ptr->hasVariable(var_name))
591 {
594 const FEType type = var.feType();
595 const bool is_elemental_data = isElementalDataFEType(type, *_problem_ptr);
596 for (unsigned int i = 0; i < var.count(); ++i)
597 {
598 VariableName vname = var_name;
599 if (var.isArray())
600 vname = var.arrayVariableComponent(i);
601
602 if (is_elemental_data && FEInterface::field_type(type) != libMesh::TYPE_VECTOR)
603 _execute_data["elemental"].hide.insert(vname);
604 else if (FEInterface::field_type(type) == libMesh::TYPE_VECTOR)
605 {
606 const auto geom_type = is_elemental_data ? "elemental" : "nodal";
608 {
609 case 0:
610 case 1:
611 _execute_data[geom_type].hide.insert(vname);
612 break;
613 case 2:
614 _execute_data[geom_type].hide.insert(vname + "_x");
615 _execute_data[geom_type].hide.insert(vname + "_y");
616 break;
617 case 3:
618 _execute_data[geom_type].hide.insert(vname + "_x");
619 _execute_data[geom_type].hide.insert(vname + "_y");
620 _execute_data[geom_type].hide.insert(vname + "_z");
621 break;
622 }
623 }
624 else
625 _execute_data["nodal"].hide.insert(vname);
626 }
627 }
628 else if (_problem_ptr->hasScalarVariable(var_name))
629 _execute_data["scalars"].hide.insert(var_name);
630 else if (hasPostprocessorByName(var_name))
631 _execute_data["postprocessors"].hide.insert(var_name);
632 else if (hasVectorPostprocessorByName(var_name))
633 _execute_data["vector_postprocessors"].hide.insert(var_name);
634 else if ((var_name.find("/") != std::string::npos) &&
636 _execute_data["reporters"].hide.insert(var_name);
637
638 else
639 unknown.insert(var_name);
640 }
641
642 // Error if an unknown variable or postprocessor is found
643 if (!unknown.empty())
644 {
645 std::ostringstream oss;
646 oss << "Output(s) do not exist (must be variable, scalar, postprocessor, or vector "
647 "postprocessor): ";
648 std::copy(unknown.begin(), unknown.end(), infix_ostream_iterator<std::string>(oss, " "));
649 mooseError(oss.str());
650 }
651}
652
653void
655{
656 // References to the vectors of variable names
657 std::set<std::string> & hide = data.hide;
658 std::set<std::string> & show = data.show;
659 std::set<std::string> & avail = data.available;
660 std::set<std::string> & output = data.output;
661
662 // Get the hide list from OutputInterface objects
663 std::set<std::string> interface_hide_all_types;
664 _app.getOutputWarehouse().buildInterfaceHideVariables(name(), interface_hide_all_types);
665
666 // OutputInterface hide list includes all types; only include those that are available
667 std::set<std::string> interface_hide;
668 std::set_intersection(interface_hide_all_types.begin(),
669 interface_hide_all_types.end(),
670 avail.begin(),
671 avail.end(),
672 std::inserter(interface_hide, interface_hide.begin()));
673
674 // Append to the hide list from OutputInterface objects
675 hide.insert(interface_hide.begin(), interface_hide.end());
676
677 // Both show and hide are empty and no show/hide settings were provided (show all available)
678 if (!_execute_data.hasShowList() && hide.empty())
679 output = avail;
680
681 // Only hide is empty (show all the variables listed)
682 else if (_execute_data.hasShowList() && hide.empty())
683 output = show;
684
685 // Only show is empty (show all except those hidden)
686 else if (!_execute_data.hasShowList() && !hide.empty())
687 std::set_difference(avail.begin(),
688 avail.end(),
689 hide.begin(),
690 hide.end(),
691 std::inserter(output, output.begin()));
692
693 // Both hide and show are present (show all those listed)
694 else // (_execute_data.hasShowList() && !hide.empty())
695 {
696 // Check if variables are in both, which is invalid
697 std::vector<std::string> tmp;
698 std::set_intersection(
699 hide.begin(), hide.end(), show.begin(), show.end(), std::inserter(tmp, tmp.begin()));
700 if (!tmp.empty())
701 {
702 std::ostringstream oss;
703 oss << "Output(s) specified to be both shown and hidden: ";
704 std::copy(tmp.begin(), tmp.end(), infix_ostream_iterator<std::string>(oss, " "));
705 mooseError(oss.str());
706 }
707
708 // Define the output variable list
709 output = show;
710 }
711}
712
713void
715{
717 empty_execute_on.addAvailableFlags(EXEC_FAILED);
718
719 // Nodal output
720 if (types.isValueSet("nodal"))
721 {
722 params.addParam<ExecFlagEnum>(
723 "execute_nodal_on", empty_execute_on, "Control the output of nodal variables");
724 params.addParamNamesToGroup("execute_nodal_on", "Selection/restriction of output");
725 }
726
727 // Elemental output
728 if (types.isValueSet("elemental"))
729 {
730 params.addParam<ExecFlagEnum>(
731 "execute_elemental_on", empty_execute_on, "Control the output of elemental variables");
732 params.addParamNamesToGroup("execute_elemental_on", "Selection/restriction of output");
733
734 // Add material output control, which are output via elemental variables
735 params.addParam<bool>("output_material_properties",
736 false,
737 "Flag indicating if material properties should be output");
738 params.addParam<std::vector<std::string>>(
739 "show_material_properties",
740 "List of material properties that should be written to the output");
741 params.addParamNamesToGroup("output_material_properties show_material_properties", "Materials");
742
743 // Add mesh extra element id control, which are output via elemental variables
744 params.addParam<bool>(
745 "output_extra_element_ids",
746 false,
747 "Flag indicating if extra element ids defined on the mesh should be outputted");
748 params.addParam<std::vector<std::string>>(
749 "extra_element_ids_to_output",
750 "List of extra element ids defined on the mesh that should be written to the output.");
751 params.addParamNamesToGroup("output_extra_element_ids extra_element_ids_to_output", "Mesh");
752 }
753
754 // Scalar variable output
755 if (types.isValueSet("scalar"))
756 {
757 params.addParam<ExecFlagEnum>(
758 "execute_scalars_on", empty_execute_on, "Control the output of scalar variables");
759 params.addParamNamesToGroup("execute_scalars_on", "Selection/restriction of output");
760 }
761
762 // Nodal and scalar output
763 if (types.isValueSet("nodal") && types.isValueSet("scalar"))
764 {
765 params.addParam<bool>("scalar_as_nodal", false, "Output scalar variables as nodal");
766 params.addParamNamesToGroup("scalar_as_nodal", "Conversions before output");
767 }
768
769 // Elemental and nodal
770 if (types.isValueSet("elemental") && types.isValueSet("nodal"))
771 {
772 params.addParam<bool>(
773 "elemental_as_nodal", false, "Output elemental nonlinear variables as nodal");
774 params.addParamNamesToGroup("elemental_as_nodal", "Conversions before output");
775 }
776
777 // Postprocessors
778 if (types.isValueSet("postprocessor"))
779 {
780 params.addParam<ExecFlagEnum>(
781 "execute_postprocessors_on", empty_execute_on, "Control of when postprocessors are output");
782 params.addParamNamesToGroup("execute_postprocessors_on", "Selection/restriction of output");
783 }
784
785 // Vector Postprocessors
786 if (types.isValueSet("vector_postprocessor"))
787 {
788 params.addParam<ExecFlagEnum>("execute_vector_postprocessors_on",
789 empty_execute_on,
790 "Enable/disable the output of VectorPostprocessors");
791 params.addParamNamesToGroup("execute_vector_postprocessors_on",
792 "Selection/restriction of output");
793 }
794
795 // Reporters
796 if (types.isValueSet("reporter"))
797 {
798 params.addParam<ExecFlagEnum>(
799 "execute_reporters_on", empty_execute_on, "Control of when Reporter values are output");
800 params.addParamNamesToGroup("execute_reporters_on", "Selection/restriction of output");
801 }
802
803 // Input file
804 if (types.isValueSet("input"))
805 {
806 params.addParam<ExecFlagEnum>(
807 "execute_input_on", empty_execute_on, "Enable/disable the output of the input file");
808 params.addParamNamesToGroup("execute_input_on", "Selection/restriction of output");
809 }
810
811 // System Information
812 if (types.isValueSet("system_information"))
813 {
814 params.addParam<ExecFlagEnum>("execute_system_information_on",
815 empty_execute_on,
816 "Control when the output of the simulation information occurs");
817 params.addParamNamesToGroup("execute_system_information_on", "Selection/restriction of output");
818 }
819}
820
821bool
822AdvancedOutput::hasOutputHelper(const std::string & name)
823{
824 return !_execute_data[name].output.empty() && _advanced_execute_on.contains(name) &&
825 _advanced_execute_on[name].isValid() && !_advanced_execute_on[name].isValueSet("none");
826}
827
828bool
833
834const std::set<std::string> &
836{
837 return _execute_data["nodal"].output;
838}
839
840bool
845
846const std::set<std::string> &
848{
849 return _execute_data["elemental"].output;
850}
851
852bool
854{
855 return hasOutputHelper("scalars");
856}
857
858const std::set<std::string> &
860{
861 return _execute_data["scalars"].output;
862}
863
864bool
866{
867 return hasOutputHelper("postprocessors");
868}
869
870const std::set<std::string> &
872{
873 return _execute_data["postprocessors"].output;
874}
875
876bool
878{
879 return hasOutputHelper("vector_postprocessors");
880}
881
882const std::set<std::string> &
884{
885 return _execute_data["vector_postprocessors"].output;
886}
887
888bool
890{
891 return hasOutputHelper("reporters");
892}
893
894const std::set<std::string> &
896{
897 return _execute_data["reporters"].output;
898}
899
900const 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.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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 doingPRefinement() const
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()
@ 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.