www.mooseframework.org
AddFluidPropertiesInterrogatorAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 #include "Executioner.h"
12 #include "FEProblem.h"
13 
14 registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "setup_mesh");
15 registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "init_mesh");
16 registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "create_problem");
17 registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "add_user_object");
18 registerMooseAction("FluidPropertiesApp",
20  "setup_executioner");
21 registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "add_output");
22 registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "common_output");
23 registerMooseAction("FluidPropertiesApp",
25  "add_output_aux_variables");
26 
27 template <>
28 InputParameters
30 {
31  InputParameters params = validParams<Action>();
32  params.addRequiredParam<UserObjectName>("fp",
33  "The name of the fluid properties object to query.");
34  params.addParam<Real>("rho", "Density");
35  params.addParam<Real>("rhou", "Momentum density; rho * u");
36  params.addParam<Real>("rhoE", "Total energy density: rho * E");
37  params.addParam<Real>("e", "Specific internal energy");
38  params.addParam<Real>("p", "Pressure");
39  params.addParam<Real>("T", "Temperature");
40  params.addParam<Real>("vel", "Velocity");
41  params.addParam<std::vector<Real>>("x_ncg", "Mass fractions of NCGs");
42  params.addParam<unsigned int>("precision", 10, "Precision for printing values");
43  params.addParam<bool>("json", false, "Output in JSON format");
44 
45  params.addClassDescription("Action that sets up the fluid properties interrogator");
46 
47  return params;
48 }
49 
51  : Action(params)
52 {
53  // Currently these parameters are required by the constructor of Console, which
54  // assumes that the action satisfying task "add_output" has these parameters.
55  // However, these parameters are not meant to be seen by the user, so they
56  // are added here, instead of in validParams(), with the help of const_cast.
57  InputParameters & pars = const_cast<InputParameters &>(parameters());
58  ExecFlagEnum exec_enum = Output::getDefaultExecFlagEnum();
59  exec_enum = {EXEC_INITIAL, EXEC_TIMESTEP_END};
60  pars.addParam<ExecFlagEnum>("execute_on", exec_enum, "(Does not need to be set)");
61  pars.addParam<bool>("print_perf_log", false, "(Does not need to be set)");
62 }
63 
64 void
66 {
67  // Set up an arbitrary mesh
68  if (_current_task == "setup_mesh")
69  {
70  const std::string class_name = "GeneratedMesh";
71  InputParameters params = _factory.getValidParams(class_name);
72  params.set<MooseEnum>("dim") = "1";
73  _mesh = _factory.create<MooseMesh>(class_name, "mesh", params);
74  }
75  // Initialize the arbitrary mesh
76  else if (_current_task == "init_mesh")
77  {
78  _mesh->init();
79  }
80  // Create a "solve=false" FEProblem
81  else if (_current_task == "create_problem")
82  {
83  const std::string class_name = "FEProblem";
84  InputParameters params = _factory.getValidParams(class_name);
85  params.set<MooseMesh *>("mesh") = _mesh.get();
86  params.set<bool>("use_nonlinear") = true;
87  params.set<bool>("solve") = false;
88  _problem = _factory.create<FEProblemBase>(class_name, "Problem", params);
89  _problem->setKernelCoverageCheck(false);
90  }
91  // Add the fluid properties interrogator user object
92  else if (_current_task == "add_user_object")
93  {
95  }
96  // Set up an arbitrary steady executioner
97  else if (_current_task == "setup_executioner")
98  {
99  const std::string class_name = "Steady";
100  InputParameters params = _factory.getValidParams(class_name);
101  params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
102  params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get();
103  std::shared_ptr<Executioner> executioner =
104  _factory.create<Executioner>(class_name, "Executioner", params);
105  _app.setExecutioner(std::move(executioner));
106  }
107  // Create a console that executes only on FINAL and does not print system info
108  else if (_current_task == "add_output")
109  {
110  const std::string class_name = "Console";
111  InputParameters params = _factory.getValidParams(class_name);
112  params.addPrivateParam<FEProblemBase *>("_fe_problem_base", _problem.get());
113  params.set<std::string>("file_base") = _app.getOutputFileBase();
114  params.set<ExecFlagEnum>("execute_on") = EXEC_FINAL;
115  params.set<MultiMooseEnum>("system_info") = "";
116  std::shared_ptr<Output> output = _factory.create<Output>(class_name, "Console", params);
117  OutputWarehouse & output_warehouse = _app.getOutputWarehouse();
118  output_warehouse.addOutput(output);
119  }
120  else if (_current_task == "common_output")
121  {
122  // This action must satisfy this task to prevent CommonOutputAction from
123  // acting, which performs a static cast that assumes that the action
124  // satisfying the task "add_output" is derived from MooseObjectAction,
125  // which is now false.
126  }
127  else if (_current_task == "add_output_aux_variables")
128  {
129  // This action must satisfy this task to prevent MaterialOutputAction from
130  // acting, which assumes that the action satisfying "add_output" can be
131  // dynamic_cast-ed to type "AddOutputAction", which is now false.
132  }
133 }
134 
135 void
137 {
138  const std::string class_name = "FluidPropertiesInterrogator";
139  InputParameters params = _factory.getValidParams(class_name);
140  params.set<UserObjectName>("fp") = getParam<UserObjectName>("fp");
141  // Only pass parameters that were supplied to this action
142  if (isParamValid("rho"))
143  params.set<Real>("rho") = getParam<Real>("rho");
144  if (isParamValid("rhou"))
145  params.set<Real>("rhou") = getParam<Real>("rhou");
146  if (isParamValid("rhoE"))
147  params.set<Real>("rhoE") = getParam<Real>("rhoE");
148  if (isParamValid("e"))
149  params.set<Real>("e") = getParam<Real>("e");
150  if (isParamValid("p"))
151  params.set<Real>("p") = getParam<Real>("p");
152  if (isParamValid("T"))
153  params.set<Real>("T") = getParam<Real>("T");
154  if (isParamValid("vel"))
155  params.set<Real>("vel") = getParam<Real>("vel");
156  if (isParamValid("x_ncg"))
157  params.set<std::vector<Real>>("x_ncg") = getParam<std::vector<Real>>("x_ncg");
158  params.set<unsigned int>("precision") = getParam<unsigned int>("precision");
159  params.set<bool>("json") = getParam<bool>("json");
160  _problem->addUserObject(class_name, "fp_interrogator", params);
161 }
AddFluidPropertiesInterrogatorAction
Action that sets up the fluid properties interrogator.
Definition: AddFluidPropertiesInterrogatorAction.h:22
validParams< AddFluidPropertiesInterrogatorAction >
InputParameters validParams< AddFluidPropertiesInterrogatorAction >()
Definition: AddFluidPropertiesInterrogatorAction.C:29
AddFluidPropertiesInterrogatorAction::act
virtual void act() override
Definition: AddFluidPropertiesInterrogatorAction.C:65
AddFluidPropertiesInterrogatorAction.h
AddFluidPropertiesInterrogatorAction::addFluidPropertiesInterrogatorObject
void addFluidPropertiesInterrogatorObject() const
Adds the FluidPropertiesInterrogator user object.
Definition: AddFluidPropertiesInterrogatorAction.C:136
AddFluidPropertiesInterrogatorAction::AddFluidPropertiesInterrogatorAction
AddFluidPropertiesInterrogatorAction(InputParameters parameters)
Definition: AddFluidPropertiesInterrogatorAction.C:50
registerMooseAction
registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "setup_mesh")