LCOV - code coverage report
Current view: top level - src/outputs - AdvancedOutput.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31653 (1b668c) with base bb0a08 Lines: 339 402 84.3 %
Date: 2025-11-03 17:02:13 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      445052 : addAdvancedOutputParams(InputParameters & params)
      38             : {
      39             :   // Hide/show variable output options
      40     1780208 :   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     1780208 :   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     1335156 :   params.addParam<bool>(
      54      890104 :       "postprocessors_as_reporters", false, "Output Postprocessors values as Reporter values.");
      55     1335156 :   params.addParam<bool>("vectorpostprocessors_as_reporters",
      56      890104 :                         false,
      57             :                         "Output VectorsPostprocessors vectors as Reporter values.");
      58             : 
      59             :   // Group for selecting the output
      60     1780208 :   params.addParamNamesToGroup("hide show", "Selection/restriction of output");
      61             : 
      62             :   // Group for converting outputs
      63     1780208 :   params.addParamNamesToGroup("postprocessors_as_reporters vectorpostprocessors_as_reporters",
      64             :                               "Conversions before output");
      65             : 
      66             :   // **** DEPRECATED PARAMS ****
      67     2225260 :   params.addDeprecatedParam<bool>("output_postprocessors",
      68      890104 :                                   true,
      69             :                                   "Enable/disable the output of postprocessors",
      70             :                                   "'execute_postprocessors_on' has replaced this parameter");
      71     2225260 :   params.addDeprecatedParam<bool>("execute_vector_postprocessors",
      72      890104 :                                   true,
      73             :                                   "Enable/disable the output of vector postprocessors",
      74             :                                   "'execute_vector_postprocessors_on' has replaced this parameter");
      75     2225260 :   params.addDeprecatedParam<bool>("execute_system_information",
      76      890104 :                                   true,
      77             :                                   "Enable/disable the output of the simulation information",
      78             :                                   "'execute_system_information_on' has replaced this parameter");
      79     2225260 :   params.addDeprecatedParam<bool>("execute_elemental_variables",
      80      890104 :                                   true,
      81             :                                   "Enable/disable the output of elemental variables",
      82             :                                   "'execute_elemental_on' has replaced this parameter");
      83     2225260 :   params.addDeprecatedParam<bool>("execute_nodal_variables",
      84      890104 :                                   true,
      85             :                                   "Enable/disable the output of nodal variables",
      86             :                                   "'execute_nodal_on' has replaced this parameter");
      87     2225260 :   params.addDeprecatedParam<bool>("execute_scalar_variables",
      88     1335156 :                                   true,
      89             :                                   "Enable/disable the output of aux scalar variables",
      90             :                                   "'execute_scalars_on' has replaced this parameter");
      91     1780208 :   params.addDeprecatedParam<bool>("execute_input",
      92      890104 :                                   true,
      93             :                                   "Enable/disable the output of input file information",
      94             :                                   "'execute_input_on' has replaced this parameter");
      95      445052 : }
      96             : }
      97             : 
      98             : InputParameters
      99      445052 : AdvancedOutput::validParams()
     100             : {
     101             :   // Get the parameters from the parent object
     102      445052 :   InputParameters params = FileOutput::validParams();
     103      445052 :   addAdvancedOutputParams(params);
     104      445052 :   return params;
     105           0 : }
     106             : 
     107             : // Defines the output types to enable for the AdvancedOutput object
     108             : MultiMooseEnum
     109      531785 : AdvancedOutput::getOutputTypes()
     110             : {
     111             :   return MultiMooseEnum("nodal=0 elemental=1 scalar=2 postprocessor=3 vector_postprocessor=4 "
     112     1063570 :                         "input=5 system_information=6 reporter=7");
     113             : }
     114             : 
     115             : // Enables the output types (see getOutputTypes) for an AdvancedOutput object
     116             : InputParameters
     117      531785 : AdvancedOutput::enableOutputTypes(const std::string & names)
     118             : {
     119             :   // The parameters object that will be returned
     120      531785 :   InputParameters params = emptyInputParameters();
     121             : 
     122             :   // Get the MultiEnum of output types
     123      531785 :   MultiMooseEnum output_types = getOutputTypes();
     124             : 
     125             :   // Update the enum of output types to append
     126      531785 :   if (names.empty())
     127           0 :     output_types = output_types.getRawNames();
     128             :   else
     129      531785 :     output_types = names;
     130             : 
     131             :   // Add the parameters and return them
     132      531785 :   addValidParams(params, output_types);
     133     1063570 :   return params;
     134      531785 : }
     135             : 
     136             : // Constructor
     137      120908 : AdvancedOutput::AdvancedOutput(const InputParameters & parameters)
     138             :   : FileOutput(parameters),
     139      198650 :     _elemental_as_nodal(isParamValid("elemental_as_nodal") ? getParam<bool>("elemental_as_nodal")
     140             :                                                            : false),
     141      319546 :     _scalar_as_nodal(isParamValid("scalar_as_nodal") ? getParam<bool>("scalar_as_nodal") : false),
     142      120896 :     _reporter_data(_problem_ptr->getReporterData()),
     143      241792 :     _last_execute_time(declareRecoverableData<std::map<std::string, Real>>("last_execute_time")),
     144      241792 :     _postprocessors_as_reporters(getParam<bool>("postprocessors_as_reporters")),
     145      483596 :     _vectorpostprocessors_as_reporters(getParam<bool>("vectorpostprocessors_as_reporters"))
     146             : {
     147      120896 :   _is_advanced = true;
     148      120896 :   _advanced_execute_on = OutputOnWarehouse(_execute_on, parameters);
     149      120896 : }
     150             : 
     151             : void
     152      116868 : AdvancedOutput::initialSetup()
     153             : {
     154      116868 :   init();
     155      116848 : }
     156             : 
     157             : void
     158      379555 : AdvancedOutput::init()
     159             : {
     160             :   // Initialize the execution flags
     161     2441410 :   for (auto & [name, input] : _advanced_execute_on)
     162     2061855 :     initExecutionTypes(name, input);
     163             : 
     164             :   // Clear existing execute information lists
     165      379555 :   _execute_data.reset();
     166             : 
     167             :   // Initialize the available output
     168      379555 :   initAvailableLists();
     169             : 
     170             :   // Separate the hide/show list into components
     171     1518196 :   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      379543 :   if (_elemental_as_nodal)
     178             :   {
     179        3190 :     OutputData & nodal = _execute_data["nodal"];
     180        3190 :     OutputData & elemental = _execute_data["elemental"];
     181        1595 :     nodal.show.insert(elemental.show.begin(), elemental.show.end());
     182        1595 :     nodal.hide.insert(elemental.hide.begin(), elemental.hide.end());
     183        1595 :     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      379543 :   if (_scalar_as_nodal)
     188             :   {
     189         148 :     OutputData & nodal = _execute_data["nodal"];
     190         148 :     OutputData & scalar = _execute_data["scalars"];
     191          74 :     nodal.show.insert(scalar.show.begin(), scalar.show.end());
     192          74 :     nodal.hide.insert(scalar.hide.begin(), scalar.hide.end());
     193          74 :     nodal.available.insert(scalar.available.begin(), scalar.available.end());
     194             :   }
     195             : 
     196             :   // Initialize the show/hide/output lists for each of the types of output
     197     2656765 :   for (auto & it : _execute_data)
     198     2277230 :     initOutputList(it.second);
     199      379535 : }
     200             : 
     201      115481 : 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     9080902 : AdvancedOutput::shouldOutput()
     268             : {
     269     9080902 :   if (!checkFilename())
     270         612 :     return false;
     271             : 
     272     9080290 :   if (hasOutput(_current_execute_flag))
     273      427873 :     return true;
     274             :   else
     275     8652417 :     return Output::shouldOutput();
     276             : }
     277             : 
     278             : void
     279      262687 : AdvancedOutput::output()
     280             : {
     281      262687 :   const auto & type = _current_execute_flag;
     282             : 
     283             :   // (re)initialize the list of available items for output
     284      262687 :   init();
     285             : 
     286             :   // Call the various output types, if data exists
     287      525374 :   if (wantOutput("nodal", type))
     288             :   {
     289      162238 :     outputNodalVariables();
     290      486714 :     _last_execute_time["nodal"] = _time;
     291             :   }
     292             : 
     293      525374 :   if (wantOutput("elemental", type))
     294             :   {
     295       37204 :     outputElementalVariables();
     296      111612 :     _last_execute_time["elemental"] = _time;
     297             :   }
     298             : 
     299      525374 :   if (wantOutput("postprocessors", type))
     300             :   {
     301      107438 :     outputPostprocessors();
     302      322314 :     _last_execute_time["postprocessors"] = _time;
     303             :   }
     304             : 
     305      525374 :   if (wantOutput("vector_postprocessors", type))
     306             :   {
     307        7840 :     outputVectorPostprocessors();
     308       23520 :     _last_execute_time["vector_postprocessors"] = _time;
     309             :   }
     310             : 
     311      525374 :   if (wantOutput("scalars", type))
     312             :   {
     313       17385 :     outputScalarVariables();
     314       52155 :     _last_execute_time["scalars"] = _time;
     315             :   }
     316             : 
     317      525374 :   if (wantOutput("system_information", type))
     318             :   {
     319         821 :     outputSystemInformation();
     320        2463 :     _last_execute_time["system_information"] = _time;
     321             :   }
     322             : 
     323      525374 :   if (wantOutput("input", type))
     324             :   {
     325       35607 :     outputInput();
     326      106821 :     _last_execute_time["input"] = _time;
     327             :   }
     328             : 
     329      525374 :   if (wantOutput("reporters", type))
     330             :   {
     331        4967 :     outputReporters();
     332       14901 :     _last_execute_time["reporters"] = _time;
     333             :   }
     334      262687 : }
     335             : 
     336             : bool
     337    72439337 : 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    72439337 :   if (type == EXEC_FORCED && (name == "system_information" || name == "input"))
     341        9563 :     return false;
     342             : 
     343             :   // Do not output if the 'none' is contained by the execute_on
     344   215879394 :   if (_advanced_execute_on.contains(name) && _advanced_execute_on[name].isValueSet("none"))
     345       26261 :     return false;
     346             : 
     347             :   // Data output flag, true if data exists to be output
     348    72403513 :   bool execute_data_flag = true;
     349             : 
     350             :   // Set flag to false, if the OutputData exists and the output variable list is empty
     351    72403513 :   std::map<std::string, OutputData>::const_iterator iter = _execute_data.find(name);
     352    72403513 :   if (iter != _execute_data.end() && iter->second.output.empty())
     353    39765750 :     execute_data_flag = false;
     354             : 
     355             :   // Set flag to false, if the OutputOnWarehouse DOES NOT contain an entry
     356    72403513 :   if (!_advanced_execute_on.contains(name))
     357      704964 :     execute_data_flag = false;
     358             : 
     359             :   // Force the output, if there is something to output and the time has not been output
     360    72403513 :   if (type == EXEC_FORCED && execute_data_flag && _last_execute_time[name] != _time)
     361        2416 :     return true;
     362             : 
     363             :   // Return true (output should occur) if three criteria are satisfied, else do not output:
     364             :   //   (1) The execute_data_flag = true (i.e, there is data to output)
     365             :   //   (2) The current output type is contained in the list of output execution types
     366             :   //   (3) The current execution time is "final" or "forced" and the data has not already been
     367             :   //   output
     368    73466424 :   if (execute_data_flag && _advanced_execute_on[name].isValueSet(type) &&
     369     1065327 :       !(type == EXEC_FINAL && _last_execute_time[name] == _time))
     370     1064295 :     return true;
     371             :   else
     372    71336802 :     return false;
     373             : }
     374             : 
     375             : bool
     376     9080290 : AdvancedOutput::hasOutput(const ExecFlagType & type)
     377             : {
     378             :   // If any of the component outputs are true, then there is some output to perform
     379    58305699 :   for (const auto & it : _advanced_execute_on)
     380    49653282 :     if (wantOutput(it.first, type))
     381      427873 :       return true;
     382             : 
     383             :   // There is nothing to output
     384     8652417 :   return false;
     385             : }
     386             : 
     387             : bool
     388       38398 : AdvancedOutput::hasOutput()
     389             : {
     390             :   // Test that variables exist for output AND that output execution flags are valid
     391       61531 :   for (const auto & it : _execute_data)
     392       99929 :     if (!(it.second).output.empty() && _advanced_execute_on.contains(it.first) &&
     393       38398 :         _advanced_execute_on[it.first].isValid())
     394       38398 :       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      379555 : 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      379555 :   if (!_postprocessors_as_reporters)
     413      758906 :     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      379551 :   if (!_vectorpostprocessors_as_reporters)
     420      758334 :     initPostprocessorOrVectorPostprocessorLists<VectorPostprocessor>("vector_postprocessors");
     421             : 
     422             :   // Get a list of the available variables
     423      379551 :   std::vector<VariableName> variables = _problem_ptr->getVariableNames();
     424             : 
     425             :   // Loop through the variables and store the names in the correct available lists
     426     1533355 :   for (const auto & var_name : variables)
     427             :   {
     428     1153804 :     if (_problem_ptr->hasVariable(var_name))
     429             :     {
     430     1122706 :       MooseVariableFEBase & var = _problem_ptr->getVariable(
     431             :           0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
     432             : 
     433     1122706 :       const FEType type = var.feType();
     434     2259610 :       for (unsigned int i = 0; i < var.count(); ++i)
     435             :       {
     436     1136904 :         VariableName vname = var_name;
     437     1136904 :         if (var.isArray())
     438       23904 :           vname = var.arrayVariableComponent(i);
     439             : 
     440             :         // A note that if we have p-refinement we assume "worst-case" scenario that our constant
     441             :         // monomial/monomial-vec families have been refined and we can no longer write them as
     442             :         // elemental
     443     1432208 :         if (type.order == CONSTANT && !_problem_ptr->havePRefinement() &&
     444      295304 :             type.family != MONOMIAL_VEC)
     445      883767 :           _execute_data["elemental"].available.insert(vname);
     446      842315 :         else if (FEInterface::field_type(type) == TYPE_VECTOR)
     447             :         {
     448        1115 :           const auto geom_type = ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT) &&
     449         715 :                                   !_problem_ptr->havePRefinement())
     450        7926 :                                      ? "elemental"
     451        6811 :                                      : "nodal";
     452        6811 :           switch (_es_ptr->get_mesh().spatial_dimension())
     453             :           {
     454         403 :             case 0:
     455             :             case 1:
     456         806 :               _execute_data[geom_type].available.insert(vname);
     457         403 :               break;
     458        4892 :             case 2:
     459        9784 :               _execute_data[geom_type].available.insert(vname + "_x");
     460        9784 :               _execute_data[geom_type].available.insert(vname + "_y");
     461        4892 :               break;
     462        1516 :             case 3:
     463        3032 :               _execute_data[geom_type].available.insert(vname + "_x");
     464        3032 :               _execute_data[geom_type].available.insert(vname + "_y");
     465        3032 :               _execute_data[geom_type].available.insert(vname + "_z");
     466        1516 :               break;
     467             :           }
     468             :         }
     469             :         else
     470     2506512 :           _execute_data["nodal"].available.insert(vname);
     471     1136904 :       }
     472             :     }
     473             : 
     474       31098 :     else if (_problem_ptr->hasScalarVariable(var_name))
     475       93294 :       _execute_data["scalars"].available.insert(var_name);
     476             :   }
     477             : 
     478             :   // Initialize Reporter name list
     479      865401 :   for (auto && r_name : _reporter_data.getReporterNames())
     480      604145 :     if ((_postprocessors_as_reporters || !r_name.isPostprocessor()) &&
     481      118295 :         (_vectorpostprocessors_as_reporters || !r_name.isVectorPostprocessor()))
     482      475785 :       _execute_data["reporters"].available.insert(r_name);
     483      379551 : }
     484             : 
     485             : void
     486     2061855 : AdvancedOutput::initExecutionTypes(const std::string & name, ExecFlagEnum & input)
     487             : {
     488             :   // Build the input parameter name
     489     2061855 :   std::string param_name = "execute_";
     490     2061855 :   param_name += name + "_on";
     491             : 
     492             :   // The parameters exists and has been set by the user
     493     2061855 :   if (_pars.have_parameter<ExecFlagEnum>(param_name) && isParamValid(param_name))
     494      531825 :     input = getParam<ExecFlagEnum>(param_name);
     495             : 
     496             :   // If the parameter does not exists; set it to a state where no valid entries exists so nothing
     497             :   // gets executed
     498     1530030 :   else if (!_pars.have_parameter<ExecFlagEnum>(param_name))
     499             :   {
     500           0 :     input = _execute_on;
     501           0 :     input.clearSetValues();
     502             :   }
     503     2061855 : }
     504             : 
     505             : void
     506      379551 : AdvancedOutput::initShowHideLists(const std::vector<VariableName> & show,
     507             :                                   const std::vector<VariableName> & hide)
     508             : {
     509             : 
     510             :   // Storage for user-supplied input that is unknown as a variable or postprocessor
     511      379551 :   std::set<std::string> unknown;
     512             : 
     513             :   // If a show hide/list exists, let the data warehouse know about it. This allows for the proper
     514             :   // handling of output lists (see initOutputList)
     515      379551 :   if (show.size() > 0)
     516        2066 :     _execute_data.setHasShowList(true);
     517             : 
     518             :   // Populate the show lists
     519      382580 :   for (const auto & var_name : show)
     520             :   {
     521        3029 :     if (_problem_ptr->hasVariable(var_name))
     522             :     {
     523        1078 :       MooseVariableFEBase & var = _problem_ptr->getVariable(
     524             :           0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
     525        1078 :       const FEType type = var.feType();
     526        2156 :       for (unsigned int i = 0; i < var.count(); ++i)
     527             :       {
     528        1078 :         VariableName vname = var_name;
     529        1078 :         if (var.isArray())
     530           0 :           vname = var.arrayVariableComponent(i);
     531             : 
     532        1078 :         if (type.order == CONSTANT)
     533         423 :           _execute_data["elemental"].show.insert(vname);
     534         937 :         else if (FEInterface::field_type(type) == TYPE_VECTOR)
     535             :         {
     536             :           const auto geom_type =
     537           0 :               ((type.family == MONOMIAL_VEC) && (type.order == CONSTANT)) ? "elemental" : "nodal";
     538           0 :           switch (_es_ptr->get_mesh().spatial_dimension())
     539             :           {
     540           0 :             case 0:
     541             :             case 1:
     542           0 :               _execute_data[geom_type].show.insert(vname);
     543           0 :               break;
     544           0 :             case 2:
     545           0 :               _execute_data[geom_type].show.insert(vname + "_x");
     546           0 :               _execute_data[geom_type].show.insert(vname + "_y");
     547           0 :               break;
     548           0 :             case 3:
     549           0 :               _execute_data[geom_type].show.insert(vname + "_x");
     550           0 :               _execute_data[geom_type].show.insert(vname + "_y");
     551           0 :               _execute_data[geom_type].show.insert(vname + "_z");
     552           0 :               break;
     553             :           }
     554             :         }
     555             :         else
     556        2811 :           _execute_data["nodal"].show.insert(vname);
     557        1078 :       }
     558             :     }
     559        1951 :     else if (_problem_ptr->hasScalarVariable(var_name))
     560         627 :       _execute_data["scalars"].show.insert(var_name);
     561        1742 :     else if (hasPostprocessorByName(var_name))
     562        5091 :       _execute_data["postprocessors"].show.insert(var_name);
     563          45 :     else if (hasVectorPostprocessorByName(var_name))
     564         111 :       _execute_data["vector_postprocessors"].show.insert(var_name);
     565           8 :     else if ((var_name.find("/") != std::string::npos) &&
     566           8 :              (hasReporterValueByName(ReporterName(var_name))))
     567           0 :       _execute_data["reporters"].show.insert(var_name);
     568             :     else
     569           8 :       unknown.insert(var_name);
     570             :   }
     571             : 
     572             :   // Populate the hide lists
     573      413390 :   for (const auto & var_name : hide)
     574             :   {
     575       33839 :     if (_problem_ptr->hasVariable(var_name))
     576             :     {
     577       31644 :       MooseVariableFEBase & var = _problem_ptr->getVariable(
     578             :           0, var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_ANY);
     579       31644 :       const FEType type = var.feType();
     580       64270 :       for (unsigned int i = 0; i < var.count(); ++i)
     581             :       {
     582       32626 :         VariableName vname = var_name;
     583       32626 :         if (var.isArray())
     584        1964 :           vname = var.arrayVariableComponent(i);
     585             : 
     586       32626 :         if (type.order == CONSTANT)
     587       47421 :           _execute_data["elemental"].hide.insert(vname);
     588       16819 :         else if (FEInterface::field_type(type) == TYPE_VECTOR)
     589             :         {
     590         274 :           switch (_es_ptr->get_mesh().spatial_dimension())
     591             :           {
     592          74 :             case 0:
     593             :             case 1:
     594         148 :               _execute_data["nodal"].hide.insert(vname);
     595          74 :               break;
     596         200 :             case 2:
     597         400 :               _execute_data["nodal"].hide.insert(vname + "_x");
     598         400 :               _execute_data["nodal"].hide.insert(vname + "_y");
     599         200 :               break;
     600           0 :             case 3:
     601           0 :               _execute_data["nodal"].hide.insert(vname + "_x");
     602           0 :               _execute_data["nodal"].hide.insert(vname + "_y");
     603           0 :               _execute_data["nodal"].hide.insert(vname + "_z");
     604           0 :               break;
     605             :           }
     606             :         }
     607             :         else
     608       49635 :           _execute_data["nodal"].hide.insert(vname);
     609       32626 :       }
     610             :     }
     611        2195 :     else if (_problem_ptr->hasScalarVariable(var_name))
     612        4353 :       _execute_data["scalars"].hide.insert(var_name);
     613         744 :     else if (hasPostprocessorByName(var_name))
     614        2220 :       _execute_data["postprocessors"].hide.insert(var_name);
     615           4 :     else if (hasVectorPostprocessorByName(var_name))
     616           0 :       _execute_data["vector_postprocessors"].hide.insert(var_name);
     617           4 :     else if ((var_name.find("/") != std::string::npos) &&
     618           4 :              (hasReporterValueByName(ReporterName(var_name))))
     619           0 :       _execute_data["reporters"].hide.insert(var_name);
     620             : 
     621             :     else
     622           4 :       unknown.insert(var_name);
     623             :   }
     624             : 
     625             :   // Error if an unknown variable or postprocessor is found
     626      379551 :   if (!unknown.empty())
     627             :   {
     628           8 :     std::ostringstream oss;
     629             :     oss << "Output(s) do not exist (must be variable, scalar, postprocessor, or vector "
     630           8 :            "postprocessor): ";
     631           8 :     std::copy(unknown.begin(), unknown.end(), infix_ostream_iterator<std::string>(oss, " "));
     632           8 :     mooseError(oss.str());
     633           0 :   }
     634      379543 : }
     635             : 
     636             : void
     637     2277230 : AdvancedOutput::initOutputList(OutputData & data)
     638             : {
     639             :   // References to the vectors of variable names
     640     2277230 :   std::set<std::string> & hide = data.hide;
     641     2277230 :   std::set<std::string> & show = data.show;
     642     2277230 :   std::set<std::string> & avail = data.available;
     643     2277230 :   std::set<std::string> & output = data.output;
     644             : 
     645             :   // Get the hide list from OutputInterface objects
     646     2277230 :   std::set<std::string> interface_hide_all_types;
     647     2277230 :   _app.getOutputWarehouse().buildInterfaceHideVariables(name(), interface_hide_all_types);
     648             : 
     649             :   // OutputInterface hide list includes all types; only include those that are available
     650     2277230 :   std::set<std::string> interface_hide;
     651     2277230 :   std::set_intersection(interface_hide_all_types.begin(),
     652             :                         interface_hide_all_types.end(),
     653             :                         avail.begin(),
     654             :                         avail.end(),
     655             :                         std::inserter(interface_hide, interface_hide.begin()));
     656             : 
     657             :   // Append to the hide list from OutputInterface objects
     658     2277230 :   hide.insert(interface_hide.begin(), interface_hide.end());
     659             : 
     660             :   // Both show and hide are empty and no show/hide settings were provided (show all available)
     661     2277230 :   if (!_execute_data.hasShowList() && hide.empty())
     662     2217849 :     output = avail;
     663             : 
     664             :   // Only hide is empty (show all the variables listed)
     665       59381 :   else if (_execute_data.hasShowList() && hide.empty())
     666       12245 :     output = show;
     667             : 
     668             :   // Only show is empty (show all except those hidden)
     669       47136 :   else if (!_execute_data.hasShowList() && !hide.empty())
     670       47037 :     std::set_difference(avail.begin(),
     671             :                         avail.end(),
     672             :                         hide.begin(),
     673             :                         hide.end(),
     674             :                         std::inserter(output, output.begin()));
     675             : 
     676             :   // Both hide and show are present (show all those listed)
     677             :   else // (_execute_data.hasShowList() && !hide.empty())
     678             :   {
     679             :     // Check if variables are in both, which is invalid
     680          99 :     std::vector<std::string> tmp;
     681          99 :     std::set_intersection(
     682             :         hide.begin(), hide.end(), show.begin(), show.end(), std::inserter(tmp, tmp.begin()));
     683          99 :     if (!tmp.empty())
     684             :     {
     685           8 :       std::ostringstream oss;
     686           8 :       oss << "Output(s) specified to be both shown and hidden: ";
     687           8 :       std::copy(tmp.begin(), tmp.end(), infix_ostream_iterator<std::string>(oss, " "));
     688           8 :       mooseError(oss.str());
     689           0 :     }
     690             : 
     691             :     // Define the output variable list
     692          91 :     output = show;
     693          91 :   }
     694     2277222 : }
     695             : 
     696             : void
     697      531785 : AdvancedOutput::addValidParams(InputParameters & params, const MultiMooseEnum & types)
     698             : {
     699      531785 :   ExecFlagEnum empty_execute_on = MooseUtils::getDefaultExecFlagEnum();
     700      531785 :   empty_execute_on.addAvailableFlags(EXEC_FAILED);
     701             : 
     702             :   // Nodal output
     703     1063570 :   if (types.isValueSet("nodal"))
     704             :   {
     705      380884 :     params.addParam<ExecFlagEnum>(
     706             :         "execute_nodal_on", empty_execute_on, "Control the output of nodal variables");
     707      380884 :     params.addParamNamesToGroup("execute_nodal_on", "Selection/restriction of output");
     708             :   }
     709             : 
     710             :   // Elemental output
     711     1063570 :   if (types.isValueSet("elemental"))
     712             :   {
     713      380884 :     params.addParam<ExecFlagEnum>(
     714             :         "execute_elemental_on", empty_execute_on, "Control the output of elemental variables");
     715      380884 :     params.addParamNamesToGroup("execute_elemental_on", "Selection/restriction of output");
     716             : 
     717             :     // Add material output control, which are output via elemental variables
     718      285663 :     params.addParam<bool>("output_material_properties",
     719      190442 :                           false,
     720             :                           "Flag indicating if material properties should be output");
     721      380884 :     params.addParam<std::vector<std::string>>(
     722             :         "show_material_properties",
     723             :         "List of material properties that should be written to the output");
     724      380884 :     params.addParamNamesToGroup("output_material_properties show_material_properties", "Materials");
     725             : 
     726             :     // Add mesh extra element id control, which are output via elemental variables
     727      285663 :     params.addParam<bool>(
     728             :         "output_extra_element_ids",
     729      190442 :         false,
     730             :         "Flag indicating if extra element ids defined on the mesh should be outputted");
     731      380884 :     params.addParam<std::vector<std::string>>(
     732             :         "extra_element_ids_to_output",
     733             :         "List of extra element ids defined on the mesh that should be written to the output.");
     734      380884 :     params.addParamNamesToGroup("output_extra_element_ids extra_element_ids_to_output", "Mesh");
     735             :   }
     736             : 
     737             :   // Scalar variable output
     738     1063570 :   if (types.isValueSet("scalar"))
     739             :   {
     740     1989612 :     params.addParam<ExecFlagEnum>(
     741             :         "execute_scalars_on", empty_execute_on, "Control the output of scalar variables");
     742     1989612 :     params.addParamNamesToGroup("execute_scalars_on", "Selection/restriction of output");
     743             :   }
     744             : 
     745             :   // Nodal and scalar output
     746     1785797 :   if (types.isValueSet("nodal") && types.isValueSet("scalar"))
     747             :   {
     748      380884 :     params.addParam<bool>("scalar_as_nodal", false, "Output scalar variables as nodal");
     749      380884 :     params.addParamNamesToGroup("scalar_as_nodal", "Conversions before output");
     750             :   }
     751             : 
     752             :   // Elemental and nodal
     753     1785797 :   if (types.isValueSet("elemental") && types.isValueSet("nodal"))
     754             :   {
     755      285663 :     params.addParam<bool>(
     756      190442 :         "elemental_as_nodal", false, "Output elemental nonlinear variables as nodal");
     757      380884 :     params.addParamNamesToGroup("elemental_as_nodal", "Conversions before output");
     758             :   }
     759             : 
     760             :   // Postprocessors
     761     1063570 :   if (types.isValueSet("postprocessor"))
     762             :   {
     763     1989612 :     params.addParam<ExecFlagEnum>(
     764             :         "execute_postprocessors_on", empty_execute_on, "Control of when postprocessors are output");
     765     1989612 :     params.addParamNamesToGroup("execute_postprocessors_on", "Selection/restriction of output");
     766             :   }
     767             : 
     768             :   // Vector Postprocessors
     769     1063570 :   if (types.isValueSet("vector_postprocessor"))
     770             :   {
     771      957240 :     params.addParam<ExecFlagEnum>("execute_vector_postprocessors_on",
     772             :                                   empty_execute_on,
     773             :                                   "Enable/disable the output of VectorPostprocessors");
     774      957240 :     params.addParamNamesToGroup("execute_vector_postprocessors_on",
     775             :                                 "Selection/restriction of output");
     776             :   }
     777             : 
     778             :   // Reporters
     779     1063570 :   if (types.isValueSet("reporter"))
     780             :   {
     781     1354588 :     params.addParam<ExecFlagEnum>(
     782             :         "execute_reporters_on", empty_execute_on, "Control of when Reporter values are output");
     783     1354588 :     params.addParamNamesToGroup("execute_reporters_on", "Selection/restriction of output");
     784             :   }
     785             : 
     786             :   // Input file
     787     1063570 :   if (types.isValueSet("input"))
     788             :   {
     789     1092904 :     params.addParam<ExecFlagEnum>(
     790             :         "execute_input_on", empty_execute_on, "Enable/disable the output of the input file");
     791     1092904 :     params.addParamNamesToGroup("execute_input_on", "Selection/restriction of output");
     792             :   }
     793             : 
     794             :   // System Information
     795     1063570 :   if (types.isValueSet("system_information"))
     796             :   {
     797      726852 :     params.addParam<ExecFlagEnum>("execute_system_information_on",
     798             :                                   empty_execute_on,
     799             :                                   "Control when the output of the simulation information occurs");
     800      726852 :     params.addParamNamesToGroup("execute_system_information_on", "Selection/restriction of output");
     801             :   }
     802      531785 : }
     803             : 
     804             : bool
     805       75703 : AdvancedOutput::hasOutputHelper(const std::string & name)
     806             : {
     807      142556 :   return !_execute_data[name].output.empty() && _advanced_execute_on.contains(name) &&
     808      351965 :          _advanced_execute_on[name].isValid() && !_advanced_execute_on[name].isValueSet("none");
     809             : }
     810             : 
     811             : bool
     812       71255 : AdvancedOutput::hasNodalVariableOutput()
     813             : {
     814      142510 :   return hasOutputHelper("nodal");
     815             : }
     816             : 
     817             : const std::set<std::string> &
     818      326587 : AdvancedOutput::getNodalVariableOutput()
     819             : {
     820      979761 :   return _execute_data["nodal"].output;
     821             : }
     822             : 
     823             : bool
     824        4346 : AdvancedOutput::hasElementalVariableOutput()
     825             : {
     826        8692 :   return hasOutputHelper("elemental");
     827             : }
     828             : 
     829             : const std::set<std::string> &
     830       76519 : AdvancedOutput::getElementalVariableOutput()
     831             : {
     832      229557 :   return _execute_data["elemental"].output;
     833             : }
     834             : 
     835             : bool
     836          51 : AdvancedOutput::hasScalarOutput()
     837             : {
     838         102 :   return hasOutputHelper("scalars");
     839             : }
     840             : 
     841             : const std::set<std::string> &
     842       51190 : AdvancedOutput::getScalarOutput()
     843             : {
     844      153570 :   return _execute_data["scalars"].output;
     845             : }
     846             : 
     847             : bool
     848          51 : AdvancedOutput::hasPostprocessorOutput()
     849             : {
     850         102 :   return hasOutputHelper("postprocessors");
     851             : }
     852             : 
     853             : const std::set<std::string> &
     854      430550 : AdvancedOutput::getPostprocessorOutput()
     855             : {
     856     1291650 :   return _execute_data["postprocessors"].output;
     857             : }
     858             : 
     859             : bool
     860           0 : AdvancedOutput::hasVectorPostprocessorOutput()
     861             : {
     862           0 :   return hasOutputHelper("vector_postprocessors");
     863             : }
     864             : 
     865             : const std::set<std::string> &
     866       27944 : AdvancedOutput::getVectorPostprocessorOutput()
     867             : {
     868       83832 :   return _execute_data["vector_postprocessors"].output;
     869             : }
     870             : 
     871             : bool
     872           0 : AdvancedOutput::hasReporterOutput()
     873             : {
     874           0 :   return hasOutputHelper("reporters");
     875             : }
     876             : 
     877             : const std::set<std::string> &
     878       27050 : AdvancedOutput::getReporterOutput()
     879             : {
     880       81150 :   return _execute_data["reporters"].output;
     881             : }
     882             : 
     883             : const OutputOnWarehouse &
     884       46790 : AdvancedOutput::advancedExecuteOn() const
     885             : {
     886       46790 :   return _advanced_execute_on;
     887             : }

Generated by: LCOV version 1.14