https://mooseframework.inl.gov
THMSetupOutputAction.C
Go to the documentation of this file.
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"
22 
23 registerMooseAction("ThermalHydraulicsApp", THMSetupOutputAction, "THM:setup_output");
24 
27 {
29 
30  params.addParam<bool>("disable_scalars_in_console",
31  true,
32  "Set to true to force 'execute_scalars_on = NONE' in Console, which "
33  "disables printing of all scalar variables.");
34 
35  params.addClassDescription("Sets up output for THM.");
36 
37  return params;
38 }
39 
41 
42 void
44 {
45  THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get());
46  if (thm_problem)
47  {
48  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  if (dynamic_cast<Console *>(o) != nullptr)
67  {
68  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  InputParameters & pars = const_cast<InputParameters &>(o->parameters());
75  pars.set<ExecFlagEnum>("execute_scalars_on") = EXEC_NONE;
76  }
77 
78  thm_problem->addScreenOutputter(o->name());
79  }
80  else if (dynamic_cast<XDA *>(o) != nullptr || dynamic_cast<CSV *>(o) != nullptr ||
81  dynamic_cast<Tecplot *>(o) != nullptr || dynamic_cast<Exodus *>(o) != nullptr)
82  {
83  thm_problem->addFileOutputter(o->name());
84  }
85  }
86  }
87 }
Specialization of FEProblem to run with component subsystem.
Definition: THMProblem.h:18
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const ExecFlagType EXEC_NONE
MooseApp & _app
T & set(const std::string &name, bool quiet_mode=false)
std::vector< T *> getOutputs(const std::vector< OutputName > &names)
void addFileOutputter(const std::string &name)
Definition: Simulation.C:1035
static InputParameters validParams()
static InputParameters validParams()
THMSetupOutputAction(const InputParameters &params)
registerMooseAction("ThermalHydraulicsApp", THMSetupOutputAction, "THM:setup_output")
void addScreenOutputter(const std::string &name)
Definition: Simulation.C:1042
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
OutputWarehouse & getOutputWarehouse()