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

Generated by: LCOV version 1.14