https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AddFluidPropertiesInterrogatorAction.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
11#include "Executioner.h"
12#include "FEProblem.h"
13
14registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "setup_mesh");
16registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "create_problem");
17registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "add_user_object");
18registerMooseAction("FluidPropertiesApp",
20 "setup_executioner");
21registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "add_fp_output");
22registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "common_output");
23registerMooseAction("FluidPropertiesApp",
25 "add_output_aux_variables");
26
29{
31 params.addRequiredParam<UserObjectName>("fp",
32 "The name of the fluid properties object to query.");
33 params.addParam<Real>("rho", "Density");
34 params.addParam<Real>("rhou", "Momentum density; rho * u");
35 params.addParam<Real>("rhoE", "Total energy density: rho * E");
36 params.addParam<Real>("e", "Specific internal energy");
37 params.addParam<Real>("p", "Pressure");
38 params.addParam<Real>("T", "Temperature");
39 params.addParam<Real>("vel", "Velocity");
40 params.addParam<std::vector<Real>>("x_ncg", "Mass fractions of NCGs");
41 params.addParam<unsigned int>("precision", 10, "Precision for printing values");
42 params.addParam<bool>("json", false, "Output in JSON format");
43
44 params.addClassDescription("Action that sets up the fluid properties interrogator");
45
46 return params;
47}
48
50 const InputParameters & params)
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());
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 pars.addParam<bool>("print_linear_residuals", false, "(Does not need to be set)");
63}
64
65void
67{
68 // Set up an arbitrary mesh
69 if (_current_task == "setup_mesh")
70 {
71 const std::string class_name = "GeneratedMesh";
72 InputParameters params = _factory.getValidParams(class_name);
73 params.set<MooseEnum>("dim") = "1";
74 _mesh = _factory.create<MooseMesh>(class_name, "mesh", params);
75 }
76 // Initialize the arbitrary mesh
77 else if (_current_task == "init_mesh")
78 {
79 _mesh->init();
80 }
81 // Create a "solve=false" FEProblem
82 else if (_current_task == "create_problem")
83 {
84 const std::string class_name = "FEProblem";
85 InputParameters params = _factory.getValidParams(class_name);
86 params.set<MooseMesh *>("mesh") = _mesh.get();
87 params.set<bool>("use_nonlinear") = true;
88 params.set<bool>("solve") = false;
89 _problem = _factory.create<FEProblemBase>(class_name, "Problem", params);
90 _problem->setKernelCoverageCheck(FEProblemBase::CoverageCheckMode::FALSE);
91 }
92 // Add the fluid properties interrogator user object
93 else if (_current_task == "add_user_object")
94 {
96 }
97 // Set up an arbitrary steady executioner
98 else if (_current_task == "setup_executioner")
99 {
100 const std::string class_name = "Steady";
101 InputParameters params = _factory.getValidParams(class_name);
102 params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
103 params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get();
104 std::shared_ptr<Executioner> executioner =
105 _factory.create<Executioner>(class_name, "Executioner", params);
106 _app.setExecutioner(std::move(executioner));
107 }
108 // Create a console that executes only on FINAL and does not print system info
109 else if (_current_task == "add_fp_output")
110 {
111 OutputWarehouse & output_warehouse = _app.getOutputWarehouse();
112 if (!output_warehouse.hasOutput("console"))
113 {
114 const std::string class_name = "Console";
115 InputParameters params = _factory.getValidParams(class_name);
116 params.addPrivateParam<FEProblemBase *>("_fe_problem_base", _problem.get());
117 params.set<std::string>("file_base") = _app.getOutputFileBase();
118 params.set<ExecFlagEnum>("execute_on") = EXEC_FINAL;
119 params.set<MultiMooseEnum>("system_info") = "";
120 std::shared_ptr<Output> output = _factory.create<Output>(class_name, "Console", params);
121 output_warehouse.addOutput(output);
122 }
123 }
124 else if (_current_task == "common_output")
125 {
126 // This action must satisfy this task to prevent CommonOutputAction from
127 // acting, which performs a static cast that assumes that the action
128 // satisfying the task "add_output" is derived from MooseObjectAction,
129 // which is now false.
130 }
131 else if (_current_task == "add_output_aux_variables")
132 {
133 // This action must satisfy this task to prevent MaterialOutputAction from
134 // acting, which assumes that the action satisfying "add_output" can be
135 // dynamic_cast-ed to type "AddOutputAction", which is now false.
136 }
137}
138
139void
141{
142 const std::string class_name = "FluidPropertiesInterrogator";
143 InputParameters params = _factory.getValidParams(class_name);
144 params.set<UserObjectName>("fp") = getParam<UserObjectName>("fp");
145 // Only pass parameters that were supplied to this action
146 if (isParamValid("rho"))
147 params.set<Real>("rho") = getParam<Real>("rho");
148 if (isParamValid("rhou"))
149 params.set<Real>("rhou") = getParam<Real>("rhou");
150 if (isParamValid("rhoE"))
151 params.set<Real>("rhoE") = getParam<Real>("rhoE");
152 if (isParamValid("e"))
153 params.set<Real>("e") = getParam<Real>("e");
154 if (isParamValid("p"))
155 params.set<Real>("p") = getParam<Real>("p");
156 if (isParamValid("T"))
157 params.set<Real>("T") = getParam<Real>("T");
158 if (isParamValid("vel"))
159 params.set<Real>("vel") = getParam<Real>("vel");
160 if (isParamValid("x_ncg"))
161 params.set<std::vector<Real>>("x_ncg") = getParam<std::vector<Real>>("x_ncg");
162 params.set<unsigned int>("precision") = getParam<unsigned int>("precision");
163 params.set<bool>("json") = getParam<bool>("json");
164 _problem->addUserObject(class_name, "fp_interrogator", params);
165}
registerMooseAction("FluidPropertiesApp", AddFluidPropertiesInterrogatorAction, "setup_mesh")
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_FINAL
std::shared_ptr< MooseMesh > & _mesh
static InputParameters validParams()
MooseApp & _app
std::shared_ptr< FEProblemBase > & _problem
const std::string & _current_task
Action that sets up the fluid properties interrogator.
void addFluidPropertiesInterrogatorObject() const
Adds the FluidPropertiesInterrogator user object.
AddFluidPropertiesInterrogatorAction(const InputParameters &parameters)
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters &parameters, THREAD_ID tid=0, bool print_deprecated=true)
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addPrivateParam(const std::string &name, const T &value)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void setExecutioner(std::shared_ptr< Executioner > &&executioner)
std::string getOutputFileBase(bool for_non_moose_build_output=false) const
OutputWarehouse & getOutputWarehouse()
const InputParameters & parameters() const
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
bool hasOutput(const std::string &name) const
void addOutput(std::shared_ptr< Output > output)
static ExecFlagEnum getDefaultExecFlagEnum()
Factory & _factory