LCOV - code coverage report
Current view: top level - src/outputs - AdvancedOutput.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 344 407 84.5 %
Date: 2026-05-29 20:35:17 Functions: 30 41 73.2 %
Legend: Lines: hit not hit

          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      277694 : addAdvancedOutputParams(InputParameters & params)
      38             : {
      39             :   // Hide/show variable output options
      40     1110776 :   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     1110776 :   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      833082 :   params.addParam<bool>(
      54      555388 :       "postprocessors_as_reporters", false, "Output Postprocessors values as Reporter values.");
      55      833082 :   params.addParam<bool>("vectorpostprocessors_as_reporters",
      56      555388 :                         false,
      57             :                         "Output VectorsPostprocessors vectors as Reporter values.");
      58             : 
      59             :   // Group for selecting the output
      60     1110776 :   params.addParamNamesToGroup("hide show", "Selection/restriction of output");
      61             : 
      62             :   // Group for converting outputs
      63     1110776 :   params.addParamNamesToGroup("postprocessors_as_reporters vectorpostprocessors_as_reporters",
      64             :                               "Conversions before output");
      65             : 
      66             :   // **** DEPRECATED PARAMS ****
      67     1388470 :   params.addDeprecatedParam<bool>("output_postprocessors",
      68      555388 :                                   true,
      69             :                                   "Enable/disable the output of postprocessors",
      70             :                                   "'execute_postprocessors_on' has replaced this parameter");
      71     1388470 :   params.addDeprecatedParam<bool>("execute_vector_postprocessors",
      72      555388 :                                   true,
      73             :                                   "Enable/disable the output of vector postprocessors",
      74             :                                   "'execute_vector_postprocessors_on' has replaced this parameter");
      75     1388470 :   params.addDeprecatedParam<bool>("execute_system_information",
      76      555388 :                                   true,
      77             :                                   "Enable/disable the output of the simulation information",
      78             :                                   "'execute_system_information_on' has replaced this parameter");
      79     1388470 :   params.addDeprecatedParam<bool>("execute_elemental_variables",
      80      555388 :                                   true,
      81             :                                   "Enable/disable the output of elemental variables",
      82             :                                   "'execute_elemental_on' has replaced this parameter");
      83     1388470 :   params.addDeprecatedParam<bool>("execute_nodal_variables",
      84      555388 :                                   true,
      85             :                                   "Enable/disable the output of nodal variables",
      86             :                                   "'execute_nodal_on' has replaced this parameter");
      87     1388470 :   params.addDeprecatedParam<bool>("execute_scalar_variables",
      88      833082 :                                   true,
      89             :                                   "Enable/disable the output of aux scalar variables",
      90             :                                   "'execute_scalars_on' has replaced this parameter");
      91     1110776 :   params.addDeprecatedParam<bool>("execute_input",
      92      555388 :                                   true,
      93             :                                   "Enable/disable the output of input file information",
      94             :                                   "'execute_input_on' has replaced this parameter");
      95      277694 : }
      96             : }
      97             : 
      98             : InputParameters
      99      277694 : AdvancedOutput::validParams()
     100             : {
     101             :   // Get the parameters from the parent object
     102      277694 :   InputParameters params = FileOutput::validParams();
     103      277694 :   addAdvancedOutputParams(params);
     104      277694 :   return params;
     105           0 : }
     106             : 
     107             : // Defines the output types to enable for the AdvancedOutput object
     108             : MultiMooseEnum
     109      394091 : AdvancedOutput::getOutputTypes()
     110             : {
     111             :   return MultiMooseEnum("nodal=0 elemental=1 scalar=2 postprocessor=3 vector_postprocessor=4 "
     112      788182 :                         "input=5 system_information=6 reporter=7");
     113             : }
     114             : 
     115             : // Enables the output types (see getOutputTypes) for an AdvancedOutput object
     116             : InputParameters
     117      394091 : AdvancedOutput::enableOutputTypes(const std::string & names)
     118             : {
     119             :   // The parameters object that will be returned
     120      394091 :   InputParameters params = emptyInputParameters();
     121             : 
     122             :   // Get the MultiEnum of output types
     123      394091 :   MultiMooseEnum output_types = getOutputTypes();
     124             : 
     125             :   // Update the enum of output types to append
     126      394091 :   if (names.empty())
     127           0 :     output_types = output_types.getRawNames();
     128             :   else
     129      394091 :     output_types = names;
     130             : 
     131             :   // Add the parameters and return them
     132      394091 :   addValidParams(params, output_types);
     133      788182 :   return params;
     134      394091 : }
     135             : 
     136             : // Constructor
     137      114980 : AdvancedOutput::AdvancedOutput(const InputParameters & parameters)
     138             :   : FileOutput(parameters),
     139      188555 :     _elemental_as_nodal(isParamValid("elemental_as_nodal") ? getParam<bool>("elemental_as_nodal")
     140             :                                                            : false),
     141      303526 :     _scalar_as_nodal(isParamValid("scalar_as_nodal") ? getParam<bool>("scalar_as_nodal") : false),
     142      114971 :     _reporter_data(_problem_ptr->getReporterData()),
     143      229942 :     _last_execute_time(declareRecoverableData<std::map<std::string, Real>>("last_execute_time")),
     144      229942 :     _postprocessors_as_reporters(getParam<bool>("postprocessors_as_reporters")),
     145      459893 :     _vectorpostprocessors_as_reporters(getParam<bool>("vectorpostprocessors_as_reporters"))
     146             : {
     147      114971 :   _is_advanced = true;
     148      114971 :   _advanced_execute_on = OutputOnWarehouse(_execute_on, parameters);
     149      114971 : }
     150             : 
     151             : void
     152      111536 : AdvancedOutput::initialSetup()
     153             : {
     154      111536 :   init();
     155      111521 : }
     156             : 
     157             : void
     158      353658 : AdvancedOutput::init()
     159             : {
     160             :   // Initialize the execution flags
     161     2276180 :   for (auto & [name, input] : _advanced_execute_on)
     162     1922522 :     initExecutionTypes(name, input);
     163             : 
     164             :   // Clear existing execute information lists
     165      353658 :   _execute_data.reset();
     166             : 
     167             :   // Initialize the available output
     168      353658 :   initAvailableLists();
     169             : 
     170             :   // Separate the hide/show list into components
     171     1414614 :   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      353649 :   if (_elemental_as_nodal)
     178             :   {
     179        3086 :     OutputData & nodal = _execute_data["nodal"];
     180        3086 :     OutputData & elemental = _execute_data["elemental"];
     181        1543 :     nodal.show.insert(elemental.show.begin(), elemental.show.end());
     182        1543 :     nodal.hide.insert(elemental.hide.begin(), elemental.hide.end());
     183        1543 :     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      353649 :   if (_scalar_as_nodal)
     188             :   {
     189         136 :     OutputData & nodal = _execute_data["nodal"];
     190         136 :     OutputData & scalar = _execute_data["scalars"];
     191          68 :     nodal.show.insert(scalar.show.begin(), scalar.show.end());
     192          68 :     nodal.hide.insert(scalar.hide.begin(), scalar.hide.end());
     193          68 :     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     2475516 :   for (auto & it : _execute_data)
     198     2121873 :     initOutputList(it.second);
     199      353643 : }
     200             : 
     201      111287 : 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     8323959 : AdvancedOutput::shouldOutput()
     268             : {
     269     8323959 :   if (!checkFilename())
     270         544 :     return false;
     271             : 
     272     8323415 :   if (hasOutput(_current_execute_flag))
     273      394170 :     return true;
     274             :   else
     275     7929245 :     return Output::shouldOutput();
     276             : }
     277             : 
     278             : void
     279      242122 : AdvancedOutput::output()
     280             : {
     281      242122 :   const auto & type = _current_execute_flag;
     282             : 
     283             :   // (re)initialize the list of available items for output
     284      242122 :   init();
     285             : 
     286             :   // Call the various output types, if data exists
     287      484244 :   if (wantOutput("nodal", type))
     288             :   {
     289      149921 :     outputNodalVariables();
     290      449763 :     _last_execute_time["nodal"] = _time;
     291             :   }
     292             : 
     293      484244 :   if (wantOutput("elemental", type))
     294             :   {
     295       34713 :     outputElementalVariables();
     296      104139 :     _last_execute_time["elemental"] = _time;
     297             :   }
     298             : 
     299      484244 :   if (wantOutput("postprocessors", type))
     300             :   {
     301       99133 :     outputPostprocessors();
     302      297399 :     _last_execute_time["postprocessors"] = _time;
     303             :   }
     304             : 
     305      484244 :   if (wantOutput("vector_postprocessors", type))
     306             :   {
     307        8060 :     outputVectorPostprocessors();
     308       24180 :     _last_execute_time["vector_postprocessors"] = _time;
     309             :   }
     310             : 
     311      484244 :   if (wantOutput("scalars", type))
     312             :   {
     313       13371 :     outputScalarVariables();
     314       40113 :     _last_execute_time["scalars"] = _time;
     315             :   }
     316             : 
     317      484244 :   if (wantOutput("system_information", type))
     318             :   {
     319         729 :     outputSystemInformation();
     320        2187 :     _last_execute_time["system_information"] = _time;
     321             :   }
     322             : 
     323      484244 :   if (wantOutput("input", type))
     324             :   {
     325       33608 :     outputInput();
     326      100824 :     _last_execute_time["input"] = _time;
     327             :   }
     328             : 
     329      484244 :   if (wantOutput("reporters", type))
     330             :   {
     331        4645 :     outputReporters();
     332       13935 :     _last_execute_time["reporters"] = _time;
     333             :   }
     334      242122 : }
     335             : 
     336             : bool
     337    63362210 : 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    63362210 :   if (type == EXEC_FORCED && (name == "system_information" || name == "input"))
     341        8752 :     return false;
     342             : 
     343             :   // Do not output if the 'none' is contained by the execute_on
     344   188761674 :   if (_advanced_execute_on.contains(name) && _advanced_execute_on[name].isValueSet("none"))
     345       26353 :     return false;
     346             : 
     347             :   // Data output flag, true if data exists to be output
     348    63327105 :   bool execute_data_flag = true;
     349             : 
     350             :   // Set flag to false, if the OutputData exists and the output variable list is empty
     351    63327105 :   std::map<std::string, OutputData>::const_iterator iter = _execute_data.find(name);
     352    63327105 :   if (iter != _execute_data.end() && iter->second.output.empty())
     353    35047256 :     execute_data_flag = false;
     354             : 
     355             :   // Set flag to false, if the OutputOnWarehouse DOES NOT contain an entry
     356    63327105 :   if (!_advanced_execute_on.contains(name))
     357      649350 :     execute_data_flag = false;
     358             : 
     359             :   // Force the output, if there is something to output and the time has not been output
     360    63327105 :   if (type == EXEC_FORCED && execute_data_flag && _last_execute_time[name] != _time)
     361        2212 :     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    64302081 :   if (execute_data_flag && _advanced_execute_on[name].isValueSet(type) &&
     369      977188 :       !(type == EXEC_FINAL && _last_execute_time[name] == _time))
     370      976266 :     return true;
     371             :   else
     372    62348627 :     return false;
     373             : }
     374             : 
     375             : bool
     376     8323415 : AdvancedOutput::hasOutput(const ExecFlagType & type)
     377             : {
     378             :   // If any of the component outputs are true, then there is some output to perform
     379    53497686 :   for (const auto & it : _advanced_execute_on)
     380    45568441 :     if (wantOutput(it.first, type))
     381      394170 :       return true;
     382             : 
     383             :   // There is nothing to output
     384     7929245 :   return false;
     385             : }
     386             : 
     387             : bool
     388       36441 : AdvancedOutput::hasOutput()
     389             : {
     390             :   // Test that variables exist for output AND that output execution flags are valid
     391       58390 :   for (const auto & it : _execute_data)
     392       94831 :     if (!(it.second).output.empty() && _advanced_execute_on.contains(it.first) &&
     393       36441 :         _advanced_execute_on[it.first].isValid())
     394       36441 :       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      353658 : 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      353658 :   if (!_postprocessors_as_reporters)
     413      707133 :     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      353655 :   if (!_vectorpostprocessors_as_reporters)
     420      706630 :     initPostprocessorOrVectorPostprocessorLists<VectorPostprocessor>("vector_postprocessors");
     421             : 
     422             :   // Get a list of the available variables
     423      353655 :   std::vector<VariableName> variables = _problem_ptr->getVariableNames();
     424             : 
     425             :   // Loop through the variables and store the names in the correct available lists
     426     1433522 :   for (const auto & var_name : variables)
     427             :   {
     428     1079867 :     if (_problem_ptr->hasVariable(var_name))
     429             :     {
     430     1054823 :       MooseVariableFEBase & var = _problem_ptr->getVariable(
     431             :           0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
     432             : 
     433             :       // Skip if the 'outputs' parameter has been set to exclude this output
     434     3164469 :       if (var.isParamValid("outputs"))
     435             :       {
     436       39932 :         const auto & outputs = var.getParam<std::vector<OutputName>>("outputs");
     437       39726 :         if (outputs.size() && std::find(outputs.begin(), outputs.end(), name()) == outputs.end() &&
     438       19760 :             outputs[0] != "all")
     439       19760 :           continue;
     440             :       }
     441             : 
     442     1035063 :       const FEType type = var.feType();
     443     2083347 :       for (unsigned int i = 0; i < var.count(); ++i)
     444             :       {
     445     1048284 :         VariableName vname = var_name;
     446     1048284 :         if (var.isArray())
     447       22320 :           vname = var.arrayVariableComponent(i);
     448             : 
     449             :         // A note that if we have p-refinement we assume "worst-case" scenario that our constant
     450             :         // monomial/monomial-vec families have been refined and we can no longer write them as
     451             :         // elemental
     452     1321406 :         if (type.order == CONSTANT && !_problem_ptr->havePRefinement() &&
     453      273122 :             type.family != MONOMIAL_VEC)
     454      817422 :           _execute_data["elemental"].available.insert(vname);
     455      775810 :         else if (FEInterface::field_type(type) == TYPE_VECTOR)
     456             :         {
     457        1016 :           const auto geom_type = ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT) &&
     458         648 :                                   !_problem_ptr->havePRefinement())
     459        7223 :                                      ? "elemental"
     460        6207 :                                      : "nodal";
     461        6207 :           switch (_es_ptr->get_mesh().spatial_dimension())
     462             :           {
     463         364 :             case 0:
     464             :             case 1:
     465         728 :               _execute_data[geom_type].available.insert(vname);
     466         364 :               break;
     467        4359 :             case 2:
     468        8718 :               _execute_data[geom_type].available.insert(vname + "_x");
     469        8718 :               _execute_data[geom_type].available.insert(vname + "_y");
     470        4359 :               break;
     471        1484 :             case 3:
     472        2968 :               _execute_data[geom_type].available.insert(vname + "_x");
     473        2968 :               _execute_data[geom_type].available.insert(vname + "_y");
     474        2968 :               _execute_data[geom_type].available.insert(vname + "_z");
     475        1484 :               break;
     476             :           }
     477             :         }
     478             :         else
     479     2308809 :           _execute_data["nodal"].available.insert(vname);
     480     1048284 :       }
     481             :     }
     482             : 
     483       25044 :     else if (_problem_ptr->hasScalarVariable(var_name))
     484       75132 :       _execute_data["scalars"].available.insert(var_name);
     485             :   }
     486             : 
     487             :   // Initialize Reporter name list
     488      811073 :   for (auto && r_name : _reporter_data.getReporterNames())
     489      578552 :     if ((_postprocessors_as_reporters || !r_name.isPostprocessor()) &&
     490      121134 :         (_vectorpostprocessors_as_reporters || !r_name.isVectorPostprocessor()))
     491      447501 :       _execute_data["reporters"].available.insert(r_name);
     492      353655 : }
     493             : 
     494             : void
     495     1922522 : AdvancedOutput::initExecutionTypes(const std::string & name, ExecFlagEnum & input)
     496             : {
     497             :   // Build the input parameter name
     498     1922522 :   std::string param_name = "execute_";
     499     1922522 :   param_name += name + "_on";
     500             : 
     501             :   // The parameters exists and has been set by the user
     502     1922522 :   if (_pars.have_parameter<ExecFlagEnum>(param_name) && isParamValid(param_name))
     503      502272 :     input = getParam<ExecFlagEnum>(param_name);
     504             : 
     505             :   // If the parameter does not exists; set it to a state where no valid entries exists so nothing
     506             :   // gets executed
     507     1420250 :   else if (!_pars.have_parameter<ExecFlagEnum>(param_name))
     508             :   {
     509           0 :     input = _execute_on;
     510           0 :     input.clearSetValues();
     511             :   }
     512     1922522 : }
     513             : 
     514             : void
     515      353655 : AdvancedOutput::initShowHideLists(const std::vector<VariableName> & show,
     516             :                                   const std::vector<VariableName> & hide)
     517             : {
     518             : 
     519             :   // Storage for user-supplied input that is unknown as a variable or postprocessor
     520      353655 :   std::set<std::string> unknown;
     521             : 
     522             :   // If a show hide/list exists, let the data warehouse know about it. This allows for the proper
     523             :   // handling of output lists (see initOutputList)
     524      353655 :   if (show.size() > 0)
     525        2005 :     _execute_data.setHasShowList(true);
     526             : 
     527             :   // Populate the show lists
     528      356541 :   for (const auto & var_name : show)
     529             :   {
     530        2886 :     if (_problem_ptr->hasVariable(var_name))
     531             :     {
     532        1066 :       MooseVariableFEBase & var = _problem_ptr->getVariable(
     533             :           0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
     534        1066 :       const FEType type = var.feType();
     535        2132 :       for (unsigned int i = 0; i < var.count(); ++i)
     536             :       {
     537        1066 :         VariableName vname = var_name;
     538        1066 :         if (var.isArray())
     539           0 :           vname = var.arrayVariableComponent(i);
     540             : 
     541        1066 :         if (type.order == CONSTANT)
     542         387 :           _execute_data["elemental"].show.insert(vname);
     543         937 :         else if (FEInterface::field_type(type) == TYPE_VECTOR)
     544             :         {
     545             :           const auto geom_type =
     546           0 :               ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT)) ? "elemental" : "nodal";
     547           0 :           switch (_es_ptr->get_mesh().spatial_dimension())
     548             :           {
     549           0 :             case 0:
     550             :             case 1:
     551           0 :               _execute_data[geom_type].show.insert(vname);
     552           0 :               break;
     553           0 :             case 2:
     554           0 :               _execute_data[geom_type].show.insert(vname + "_x");
     555           0 :               _execute_data[geom_type].show.insert(vname + "_y");
     556           0 :               break;
     557           0 :             case 3:
     558           0 :               _execute_data[geom_type].show.insert(vname + "_x");
     559           0 :               _execute_data[geom_type].show.insert(vname + "_y");
     560           0 :               _execute_data[geom_type].show.insert(vname + "_z");
     561           0 :               break;
     562             :           }
     563             :         }
     564             :         else
     565        2811 :           _execute_data["nodal"].show.insert(vname);
     566        1066 :       }
     567             :     }
     568        1820 :     else if (_problem_ptr->hasScalarVariable(var_name))
     569         567 :       _execute_data["scalars"].show.insert(var_name);
     570        1631 :     else if (hasPostprocessorByName(var_name))
     571        4773 :       _execute_data["postprocessors"].show.insert(var_name);
     572          40 :     else if (hasVectorPostprocessorByName(var_name))
     573         102 :       _execute_data["vector_postprocessors"].show.insert(var_name);
     574           6 :     else if ((var_name.find("/") != std::string::npos) &&
     575           6 :              (hasReporterValueByName(ReporterName(var_name))))
     576           0 :       _execute_data["reporters"].show.insert(var_name);
     577             :     else
     578           6 :       unknown.insert(var_name);
     579             :   }
     580             : 
     581             :   // Populate the hide lists
     582      389431 :   for (const auto & var_name : hide)
     583             :   {
     584       35776 :     if (_problem_ptr->hasVariable(var_name))
     585             :     {
     586       33818 :       MooseVariableFEBase & var = _problem_ptr->getVariable(
     587             :           0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
     588       33818 :       const FEType type = var.feType();
     589       68508 :       for (unsigned int i = 0; i < var.count(); ++i)
     590             :       {
     591       34690 :         VariableName vname = var_name;
     592       34690 :         if (var.isArray())
     593        1744 :           vname = var.arrayVariableComponent(i);
     594             : 
     595       34690 :         if (type.order == CONSTANT)
     596       50853 :           _execute_data["elemental"].hide.insert(vname);
     597       17739 :         else if (FEInterface::field_type(type) == TYPE_VECTOR)
     598             :         {
     599         252 :           switch (_es_ptr->get_mesh().spatial_dimension())
     600             :           {
     601          68 :             case 0:
     602             :             case 1:
     603         136 :               _execute_data["nodal"].hide.insert(vname);
     604          68 :               break;
     605         184 :             case 2:
     606         368 :               _execute_data["nodal"].hide.insert(vname + "_x");
     607         368 :               _execute_data["nodal"].hide.insert(vname + "_y");
     608         184 :               break;
     609           0 :             case 3:
     610           0 :               _execute_data["nodal"].hide.insert(vname + "_x");
     611           0 :               _execute_data["nodal"].hide.insert(vname + "_y");
     612           0 :               _execute_data["nodal"].hide.insert(vname + "_z");
     613           0 :               break;
     614             :           }
     615             :         }
     616             :         else
     617       52461 :           _execute_data["nodal"].hide.insert(vname);
     618       34690 :       }
     619             :     }
     620        1958 :     else if (_problem_ptr->hasScalarVariable(var_name))
     621        3828 :       _execute_data["scalars"].hide.insert(var_name);
     622         682 :     else if (hasPostprocessorByName(var_name))
     623        2037 :       _execute_data["postprocessors"].hide.insert(var_name);
     624           3 :     else if (hasVectorPostprocessorByName(var_name))
     625           0 :       _execute_data["vector_postprocessors"].hide.insert(var_name);
     626           3 :     else if ((var_name.find("/") != std::string::npos) &&
     627           3 :              (hasReporterValueByName(ReporterName(var_name))))
     628           0 :       _execute_data["reporters"].hide.insert(var_name);
     629             : 
     630             :     else
     631           3 :       unknown.insert(var_name);
     632             :   }
     633             : 
     634             :   // Error if an unknown variable or postprocessor is found
     635      353655 :   if (!unknown.empty())
     636             :   {
     637           6 :     std::ostringstream oss;
     638             :     oss << "Output(s) do not exist (must be variable, scalar, postprocessor, or vector "
     639           6 :            "postprocessor): ";
     640           6 :     std::copy(unknown.begin(), unknown.end(), infix_ostream_iterator<std::string>(oss, " "));
     641           6 :     mooseError(oss.str());
     642           0 :   }
     643      353649 : }
     644             : 
     645             : void
     646     2121873 : AdvancedOutput::initOutputList(OutputData & data)
     647             : {
     648             :   // References to the vectors of variable names
     649     2121873 :   std::set<std::string> & hide = data.hide;
     650     2121873 :   std::set<std::string> & show = data.show;
     651     2121873 :   std::set<std::string> & avail = data.available;
     652     2121873 :   std::set<std::string> & output = data.output;
     653             : 
     654             :   // Get the hide list from OutputInterface objects
     655     2121873 :   std::set<std::string> interface_hide_all_types;
     656     2121873 :   _app.getOutputWarehouse().buildInterfaceHideVariables(name(), interface_hide_all_types);
     657             : 
     658             :   // OutputInterface hide list includes all types; only include those that are available
     659     2121873 :   std::set<std::string> interface_hide;
     660     2121873 :   std::set_intersection(interface_hide_all_types.begin(),
     661             :                         interface_hide_all_types.end(),
     662             :                         avail.begin(),
     663             :                         avail.end(),
     664             :                         std::inserter(interface_hide, interface_hide.begin()));
     665             : 
     666             :   // Append to the hide list from OutputInterface objects
     667     2121873 :   hide.insert(interface_hide.begin(), interface_hide.end());
     668             : 
     669             :   // Both show and hide are empty and no show/hide settings were provided (show all available)
     670     2121873 :   if (!_execute_data.hasShowList() && hide.empty())
     671     2063778 :     output = avail;
     672             : 
     673             :   // Only hide is empty (show all the variables listed)
     674       58095 :   else if (_execute_data.hasShowList() && hide.empty())
     675       11742 :     output = show;
     676             : 
     677             :   // Only show is empty (show all except those hidden)
     678       46353 :   else if (!_execute_data.hasShowList() && !hide.empty())
     679       46104 :     std::set_difference(avail.begin(),
     680             :                         avail.end(),
     681             :                         hide.begin(),
     682             :                         hide.end(),
     683             :                         std::inserter(output, output.begin()));
     684             : 
     685             :   // Both hide and show are present (show all those listed)
     686             :   else // (_execute_data.hasShowList() && !hide.empty())
     687             :   {
     688             :     // Check if variables are in both, which is invalid
     689         249 :     std::vector<std::string> tmp;
     690         249 :     std::set_intersection(
     691             :         hide.begin(), hide.end(), show.begin(), show.end(), std::inserter(tmp, tmp.begin()));
     692         249 :     if (!tmp.empty())
     693             :     {
     694           6 :       std::ostringstream oss;
     695           6 :       oss << "Output(s) specified to be both shown and hidden: ";
     696           6 :       std::copy(tmp.begin(), tmp.end(), infix_ostream_iterator<std::string>(oss, " "));
     697           6 :       mooseError(oss.str());
     698           0 :     }
     699             : 
     700             :     // Define the output variable list
     701         243 :     output = show;
     702         243 :   }
     703     2121867 : }
     704             : 
     705             : void
     706      394091 : AdvancedOutput::addValidParams(InputParameters & params, const MultiMooseEnum & types)
     707             : {
     708      394091 :   ExecFlagEnum empty_execute_on = MooseUtils::getDefaultExecFlagEnum();
     709      394091 :   empty_execute_on.addAvailableFlags(EXEC_FAILED);
     710             : 
     711             :   // Nodal output
     712      788182 :   if (types.isValueSet("nodal"))
     713             :   {
     714      315144 :     params.addParam<ExecFlagEnum>(
     715             :         "execute_nodal_on", empty_execute_on, "Control the output of nodal variables");
     716      315144 :     params.addParamNamesToGroup("execute_nodal_on", "Selection/restriction of output");
     717             :   }
     718             : 
     719             :   // Elemental output
     720      788182 :   if (types.isValueSet("elemental"))
     721             :   {
     722      315144 :     params.addParam<ExecFlagEnum>(
     723             :         "execute_elemental_on", empty_execute_on, "Control the output of elemental variables");
     724      315144 :     params.addParamNamesToGroup("execute_elemental_on", "Selection/restriction of output");
     725             : 
     726             :     // Add material output control, which are output via elemental variables
     727      236358 :     params.addParam<bool>("output_material_properties",
     728      157572 :                           false,
     729             :                           "Flag indicating if material properties should be output");
     730      315144 :     params.addParam<std::vector<std::string>>(
     731             :         "show_material_properties",
     732             :         "List of material properties that should be written to the output");
     733      315144 :     params.addParamNamesToGroup("output_material_properties show_material_properties", "Materials");
     734             : 
     735             :     // Add mesh extra element id control, which are output via elemental variables
     736      236358 :     params.addParam<bool>(
     737             :         "output_extra_element_ids",
     738      157572 :         false,
     739             :         "Flag indicating if extra element ids defined on the mesh should be outputted");
     740      315144 :     params.addParam<std::vector<std::string>>(
     741             :         "extra_element_ids_to_output",
     742             :         "List of extra element ids defined on the mesh that should be written to the output.");
     743      315144 :     params.addParamNamesToGroup("output_extra_element_ids extra_element_ids_to_output", "Mesh");
     744             :   }
     745             : 
     746             :   // Scalar variable output
     747      788182 :   if (types.isValueSet("scalar"))
     748             :   {
     749     1535268 :     params.addParam<ExecFlagEnum>(
     750             :         "execute_scalars_on", empty_execute_on, "Control the output of scalar variables");
     751     1535268 :     params.addParamNamesToGroup("execute_scalars_on", "Selection/restriction of output");
     752             :   }
     753             : 
     754             :   // Nodal and scalar output
     755     1339845 :   if (types.isValueSet("nodal") && types.isValueSet("scalar"))
     756             :   {
     757      315144 :     params.addParam<bool>("scalar_as_nodal", false, "Output scalar variables as nodal");
     758      315144 :     params.addParamNamesToGroup("scalar_as_nodal", "Conversions before output");
     759             :   }
     760             : 
     761             :   // Elemental and nodal
     762     1339845 :   if (types.isValueSet("elemental") && types.isValueSet("nodal"))
     763             :   {
     764      236358 :     params.addParam<bool>(
     765      157572 :         "elemental_as_nodal", false, "Output elemental nonlinear variables as nodal");
     766      315144 :     params.addParamNamesToGroup("elemental_as_nodal", "Conversions before output");
     767             :   }
     768             : 
     769             :   // Postprocessors
     770      788182 :   if (types.isValueSet("postprocessor"))
     771             :   {
     772     1535268 :     params.addParam<ExecFlagEnum>(
     773             :         "execute_postprocessors_on", empty_execute_on, "Control of when postprocessors are output");
     774     1535268 :     params.addParamNamesToGroup("execute_postprocessors_on", "Selection/restriction of output");
     775             :   }
     776             : 
     777             :   // Vector Postprocessors
     778      788182 :   if (types.isValueSet("vector_postprocessor"))
     779             :   {
     780      688832 :     params.addParam<ExecFlagEnum>("execute_vector_postprocessors_on",
     781             :                                   empty_execute_on,
     782             :                                   "Enable/disable the output of VectorPostprocessors");
     783      688832 :     params.addParamNamesToGroup("execute_vector_postprocessors_on",
     784             :                                 "Selection/restriction of output");
     785             :   }
     786             : 
     787             :   // Reporters
     788      788182 :   if (types.isValueSet("reporter"))
     789             :   {
     790     1019528 :     params.addParam<ExecFlagEnum>(
     791             :         "execute_reporters_on", empty_execute_on, "Control of when Reporter values are output");
     792     1019528 :     params.addParamNamesToGroup("execute_reporters_on", "Selection/restriction of output");
     793             :   }
     794             : 
     795             :   // Input file
     796      788182 :   if (types.isValueSet("input"))
     797             :   {
     798      859208 :     params.addParam<ExecFlagEnum>(
     799             :         "execute_input_on", empty_execute_on, "Enable/disable the output of the input file");
     800      859208 :     params.addParamNamesToGroup("execute_input_on", "Selection/restriction of output");
     801             :   }
     802             : 
     803             :   // System Information
     804      788182 :   if (types.isValueSet("system_information"))
     805             :   {
     806      558016 :     params.addParam<ExecFlagEnum>("execute_system_information_on",
     807             :                                   empty_execute_on,
     808             :                                   "Control when the output of the simulation information occurs");
     809      558016 :     params.addParamNamesToGroup("execute_system_information_on", "Selection/restriction of output");
     810             :   }
     811      394091 : }
     812             : 
     813             : bool
     814       71242 : AdvancedOutput::hasOutputHelper(const std::string & name)
     815             : {
     816      134785 :   return !_execute_data[name].output.empty() && _advanced_execute_on.contains(name) &&
     817      333113 :          _advanced_execute_on[name].isValid() && !_advanced_execute_on[name].isValueSet("none");
     818             : }
     819             : 
     820             : bool
     821       67349 : AdvancedOutput::hasNodalVariableOutput()
     822             : {
     823      134698 :   return hasOutputHelper("nodal");
     824             : }
     825             : 
     826             : const std::set<std::string> &
     827      301758 : AdvancedOutput::getNodalVariableOutput()
     828             : {
     829      905274 :   return _execute_data["nodal"].output;
     830             : }
     831             : 
     832             : bool
     833        3803 : AdvancedOutput::hasElementalVariableOutput()
     834             : {
     835        7606 :   return hasOutputHelper("elemental");
     836             : }
     837             : 
     838             : const std::set<std::string> &
     839       71342 : AdvancedOutput::getElementalVariableOutput()
     840             : {
     841      214026 :   return _execute_data["elemental"].output;
     842             : }
     843             : 
     844             : bool
     845          45 : AdvancedOutput::hasScalarOutput()
     846             : {
     847          90 :   return hasOutputHelper("scalars");
     848             : }
     849             : 
     850             : const std::set<std::string> &
     851       42245 : AdvancedOutput::getScalarOutput()
     852             : {
     853      126735 :   return _execute_data["scalars"].output;
     854             : }
     855             : 
     856             : bool
     857          45 : AdvancedOutput::hasPostprocessorOutput()
     858             : {
     859          90 :   return hasOutputHelper("postprocessors");
     860             : }
     861             : 
     862             : const std::set<std::string> &
     863      386106 : AdvancedOutput::getPostprocessorOutput()
     864             : {
     865     1158318 :   return _execute_data["postprocessors"].output;
     866             : }
     867             : 
     868             : bool
     869           0 : AdvancedOutput::hasVectorPostprocessorOutput()
     870             : {
     871           0 :   return hasOutputHelper("vector_postprocessors");
     872             : }
     873             : 
     874             : const std::set<std::string> &
     875       26397 : AdvancedOutput::getVectorPostprocessorOutput()
     876             : {
     877       79191 :   return _execute_data["vector_postprocessors"].output;
     878             : }
     879             : 
     880             : bool
     881           0 : AdvancedOutput::hasReporterOutput()
     882             : {
     883           0 :   return hasOutputHelper("reporters");
     884             : }
     885             : 
     886             : const std::set<std::string> &
     887       25490 : AdvancedOutput::getReporterOutput()
     888             : {
     889       76470 :   return _execute_data["reporters"].output;
     890             : }
     891             : 
     892             : const OutputOnWarehouse &
     893       45022 : AdvancedOutput::advancedExecuteOn() const
     894             : {
     895       45022 :   return _advanced_execute_on;
     896             : }

Generated by: LCOV version 1.14