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 : #include "THMSetupOutputAction.h" 11 : #include "MooseApp.h" 12 : #include "Factory.h" 13 : #include "THMProblem.h" 14 : #include "FlowModel.h" 15 : #include "Output.h" 16 : #include "Console.h" 17 : #include "XDA.h" 18 : #include "CSV.h" 19 : #include "Tecplot.h" 20 : #include "Exodus.h" 21 : #include "InputParameterWarehouse.h" 22 : 23 : registerMooseAction("ThermalHydraulicsApp", THMSetupOutputAction, "THM:setup_output"); 24 : 25 : InputParameters 26 5416 : THMSetupOutputAction::validParams() 27 : { 28 5416 : InputParameters params = Action::validParams(); 29 : 30 10832 : params.addParam<bool>("disable_scalars_in_console", 31 10832 : true, 32 : "Set to true to force 'execute_scalars_on = NONE' in Console, which " 33 : "disables printing of all scalar variables."); 34 : 35 5416 : params.addClassDescription("Sets up output for THM."); 36 : 37 5416 : return params; 38 0 : } 39 : 40 5416 : THMSetupOutputAction::THMSetupOutputAction(const InputParameters & params) : Action(params) {} 41 : 42 : void 43 5176 : THMSetupOutputAction::act() 44 : { 45 5176 : THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get()); 46 5176 : if (thm_problem) 47 : { 48 22150 : for (auto && o : _app.getOutputWarehouse().getOutputs<Output>()) 49 : { 50 : // Get a reference to the Output's InputParameters. We have to 51 : // get it from the InputParameter Warehouse since we are going to 52 : // modify it. Note that o->name() != "name" stored in the 53 : // object's InputParameters. We need the latter to get the 54 : // InputParameters out of the Warehouse. 55 : // InputParameters & params = 56 : // _app.getInputParameterWarehouse().getInputParameters(o->name(), /*tid=*/0); 57 : // 58 : // // If "hide" is available (AdvancedOutput) then add the hide_vars to it 59 : // if (params.have_parameter<std::vector<VariableName> >("hide")) 60 : // { 61 : // std::vector<VariableName> hvars = params.get<std::vector<VariableName> >("hide"); 62 : // hvars.insert(hvars.end(), hide_vars.begin(), hide_vars.end()); 63 : // params.set<std::vector<VariableName> >("hide") = hvars; 64 : // } 65 : 66 18421 : if (dynamic_cast<Console *>(o) != nullptr) 67 : { 68 7458 : if (getParam<bool>("disable_scalars_in_console")) 69 : { 70 : // Do not output scalar variables on the screen. 71 : // CAUTION: there is no public API in MOOSE to control what gets outputted by an ouputter, 72 : // so we get the input parameters after the object was created and flip the flag there. At 73 : // this point it is still early enough, so that MOOSE won't notice. 74 3721 : InputParameters & pars = const_cast<InputParameters &>(o->parameters()); 75 7442 : pars.set<ExecFlagEnum>("execute_scalars_on") = EXEC_NONE; 76 : } 77 : 78 3729 : thm_problem->addScreenOutputter(o->name()); 79 : } 80 29384 : else if (dynamic_cast<XDA *>(o) != nullptr || dynamic_cast<CSV *>(o) != nullptr || 81 27262 : dynamic_cast<Tecplot *>(o) != nullptr || dynamic_cast<Exodus *>(o) != nullptr) 82 : { 83 3640 : thm_problem->addFileOutputter(o->name()); 84 : } 85 : } 86 : } 87 5176 : }