Line data Source code
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 : using namespace libMesh;
30 :
31 : // A function, only available in this file, for adding the AdvancedOutput parameters. This is
32 : // used to eliminate code duplication between the difference specializations of the validParams
33 : // function.
34 : namespace
35 : {
36 : void
37 427276 : addAdvancedOutputParams(InputParameters & params)
38 : {
39 : // Hide/show variable output options
40 427276 : params.addParam<std::vector<VariableName>>(
41 : "hide",
42 : {},
43 : "A list of the variables and postprocessors that should NOT be output to the Exodus "
44 : "file (may include Variables, ScalarVariables, and Postprocessor names).");
45 :
46 427276 : params.addParam<std::vector<VariableName>>(
47 : "show",
48 : {},
49 : "A list of the variables and postprocessors that should be output to the Exodus file "
50 : "(may include Variables, ScalarVariables, and Postprocessor names).");
51 :
52 : // Enable output of PP/VPP to JSON
53 1281828 : params.addParam<bool>(
54 854552 : "postprocessors_as_reporters", false, "Output Postprocessors values as Reporter values.");
55 1281828 : params.addParam<bool>("vectorpostprocessors_as_reporters",
56 854552 : false,
57 : "Output VectorsPostprocessors vectors as Reporter values.");
58 :
59 : // Group for selecting the output
60 427276 : params.addParamNamesToGroup("hide show", "Selection/restriction of output");
61 :
62 : // Group for converting outputs
63 427276 : params.addParamNamesToGroup("postprocessors_as_reporters vectorpostprocessors_as_reporters",
64 : "Conversions before output");
65 :
66 : // **** DEPRECATED PARAMS ****
67 1281828 : params.addDeprecatedParam<bool>("output_postprocessors",
68 854552 : true,
69 : "Enable/disable the output of postprocessors",
70 : "'execute_postprocessors_on' has replaced this parameter");
71 1281828 : params.addDeprecatedParam<bool>("execute_vector_postprocessors",
72 854552 : true,
73 : "Enable/disable the output of vector postprocessors",
74 : "'execute_vector_postprocessors_on' has replaced this parameter");
75 1281828 : params.addDeprecatedParam<bool>("execute_system_information",
76 854552 : true,
77 : "Enable/disable the output of the simulation information",
78 : "'execute_system_information_on' has replaced this parameter");
79 1281828 : params.addDeprecatedParam<bool>("execute_elemental_variables",
80 854552 : true,
81 : "Enable/disable the output of elemental variables",
82 : "'execute_elemental_on' has replaced this parameter");
83 1281828 : params.addDeprecatedParam<bool>("execute_nodal_variables",
84 854552 : true,
85 : "Enable/disable the output of nodal variables",
86 : "'execute_nodal_on' has replaced this parameter");
87 1281828 : params.addDeprecatedParam<bool>("execute_scalar_variables",
88 854552 : true,
89 : "Enable/disable the output of aux scalar variables",
90 : "'execute_scalars_on' has replaced this parameter");
91 1281828 : params.addDeprecatedParam<bool>("execute_input",
92 854552 : true,
93 : "Enable/disable the output of input file information",
94 : "'execute_input_on' has replaced this parameter");
95 427276 : }
96 : }
97 :
98 : InputParameters
99 427276 : AdvancedOutput::validParams()
100 : {
101 : // Get the parameters from the parent object
102 427276 : InputParameters params = FileOutput::validParams();
103 427276 : addAdvancedOutputParams(params);
104 427276 : return params;
105 0 : }
106 :
107 : // Defines the output types to enable for the AdvancedOutput object
108 : MultiMooseEnum
109 511727 : AdvancedOutput::getOutputTypes()
110 : {
111 : return MultiMooseEnum("nodal=0 elemental=1 scalar=2 postprocessor=3 vector_postprocessor=4 "
112 511727 : "input=5 system_information=6 reporter=7");
113 : }
114 :
115 : // Enables the output types (see getOutputTypes) for an AdvancedOutput object
116 : InputParameters
117 511727 : AdvancedOutput::enableOutputTypes(const std::string & names)
118 : {
119 : // The parameters object that will be returned
120 511727 : InputParameters params = emptyInputParameters();
121 :
122 : // Get the MultiEnum of output types
123 511727 : MultiMooseEnum output_types = getOutputTypes();
124 :
125 : // Update the enum of output types to append
126 511727 : if (names.empty())
127 0 : output_types = output_types.getRawNames();
128 : else
129 511727 : output_types = names;
130 :
131 : // Add the parameters and return them
132 511727 : addValidParams(params, output_types);
133 1023454 : return params;
134 511727 : }
135 :
136 : // Constructor
137 116788 : AdvancedOutput::AdvancedOutput(const InputParameters & parameters)
138 : : FileOutput(parameters),
139 116776 : _elemental_as_nodal(isParamValid("elemental_as_nodal") ? getParam<bool>("elemental_as_nodal")
140 : : false),
141 116776 : _scalar_as_nodal(isParamValid("scalar_as_nodal") ? getParam<bool>("scalar_as_nodal") : false),
142 116776 : _reporter_data(_problem_ptr->getReporterData()),
143 116776 : _last_execute_time(declareRecoverableData<std::map<std::string, Real>>("last_execute_time")),
144 116776 : _postprocessors_as_reporters(getParam<bool>("postprocessors_as_reporters")),
145 350340 : _vectorpostprocessors_as_reporters(getParam<bool>("vectorpostprocessors_as_reporters"))
146 : {
147 116776 : _is_advanced = true;
148 116776 : _advanced_execute_on = OutputOnWarehouse(_execute_on, parameters);
149 116776 : }
150 :
151 : void
152 112941 : AdvancedOutput::initialSetup()
153 : {
154 112941 : init();
155 112921 : }
156 :
157 : void
158 365859 : AdvancedOutput::init()
159 : {
160 : // Initialize the execution flags
161 2354132 : for (auto & [name, input] : _advanced_execute_on)
162 1988273 : initExecutionTypes(name, input);
163 :
164 : // Clear existing execute information lists
165 365859 : _execute_data.reset();
166 :
167 : // Initialize the available output
168 365859 : initAvailableLists();
169 :
170 : // Separate the hide/show list into components
171 365855 : initShowHideLists(getParam<std::vector<VariableName>>("show"),
172 : getParam<std::vector<VariableName>>("hide"));
173 :
174 : // If 'elemental_as_nodal = true' the elemental variable names must be appended to the
175 : // nodal variable names. Thus, when libMesh::EquationSystem::build_solution_vector is called
176 : // it will create the correct nodal variable from the elemental
177 365847 : if (_elemental_as_nodal)
178 : {
179 1388 : OutputData & nodal = _execute_data["nodal"];
180 1388 : OutputData & elemental = _execute_data["elemental"];
181 1388 : nodal.show.insert(elemental.show.begin(), elemental.show.end());
182 1388 : nodal.hide.insert(elemental.hide.begin(), elemental.hide.end());
183 1388 : nodal.available.insert(elemental.available.begin(), elemental.available.end());
184 : }
185 :
186 : // Similarly as above, if 'scalar_as_nodal = true' append the elemental variable lists
187 365847 : if (_scalar_as_nodal)
188 : {
189 74 : OutputData & nodal = _execute_data["nodal"];
190 74 : OutputData & scalar = _execute_data["scalars"];
191 74 : nodal.show.insert(scalar.show.begin(), scalar.show.end());
192 74 : nodal.hide.insert(scalar.hide.begin(), scalar.hide.end());
193 74 : nodal.available.insert(scalar.available.begin(), scalar.available.end());
194 : }
195 :
196 : // Initialize the show/hide/output lists for each of the types of output
197 2560893 : for (auto & it : _execute_data)
198 2195054 : initOutputList(it.second);
199 365839 : }
200 :
201 111706 : AdvancedOutput::~AdvancedOutput() {}
202 :
203 : void
204 0 : AdvancedOutput::outputNodalVariables()
205 : {
206 0 : mooseError("Individual output of nodal variables is not support for the output object named '",
207 0 : name(),
208 : "'");
209 : }
210 :
211 : void
212 0 : AdvancedOutput::outputElementalVariables()
213 : {
214 0 : mooseError(
215 : "Individual output of elemental variables is not support for this output object named '",
216 0 : name(),
217 : "'");
218 : }
219 :
220 : void
221 0 : AdvancedOutput::outputPostprocessors()
222 : {
223 0 : mooseError("Individual output of postprocessors is not support for this output object named '",
224 0 : name(),
225 : "'");
226 : }
227 :
228 : void
229 0 : AdvancedOutput::outputVectorPostprocessors()
230 : {
231 0 : mooseError(
232 : "Individual output of VectorPostprocessors is not support for this output object named '",
233 0 : name(),
234 : "'");
235 : }
236 :
237 : void
238 0 : AdvancedOutput::outputScalarVariables()
239 : {
240 0 : mooseError(
241 0 : "Individual output of scalars is not support for this output object named '", name(), "'");
242 : }
243 :
244 : void
245 0 : AdvancedOutput::outputSystemInformation()
246 : {
247 0 : mooseError(
248 0 : "Output of system information is not support for this output object named '", name(), "'");
249 : }
250 :
251 : void
252 0 : AdvancedOutput::outputInput()
253 : {
254 0 : mooseError("Output of the input file information is not support for this output object named '",
255 0 : name(),
256 : "'");
257 : }
258 :
259 : void
260 0 : AdvancedOutput::outputReporters()
261 : {
262 0 : mooseError(
263 0 : "Output of the Reporter value(s) is not support for this output object named '", name(), "'");
264 : }
265 :
266 : bool
267 8854785 : AdvancedOutput::shouldOutput()
268 : {
269 8854785 : if (!checkFilename())
270 612 : return false;
271 :
272 8854173 : if (hasOutput(_current_execute_flag))
273 412637 : return true;
274 : else
275 8441536 : return Output::shouldOutput();
276 : }
277 :
278 : void
279 252918 : AdvancedOutput::output()
280 : {
281 252918 : const auto & type = _current_execute_flag;
282 :
283 : // (re)initialize the list of available items for output
284 252918 : init();
285 :
286 : // Call the various output types, if data exists
287 252918 : if (wantOutput("nodal", type))
288 : {
289 156190 : outputNodalVariables();
290 156190 : _last_execute_time["nodal"] = _time;
291 : }
292 :
293 252918 : if (wantOutput("elemental", type))
294 : {
295 36807 : outputElementalVariables();
296 36807 : _last_execute_time["elemental"] = _time;
297 : }
298 :
299 252918 : if (wantOutput("postprocessors", type))
300 : {
301 102912 : outputPostprocessors();
302 102912 : _last_execute_time["postprocessors"] = _time;
303 : }
304 :
305 252918 : if (wantOutput("vector_postprocessors", type))
306 : {
307 7748 : outputVectorPostprocessors();
308 7748 : _last_execute_time["vector_postprocessors"] = _time;
309 : }
310 :
311 252918 : if (wantOutput("scalars", type))
312 : {
313 17337 : outputScalarVariables();
314 17337 : _last_execute_time["scalars"] = _time;
315 : }
316 :
317 252918 : if (wantOutput("system_information", type))
318 : {
319 798 : outputSystemInformation();
320 798 : _last_execute_time["system_information"] = _time;
321 : }
322 :
323 252918 : if (wantOutput("input", type))
324 : {
325 34489 : outputInput();
326 34489 : _last_execute_time["input"] = _time;
327 : }
328 :
329 252918 : if (wantOutput("reporters", type))
330 : {
331 4432 : outputReporters();
332 4432 : _last_execute_time["reporters"] = _time;
333 : }
334 252918 : }
335 :
336 : bool
337 70618096 : AdvancedOutput::wantOutput(const std::string & name, const ExecFlagType & type)
338 : {
339 : // Ignore EXEC_FORCED for system information and input, there is no reason to force this
340 70618096 : if (type == EXEC_FORCED && (name == "system_information" || name == "input"))
341 9507 : return false;
342 :
343 : // Do not output if the 'none' is contained by the execute_on
344 70608589 : if (_advanced_execute_on.contains(name) && _advanced_execute_on[name].isValueSet("none"))
345 21173 : return false;
346 :
347 : // Data output flag, true if data exists to be output
348 70587416 : bool execute_data_flag = true;
349 :
350 : // Set flag to false, if the OutputData exists and the output variable list is empty
351 70587416 : std::map<std::string, OutputData>::const_iterator iter = _execute_data.find(name);
352 70587416 : if (iter != _execute_data.end() && iter->second.output.empty())
353 38712269 : execute_data_flag = false;
354 :
355 : // Set flag to false, if the OutputOnWarehouse DOES NOT contain an entry
356 70587416 : if (!_advanced_execute_on.contains(name))
357 677778 : execute_data_flag = false;
358 :
359 : // Force the output, if there is something to output and the time has not been output
360 70587416 : if (type == EXEC_FORCED && execute_data_flag && _last_execute_time[name] != _time)
361 2416 : return true;
362 :
363 : // Return true (output should occur) if three criteria are satisfied, else do not output:
364 : // (1) The execute_data_flag = true (i.e, there is data to output)
365 : // (2) The current output type is contained in the list of output execution types
366 : // (3) The current execution time is "final" or "forced" and the data has not already been
367 : // output
368 71613883 : if (execute_data_flag && _advanced_execute_on[name].isValueSet(type) &&
369 1028883 : !(type == EXEC_FINAL && _last_execute_time[name] == _time))
370 1027851 : return true;
371 : else
372 69557149 : return false;
373 : }
374 :
375 : bool
376 8854173 : AdvancedOutput::hasOutput(const ExecFlagType & type)
377 : {
378 : // If any of the component outputs are true, then there is some output to perform
379 56828739 : for (const auto & it : _advanced_execute_on)
380 48387203 : if (wantOutput(it.first, type))
381 412637 : return true;
382 :
383 : // There is nothing to output
384 8441536 : return false;
385 : }
386 :
387 : bool
388 37049 : AdvancedOutput::hasOutput()
389 : {
390 : // Test that variables exist for output AND that output execution flags are valid
391 59057 : for (const auto & it : _execute_data)
392 96106 : if (!(it.second).output.empty() && _advanced_execute_on.contains(it.first) &&
393 37049 : _advanced_execute_on[it.first].isValid())
394 37049 : return true;
395 :
396 : // Test execution flags for non-variable output
397 0 : if (_advanced_execute_on.contains("system_information") &&
398 0 : _advanced_execute_on["system_information"].isValid())
399 0 : return true;
400 0 : if (_advanced_execute_on.contains("input") && _advanced_execute_on["input"].isValid())
401 0 : return true;
402 :
403 0 : return false;
404 : }
405 :
406 : void
407 365859 : AdvancedOutput::initAvailableLists()
408 : {
409 : // Initialize Postprocessor list
410 : // This flag is set to true if any postprocessor has the 'outputs' parameter set, it is then used
411 : // to produce an warning if postprocessor output is disabled
412 365859 : if (!_postprocessors_as_reporters)
413 365781 : initPostprocessorOrVectorPostprocessorLists<Postprocessor>("postprocessors");
414 :
415 : // Initialize vector postprocessor list
416 : // This flag is set to true if any vector postprocessor has the 'outputs' parameter set, it is
417 : // then used
418 : // to produce an warning if vector postprocessor output is disabled
419 365855 : if (!_vectorpostprocessors_as_reporters)
420 365471 : initPostprocessorOrVectorPostprocessorLists<VectorPostprocessor>("vector_postprocessors");
421 :
422 : // Get a list of the available variables
423 365855 : std::vector<VariableName> variables = _problem_ptr->getVariableNames();
424 :
425 : // Loop through the variables and store the names in the correct available lists
426 1493992 : for (const auto & var_name : variables)
427 : {
428 1128137 : if (_problem_ptr->hasVariable(var_name))
429 : {
430 1097119 : MooseVariableFEBase & var = _problem_ptr->getVariable(
431 : 0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
432 :
433 1097119 : const FEType type = var.feType();
434 2208324 : for (unsigned int i = 0; i < var.count(); ++i)
435 : {
436 1111205 : VariableName vname = var_name;
437 1111205 : if (var.isArray())
438 23680 : vname = var.arrayVariableComponent(i);
439 :
440 : // A note that if we have p-refinement we assume "worst-case" scenario that our constant
441 : // monomial/monomial-vec families have been refined and we can no longer write them as
442 : // elemental
443 1403362 : if (type.order == CONSTANT && !_problem_ptr->havePRefinement() &&
444 292157 : type.family != MONOMIAL_VEC)
445 291433 : _execute_data["elemental"].available.insert(vname);
446 819772 : else if (FEInterface::field_type(type) == TYPE_VECTOR)
447 : {
448 1124 : const auto geom_type = ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT) &&
449 724 : !_problem_ptr->havePRefinement())
450 7946 : ? "elemental"
451 6822 : : "nodal";
452 6822 : switch (_es_ptr->get_mesh().spatial_dimension())
453 : {
454 414 : case 0:
455 : case 1:
456 414 : _execute_data[geom_type].available.insert(vname);
457 414 : break;
458 4892 : case 2:
459 4892 : _execute_data[geom_type].available.insert(vname + "_x");
460 4892 : _execute_data[geom_type].available.insert(vname + "_y");
461 4892 : break;
462 1516 : case 3:
463 1516 : _execute_data[geom_type].available.insert(vname + "_x");
464 1516 : _execute_data[geom_type].available.insert(vname + "_y");
465 1516 : _execute_data[geom_type].available.insert(vname + "_z");
466 1516 : break;
467 : }
468 : }
469 : else
470 812950 : _execute_data["nodal"].available.insert(vname);
471 1111205 : }
472 : }
473 :
474 31018 : else if (_problem_ptr->hasScalarVariable(var_name))
475 31018 : _execute_data["scalars"].available.insert(var_name);
476 : }
477 :
478 : // Initialize Reporter name list
479 834135 : for (auto && r_name : _reporter_data.getReporterNames())
480 581660 : if ((_postprocessors_as_reporters || !r_name.isPostprocessor()) &&
481 113380 : (_vectorpostprocessors_as_reporters || !r_name.isVectorPostprocessor()))
482 394746 : _execute_data["reporters"].available.insert(r_name);
483 365855 : }
484 :
485 : void
486 1988273 : AdvancedOutput::initExecutionTypes(const std::string & name, ExecFlagEnum & input)
487 : {
488 : // Build the input parameter name
489 1988273 : std::string param_name = "execute_";
490 1988273 : param_name += name + "_on";
491 :
492 : // The parameters exists and has been set by the user
493 1988273 : if (_pars.have_parameter<ExecFlagEnum>(param_name) && isParamValid(param_name))
494 513225 : input = getParam<ExecFlagEnum>(param_name);
495 :
496 : // If the parameter does not exists; set it to a state where no valid entries exists so nothing
497 : // gets executed
498 1475048 : else if (!_pars.have_parameter<ExecFlagEnum>(param_name))
499 : {
500 0 : input = _execute_on;
501 0 : input.clearSetValues();
502 : }
503 1988273 : }
504 :
505 : void
506 365855 : AdvancedOutput::initShowHideLists(const std::vector<VariableName> & show,
507 : const std::vector<VariableName> & hide)
508 : {
509 :
510 : // Storage for user-supplied input that is unknown as a variable or postprocessor
511 365855 : std::set<std::string> unknown;
512 :
513 : // If a show hide/list exists, let the data warehouse know about it. This allows for the proper
514 : // handling of output lists (see initOutputList)
515 365855 : if (show.size() > 0)
516 2066 : _execute_data.setHasShowList(true);
517 :
518 : // Populate the show lists
519 368884 : for (const auto & var_name : show)
520 : {
521 3029 : if (_problem_ptr->hasVariable(var_name))
522 : {
523 1078 : MooseVariableFEBase & var = _problem_ptr->getVariable(
524 : 0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
525 1078 : const FEType type = var.feType();
526 2156 : for (unsigned int i = 0; i < var.count(); ++i)
527 : {
528 1078 : VariableName vname = var_name;
529 1078 : if (var.isArray())
530 0 : vname = var.arrayVariableComponent(i);
531 :
532 1078 : if (type.order == CONSTANT)
533 141 : _execute_data["elemental"].show.insert(vname);
534 937 : else if (FEInterface::field_type(type) == TYPE_VECTOR)
535 : {
536 : const auto geom_type =
537 0 : ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT)) ? "elemental" : "nodal";
538 0 : switch (_es_ptr->get_mesh().spatial_dimension())
539 : {
540 0 : case 0:
541 : case 1:
542 0 : _execute_data[geom_type].show.insert(vname);
543 0 : break;
544 0 : case 2:
545 0 : _execute_data[geom_type].show.insert(vname + "_x");
546 0 : _execute_data[geom_type].show.insert(vname + "_y");
547 0 : break;
548 0 : case 3:
549 0 : _execute_data[geom_type].show.insert(vname + "_x");
550 0 : _execute_data[geom_type].show.insert(vname + "_y");
551 0 : _execute_data[geom_type].show.insert(vname + "_z");
552 0 : break;
553 : }
554 : }
555 : else
556 937 : _execute_data["nodal"].show.insert(vname);
557 1078 : }
558 : }
559 1951 : else if (_problem_ptr->hasScalarVariable(var_name))
560 209 : _execute_data["scalars"].show.insert(var_name);
561 1742 : else if (hasPostprocessorByName(var_name))
562 1697 : _execute_data["postprocessors"].show.insert(var_name);
563 45 : else if (hasVectorPostprocessorByName(var_name))
564 37 : _execute_data["vector_postprocessors"].show.insert(var_name);
565 8 : else if ((var_name.find("/") != std::string::npos) &&
566 8 : (hasReporterValueByName(ReporterName(var_name))))
567 0 : _execute_data["reporters"].show.insert(var_name);
568 : else
569 8 : unknown.insert(var_name);
570 : }
571 :
572 : // Populate the hide lists
573 398683 : for (const auto & var_name : hide)
574 : {
575 32828 : if (_problem_ptr->hasVariable(var_name))
576 : {
577 30639 : MooseVariableFEBase & var = _problem_ptr->getVariable(
578 : 0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
579 30639 : const FEType type = var.feType();
580 62260 : for (unsigned int i = 0; i < var.count(); ++i)
581 : {
582 31621 : VariableName vname = var_name;
583 31621 : if (var.isArray())
584 1964 : vname = var.arrayVariableComponent(i);
585 :
586 31621 : if (type.order == CONSTANT)
587 15084 : _execute_data["elemental"].hide.insert(vname);
588 16537 : else if (FEInterface::field_type(type) == TYPE_VECTOR)
589 : {
590 274 : switch (_es_ptr->get_mesh().spatial_dimension())
591 : {
592 74 : case 0:
593 : case 1:
594 74 : _execute_data["nodal"].hide.insert(vname);
595 74 : break;
596 200 : case 2:
597 200 : _execute_data["nodal"].hide.insert(vname + "_x");
598 200 : _execute_data["nodal"].hide.insert(vname + "_y");
599 200 : break;
600 0 : case 3:
601 0 : _execute_data["nodal"].hide.insert(vname + "_x");
602 0 : _execute_data["nodal"].hide.insert(vname + "_y");
603 0 : _execute_data["nodal"].hide.insert(vname + "_z");
604 0 : break;
605 : }
606 : }
607 : else
608 16263 : _execute_data["nodal"].hide.insert(vname);
609 31621 : }
610 : }
611 2189 : else if (_problem_ptr->hasScalarVariable(var_name))
612 1445 : _execute_data["scalars"].hide.insert(var_name);
613 744 : else if (hasPostprocessorByName(var_name))
614 740 : _execute_data["postprocessors"].hide.insert(var_name);
615 4 : else if (hasVectorPostprocessorByName(var_name))
616 0 : _execute_data["vector_postprocessors"].hide.insert(var_name);
617 4 : else if ((var_name.find("/") != std::string::npos) &&
618 4 : (hasReporterValueByName(ReporterName(var_name))))
619 0 : _execute_data["reporters"].hide.insert(var_name);
620 :
621 : else
622 4 : unknown.insert(var_name);
623 : }
624 :
625 : // Error if an unknown variable or postprocessor is found
626 365855 : if (!unknown.empty())
627 : {
628 8 : std::ostringstream oss;
629 : oss << "Output(s) do not exist (must be variable, scalar, postprocessor, or vector "
630 8 : "postprocessor): ";
631 8 : std::copy(unknown.begin(), unknown.end(), infix_ostream_iterator<std::string>(oss, " "));
632 8 : mooseError(oss.str());
633 0 : }
634 365847 : }
635 :
636 : void
637 2195054 : AdvancedOutput::initOutputList(OutputData & data)
638 : {
639 : // References to the vectors of variable names
640 2195054 : std::set<std::string> & hide = data.hide;
641 2195054 : std::set<std::string> & show = data.show;
642 2195054 : std::set<std::string> & avail = data.available;
643 2195054 : std::set<std::string> & output = data.output;
644 :
645 : // Append to the hide list from OutputInterface objects
646 2195054 : std::set<std::string> interface_hide;
647 2195054 : _app.getOutputWarehouse().buildInterfaceHideVariables(name(), interface_hide);
648 2195054 : hide.insert(interface_hide.begin(), interface_hide.end());
649 :
650 : // Both show and hide are empty and no show/hide settings were provided (show all available)
651 2195054 : if (show.empty() && hide.empty() && !_execute_data.hasShowList())
652 2064410 : output = avail;
653 :
654 : // Only hide is empty (show all the variables listed)
655 130644 : else if (!show.empty() && hide.empty())
656 2212 : output = show;
657 :
658 : // Only show is empty (show all except those hidden)
659 128432 : else if (show.empty() && !hide.empty())
660 118304 : std::set_difference(avail.begin(),
661 : avail.end(),
662 : hide.begin(),
663 : hide.end(),
664 : std::inserter(output, output.begin()));
665 :
666 : // Both hide and show are present (show all those listed)
667 : else
668 : {
669 : // Check if variables are in both, which is invalid
670 10128 : std::vector<std::string> tmp;
671 10128 : std::set_intersection(
672 : hide.begin(), hide.end(), show.begin(), show.end(), std::inserter(tmp, tmp.begin()));
673 10128 : if (!tmp.empty())
674 : {
675 8 : std::ostringstream oss;
676 8 : oss << "Output(s) specified to be both shown and hidden: ";
677 8 : std::copy(tmp.begin(), tmp.end(), infix_ostream_iterator<std::string>(oss, " "));
678 8 : mooseError(oss.str());
679 0 : }
680 :
681 : // Define the output variable list
682 10120 : output = show;
683 10120 : }
684 2195046 : }
685 :
686 : void
687 511727 : AdvancedOutput::addValidParams(InputParameters & params, const MultiMooseEnum & types)
688 : {
689 511727 : ExecFlagEnum empty_execute_on = MooseUtils::getDefaultExecFlagEnum();
690 511727 : empty_execute_on.addAvailableFlags(EXEC_FAILED);
691 :
692 : // Nodal output
693 511727 : if (types.isValueSet("nodal"))
694 : {
695 91783 : params.addParam<ExecFlagEnum>(
696 : "execute_nodal_on", empty_execute_on, "Control the output of nodal variables");
697 91783 : params.addParamNamesToGroup("execute_nodal_on", "Selection/restriction of output");
698 : }
699 :
700 : // Elemental output
701 511727 : if (types.isValueSet("elemental"))
702 : {
703 91783 : params.addParam<ExecFlagEnum>(
704 : "execute_elemental_on", empty_execute_on, "Control the output of elemental variables");
705 91783 : params.addParamNamesToGroup("execute_elemental_on", "Selection/restriction of output");
706 :
707 : // Add material output control, which are output via elemental variables
708 275349 : params.addParam<bool>("output_material_properties",
709 183566 : false,
710 : "Flag indicating if material properties should be output");
711 91783 : params.addParam<std::vector<std::string>>(
712 : "show_material_properties",
713 : "List of material properties that should be written to the output");
714 91783 : params.addParamNamesToGroup("output_material_properties show_material_properties", "Materials");
715 :
716 : // Add mesh extra element id control, which are output via elemental variables
717 275349 : params.addParam<bool>(
718 : "output_extra_element_ids",
719 183566 : false,
720 : "Flag indicating if extra element ids defined on the mesh should be outputted");
721 91783 : params.addParam<std::vector<std::string>>(
722 : "extra_element_ids_to_output",
723 : "List of extra element ids defined on the mesh that should be written to the output.");
724 91783 : params.addParamNamesToGroup("output_extra_element_ids extra_element_ids_to_output", "Mesh");
725 : }
726 :
727 : // Scalar variable output
728 511727 : if (types.isValueSet("scalar"))
729 : {
730 479037 : params.addParam<ExecFlagEnum>(
731 : "execute_scalars_on", empty_execute_on, "Control the output of scalar variables");
732 479037 : params.addParamNamesToGroup("execute_scalars_on", "Selection/restriction of output");
733 : }
734 :
735 : // Nodal and scalar output
736 511727 : if (types.isValueSet("nodal") && types.isValueSet("scalar"))
737 : {
738 91783 : params.addParam<bool>("scalar_as_nodal", false, "Output scalar variables as nodal");
739 91783 : params.addParamNamesToGroup("scalar_as_nodal", "Conversions before output");
740 : }
741 :
742 : // Elemental and nodal
743 511727 : if (types.isValueSet("elemental") && types.isValueSet("nodal"))
744 : {
745 275349 : params.addParam<bool>(
746 183566 : "elemental_as_nodal", false, "Output elemental nonlinear variables as nodal");
747 91783 : params.addParamNamesToGroup("elemental_as_nodal", "Conversions before output");
748 : }
749 :
750 : // Postprocessors
751 511727 : if (types.isValueSet("postprocessor"))
752 : {
753 479037 : params.addParam<ExecFlagEnum>(
754 : "execute_postprocessors_on", empty_execute_on, "Control of when postprocessors are output");
755 479037 : params.addParamNamesToGroup("execute_postprocessors_on", "Selection/restriction of output");
756 : }
757 :
758 : // Vector Postprocessors
759 511727 : if (types.isValueSet("vector_postprocessor"))
760 : {
761 230274 : params.addParam<ExecFlagEnum>("execute_vector_postprocessors_on",
762 : empty_execute_on,
763 : "Enable/disable the output of VectorPostprocessors");
764 230274 : params.addParamNamesToGroup("execute_vector_postprocessors_on",
765 : "Selection/restriction of output");
766 : }
767 :
768 : // Reporters
769 511727 : if (types.isValueSet("reporter"))
770 : {
771 325925 : params.addParam<ExecFlagEnum>(
772 : "execute_reporters_on", empty_execute_on, "Control of when Reporter values are output");
773 325925 : params.addParamNamesToGroup("execute_reporters_on", "Selection/restriction of output");
774 : }
775 :
776 : // Input file
777 511727 : if (types.isValueSet("input"))
778 : {
779 263174 : params.addParam<ExecFlagEnum>(
780 : "execute_input_on", empty_execute_on, "Enable/disable the output of the input file");
781 263174 : params.addParamNamesToGroup("execute_input_on", "Selection/restriction of output");
782 : }
783 :
784 : // System Information
785 511727 : if (types.isValueSet("system_information"))
786 : {
787 174851 : params.addParam<ExecFlagEnum>("execute_system_information_on",
788 : empty_execute_on,
789 : "Control when the output of the simulation information occurs");
790 174851 : params.addParamNamesToGroup("execute_system_information_on", "Selection/restriction of output");
791 : }
792 511727 : }
793 :
794 : bool
795 73957 : AdvancedOutput::hasOutputHelper(const std::string & name)
796 : {
797 139208 : return !_execute_data[name].output.empty() && _advanced_execute_on.contains(name) &&
798 213165 : _advanced_execute_on[name].isValid() && !_advanced_execute_on[name].isValueSet("none");
799 : }
800 :
801 : bool
802 69592 : AdvancedOutput::hasNodalVariableOutput()
803 : {
804 69592 : return hasOutputHelper("nodal");
805 : }
806 :
807 : const std::set<std::string> &
808 314491 : AdvancedOutput::getNodalVariableOutput()
809 : {
810 314491 : return _execute_data["nodal"].output;
811 : }
812 :
813 : bool
814 4263 : AdvancedOutput::hasElementalVariableOutput()
815 : {
816 4263 : return hasOutputHelper("elemental");
817 : }
818 :
819 : const std::set<std::string> &
820 75725 : AdvancedOutput::getElementalVariableOutput()
821 : {
822 75725 : return _execute_data["elemental"].output;
823 : }
824 :
825 : bool
826 51 : AdvancedOutput::hasScalarOutput()
827 : {
828 51 : return hasOutputHelper("scalars");
829 : }
830 :
831 : const std::set<std::string> &
832 50621 : AdvancedOutput::getScalarOutput()
833 : {
834 50621 : return _execute_data["scalars"].output;
835 : }
836 :
837 : bool
838 51 : AdvancedOutput::hasPostprocessorOutput()
839 : {
840 51 : return hasOutputHelper("postprocessors");
841 : }
842 :
843 : const std::set<std::string> &
844 414477 : AdvancedOutput::getPostprocessorOutput()
845 : {
846 414477 : return _execute_data["postprocessors"].output;
847 : }
848 :
849 : bool
850 0 : AdvancedOutput::hasVectorPostprocessorOutput()
851 : {
852 0 : return hasOutputHelper("vector_postprocessors");
853 : }
854 :
855 : const std::set<std::string> &
856 26773 : AdvancedOutput::getVectorPostprocessorOutput()
857 : {
858 26773 : return _execute_data["vector_postprocessors"].output;
859 : }
860 :
861 : bool
862 0 : AdvancedOutput::hasReporterOutput()
863 : {
864 0 : return hasOutputHelper("reporters");
865 : }
866 :
867 : const std::set<std::string> &
868 25507 : AdvancedOutput::getReporterOutput()
869 : {
870 25507 : return _execute_data["reporters"].output;
871 : }
872 :
873 : const OutputOnWarehouse &
874 45371 : AdvancedOutput::advancedExecuteOn() const
875 : {
876 45371 : return _advanced_execute_on;
877 : }
|