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

Generated by: LCOV version 1.14