LCOV - code coverage report
Current view: top level - src/interfaces - OutputInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: fef103 Lines: 34 34 100.0 %
Date: 2025-09-03 20:01:23 Functions: 4 4 100.0 %
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             : // MOOSE includes
      11             : #include "OutputInterface.h"
      12             : #include "OutputWarehouse.h"
      13             : #include "MooseApp.h"
      14             : #include "ActionWarehouse.h"
      15             : 
      16             : // Define input parameters
      17             : InputParameters
      18     7232251 : OutputInterface::validParams()
      19             : {
      20             : 
      21     7232251 :   InputParameters params = emptyInputParameters();
      22    14464502 :   params.addClassDescription("Interface to handle the restriction of outputs from objects");
      23    28929004 :   params.addParam<std::vector<OutputName>>("outputs",
      24             :                                            "Vector of output names where you would like "
      25             :                                            "to restrict the output of variables(s) "
      26             :                                            "associated with this object");
      27             : 
      28    21696753 :   params.addParamNamesToGroup("outputs", "Advanced");
      29     7232251 :   std::set<std::string> reserved = {"all", "none"};
      30     7232251 :   params.setReservedValues("outputs", reserved);
      31             : 
      32    14464502 :   return params;
      33     7232251 : }
      34             : 
      35      362033 : OutputInterface::OutputInterface(const InputParameters & parameters, bool build_list)
      36      362033 :   : _oi_moose_app(*parameters.getCheckedPointerParam<MooseApp *>(MooseBase::app_param)),
      37      362033 :     _oi_output_warehouse(_oi_moose_app.getOutputWarehouse()),
      38      362033 :     _oi_outputs(parameters.get<std::vector<OutputName>>("outputs").begin(),
      39      362033 :                 parameters.get<std::vector<OutputName>>("outputs").end())
      40             : {
      41             : 
      42             :   // By default it is assumed that the variable name associated with 'outputs' is the name
      43             :   // of the block, this is the case for Markers, Indicators, VectorPostprocessors, and
      44             :   // Postprocessors.
      45             :   // However, for Materials this is not the case, so the call to buildOutputHideVariableList must be
      46             :   // disabled, the build_list allows for this behavior. The hide lists are handled by
      47             :   // MaterialOutputAction in this case.
      48             :   //
      49             :   // Variables/AuxVariables also call the buildOutputHideVariableList method later, because when
      50             :   // their actions are called the Output objects do not exist. This case is handled by the
      51             :   // CheckOutputAction::checkVariableOutput.
      52      362033 :   if (build_list)
      53             :   {
      54      256576 :     std::set<std::string> names_set;
      55      256576 :     names_set.insert(parameters.getObjectName());
      56      256576 :     buildOutputHideVariableList(names_set);
      57      256576 :   }
      58      362033 : }
      59             : 
      60             : void
      61      266250 : OutputInterface::buildOutputHideVariableList(std::set<std::string> variable_names)
      62             : {
      63             :   // Set of available names
      64      266250 :   const std::set<OutputName> & avail = _oi_output_warehouse.getOutputNames();
      65             : 
      66             :   // Check for 'none'; hide variables on all outputs
      67      266250 :   if (_oi_outputs.find("none") != _oi_outputs.end())
      68       43188 :     for (const auto & name : avail)
      69       36905 :       _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
      70             : 
      71             :   // Check for empty and 'all' in 'outputs' parameter; do not perform any variable restrictions in
      72             :   // these cases
      73      259967 :   else if (_oi_outputs.empty() || _oi_outputs.find("all") != _oi_outputs.end())
      74      255232 :     return;
      75             : 
      76             :   // Limit the variable output to Output objects listed
      77             :   else
      78             :   {
      79             :     // Create a list of outputs where the variable should be hidden
      80        4735 :     std::set<OutputName> hide;
      81        4735 :     std::set_difference(avail.begin(),
      82             :                         avail.end(),
      83             :                         _oi_outputs.begin(),
      84             :                         _oi_outputs.end(),
      85             :                         std::inserter(hide, hide.begin()));
      86             : 
      87             :     // If 'outputs' is specified add the object name to the list of items to hide
      88       23839 :     for (const auto & name : hide)
      89       19104 :       _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
      90        4735 :   }
      91             : }
      92             : 
      93             : const std::set<OutputName> &
      94      533079 : OutputInterface::getOutputs()
      95             : {
      96      533079 :   return _oi_outputs;
      97             : }

Generated by: LCOV version 1.14