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 7117023 : OutputInterface::validParams() 19 : { 20 : 21 7117023 : InputParameters params = emptyInputParameters(); 22 7117023 : params.addClassDescription("Interface to handle the restriction of outputs from objects"); 23 7117023 : 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 7117023 : params.addParamNamesToGroup("outputs", "Advanced"); 29 21351069 : std::set<std::string> reserved = {"all", "none"}; 30 7117023 : params.setReservedValues("outputs", reserved); 31 : 32 14234046 : return params; 33 21351069 : } 34 : 35 333240 : OutputInterface::OutputInterface(const InputParameters & parameters, bool build_list) 36 333240 : : _oi_moose_app(*parameters.getCheckedPointerParam<MooseApp *>("_moose_app")), 37 333240 : _oi_output_warehouse(_oi_moose_app.getOutputWarehouse()), 38 333240 : _oi_outputs(parameters.get<std::vector<OutputName>>("outputs").begin(), 39 333240 : 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 333240 : if (build_list) 53 : { 54 237122 : std::set<std::string> names_set; 55 237122 : names_set.insert(parameters.get<std::string>("_object_name")); 56 237122 : buildOutputHideVariableList(names_set); 57 237122 : } 58 333240 : } 59 : 60 : void 61 245818 : OutputInterface::buildOutputHideVariableList(std::set<std::string> variable_names) 62 : { 63 : // Set of available names 64 245818 : const std::set<OutputName> & avail = _oi_output_warehouse.getOutputNames(); 65 : 66 : // Check for 'none'; hide variables on all outputs 67 245818 : if (_oi_outputs.find("none") != _oi_outputs.end()) 68 40232 : for (const auto & name : avail) 69 34381 : _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 239967 : else if (_oi_outputs.empty() || _oi_outputs.find("all") != _oi_outputs.end()) 74 235327 : 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 4640 : std::set<OutputName> hide; 81 4640 : 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 23264 : for (const auto & name : hide) 89 18624 : _oi_output_warehouse.addInterfaceHideVariables(name, variable_names); 90 4640 : } 91 : } 92 : 93 : const std::set<OutputName> & 94 488104 : OutputInterface::getOutputs() 95 : { 96 488104 : return _oi_outputs; 97 : }