forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddTimeIndependentReactionSolverAction.C
140 lines (133 loc) · 6.73 KB
/
AddTimeIndependentReactionSolverAction.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#include "AddTimeIndependentReactionSolverAction.h"
#include "Executioner.h"
#include "FEProblem.h"
registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "setup_mesh");
registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "init_mesh");
registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "create_problem");
registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "setup_executioner");
registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "add_output");
registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "add_user_object");
registerMooseAction("GeochemistryApp",
AddTimeIndependentReactionSolverAction,
"add_geochemistry_molality_aux");
registerMooseAction("GeochemistryApp",
AddTimeIndependentReactionSolverAction,
"add_geochemistry_reactor");
InputParameters
AddTimeIndependentReactionSolverAction::validParams()
{
InputParameters params = AddGeochemistrySolverAction::validParams();
params.set<ExecFlagEnum>("execute_console_output_on") = EXEC_FINAL;
params.set<bool>("solver_info") = true;
params.addParam<Real>("temperature", 25.0, "The temperature (degC) of the aqueous solution");
params.addClassDescription(
"Action that sets up a time-dependent equilibrium reaction solver. This creates creates a "
"time-dependent geochemistry solver, and adds AuxVariables corresonding to the molalities, "
"etc");
return params;
}
AddTimeIndependentReactionSolverAction::AddTimeIndependentReactionSolverAction(
const InputParameters & params)
: AddGeochemistrySolverAction(params)
{
}
void
AddTimeIndependentReactionSolverAction::act()
{
// create Output and Aux objects
AddGeochemistrySolverAction::act();
// Set up an arbitrary mesh
if (_current_task == "setup_mesh")
{
const std::string class_name = "GeneratedMesh";
InputParameters params = _factory.getValidParams(class_name);
params.set<MooseEnum>("dim") = "1";
_mesh = _factory.create<MooseMesh>(class_name, "mesh", params);
}
// Initialize the arbitrary mesh
else if (_current_task == "init_mesh")
{
_mesh->init();
}
// Create a "solve=false" FEProblem, if appropriate
else if (_current_task == "create_problem")
{
const std::string class_name = "FEProblem";
InputParameters params = _factory.getValidParams(class_name);
params.set<MooseMesh *>("mesh") = _mesh.get();
params.set<bool>("use_nonlinear") = true;
params.set<bool>("solve") = getParam<bool>("include_moose_solve");
_problem = _factory.create<FEProblemBase>(class_name, "Problem", params);
_problem->setKernelCoverageCheck(getParam<bool>("include_moose_solve"));
}
// Set up an arbitrary steady executioner
else if (_current_task == "setup_executioner")
{
const std::string class_name = "Steady";
InputParameters params = _factory.getValidParams(class_name);
params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get();
std::shared_ptr<Executioner> executioner =
_factory.create<Executioner>(class_name, "Executioner", params);
_app.setExecutioner(std::move(executioner));
}
else if (_current_task == "add_geochemistry_reactor")
{
const std::string class_name = "GeochemistryTimeIndependentReactor";
auto params = _factory.getValidParams(class_name);
// Only pass parameters that were supplied to this action
if (isParamValid("block"))
params.set<std::vector<SubdomainName>>("block") =
getParam<std::vector<SubdomainName>>("block");
if (isParamValid("boundary"))
params.set<std::vector<BoundaryName>>("boundary") =
getParam<std::vector<BoundaryName>>("boundary");
params.set<UserObjectName>("model_definition") = getParam<UserObjectName>("model_definition");
if (isParamValid("swap_out_of_basis"))
params.set<std::vector<std::string>>("swap_out_of_basis") =
getParam<std::vector<std::string>>("swap_out_of_basis");
if (isParamValid("swap_into_basis"))
params.set<std::vector<std::string>>("swap_into_basis") =
getParam<std::vector<std::string>>("swap_into_basis");
params.set<MultiMooseEnum>("constraint_meaning") =
getParam<MultiMooseEnum>("constraint_meaning");
params.set<std::vector<std::string>>("constraint_species") =
getParam<std::vector<std::string>>("constraint_species");
params.set<std::vector<Real>>("constraint_value") =
getParam<std::vector<Real>>("constraint_value");
params.set<MultiMooseEnum>("constraint_unit") = getParam<MultiMooseEnum>("constraint_unit");
params.set<Real>("max_ionic_strength") = getParam<Real>("max_ionic_strength");
params.set<unsigned>("extra_iterations_to_make_consistent") =
getParam<unsigned>("extra_iterations_to_make_consistent");
params.set<Real>("stoichiometry_tolerance") = getParam<Real>("stoichiometry_tolerance");
params.set<std::string>("charge_balance_species") =
getParam<std::string>("charge_balance_species");
if (isParamValid("prevent_precipitation"))
params.set<std::vector<std::string>>("prevent_precipitation") =
getParam<std::vector<std::string>>("prevent_precipitation");
params.set<Real>("abs_tol") = getParam<Real>("abs_tol");
params.set<Real>("rel_tol") = getParam<Real>("rel_tol");
params.set<Real>("min_initial_molality") = getParam<Real>("min_initial_molality");
params.set<unsigned>("max_iter") = getParam<unsigned>("max_iter");
params.set<Real>("max_initial_residual") = getParam<Real>("max_initial_residual");
params.set<Real>("swap_threshold") = getParam<Real>("swap_threshold");
params.set<unsigned>("max_swaps_allowed") = getParam<unsigned>("max_swaps_allowed");
params.set<unsigned>("ramp_max_ionic_strength_initial") =
getParam<unsigned>("ramp_max_ionic_strength_initial");
params.set<bool>("ionic_str_using_basis_only") = getParam<bool>("ionic_str_using_basis_only");
params.set<bool>("stoichiometric_ionic_str_using_Cl_only") =
getParam<bool>("stoichiometric_ionic_str_using_Cl_only");
params.set<Real>("temperature") = getParam<Real>("temperature");
params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL};
_problem->addUserObject(
class_name, getParam<UserObjectName>("geochemistry_reactor_name"), params);
}
}