https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AddGeochemicalModelInterrogatorAction.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
12#include "Executioner.h"
13#include "FEProblem.h"
14
17registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "create_problem");
18registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "setup_executioner");
20
23{
26 params.addClassDescription("Action that sets up the geochemical model interrogator");
27
28 return params;
29}
30
36
37void
39{
40 // Set up an arbitrary mesh
41 if (_current_task == "setup_mesh")
42 {
43 const std::string class_name = "GeneratedMesh";
44 InputParameters params = _factory.getValidParams(class_name);
45 params.set<MooseEnum>("dim") = "1";
46 _mesh = _factory.create<MooseMesh>(class_name, "mesh", params);
47 }
48 // Initialize the arbitrary mesh
49 else if (_current_task == "init_mesh")
50 {
51 _mesh->init();
52 }
53 // Create a "solve=false" FEProblem
54 else if (_current_task == "create_problem")
55 {
56 const std::string class_name = "FEProblem";
57 InputParameters params = _factory.getValidParams(class_name);
58 params.set<MooseMesh *>("mesh") = _mesh.get();
59 params.set<bool>("use_nonlinear") = true;
60 params.set<bool>("solve") = false;
61 _problem = _factory.create<FEProblemBase>(class_name, "Problem", params);
62 _problem->setKernelCoverageCheck(FEProblemBase::CoverageCheckMode::FALSE);
63 }
64 // Set up an arbitrary steady executioner
65 else if (_current_task == "setup_executioner")
66 {
67 const std::string class_name = "Steady";
68 InputParameters params = _factory.getValidParams(class_name);
69 params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
70 params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get();
71 std::shared_ptr<Executioner> executioner =
72 _factory.create<Executioner>(class_name, "Executioner", params);
73 _app.setExecutioner(std::move(executioner));
74 }
75 // Create a console that executes only on FINAL and does not print system info
76 else if (_current_task == "add_output")
77 {
78 const std::string class_name = "GeochemicalModelInterrogator";
79 auto params = _factory.getValidParams(class_name);
80 params.set<UserObjectName>("model_definition") = getParam<UserObjectName>("model_definition");
81 // Only pass parameters that were supplied to this action
82 if (isParamValid("swap_out_of_basis"))
83 params.set<std::vector<std::string>>("swap_out_of_basis") =
84 getParam<std::vector<std::string>>("swap_out_of_basis");
85 if (isParamValid("swap_into_basis"))
86 params.set<std::vector<std::string>>("swap_into_basis") =
87 getParam<std::vector<std::string>>("swap_into_basis");
88 if (isParamValid("activity_species"))
89 params.set<std::vector<std::string>>("activity_species") =
90 getParam<std::vector<std::string>>("activity_species");
91 if (isParamValid("activity_values"))
92 params.set<std::vector<Real>>("activity_values") =
93 getParam<std::vector<Real>>("activity_values");
94 params.set<unsigned int>("precision") = getParam<unsigned int>("precision");
95 params.set<std::string>("equilibrium_species") = getParam<std::string>("equilibrium_species");
96 params.set<MooseEnum>("interrogation") = getParam<MooseEnum>("interrogation");
97 params.set<Real>("temperature") = getParam<Real>("temperature");
98 params.set<Real>("stoichiometry_tolerance") = getParam<Real>("stoichiometry_tolerance");
99 _problem->addOutput(class_name, "geochemical_model_interrogator", params);
100 }
101}
registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "setup_mesh")
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 geochemical model interrogator.
AddGeochemicalModelInterrogatorAction(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
static InputParameters sharedParams()
params that are shared with the AddGeochemicalModelInterrogatorAction
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void setExecutioner(std::shared_ptr< Executioner > &&executioner)
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
Factory & _factory