Line data Source code
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 "AddTimeIndependentReactionSolverAction.h" 11 : #include "Executioner.h" 12 : #include "FEProblem.h" 13 : 14 : registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "setup_mesh"); 15 : registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "init_mesh"); 16 : registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "create_problem"); 17 : registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "setup_executioner"); 18 : registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "add_output"); 19 : registerMooseAction("GeochemistryApp", AddTimeIndependentReactionSolverAction, "add_user_object"); 20 : registerMooseAction("GeochemistryApp", 21 : AddTimeIndependentReactionSolverAction, 22 : "add_geochemistry_molality_aux"); 23 : registerMooseAction("GeochemistryApp", 24 : AddTimeIndependentReactionSolverAction, 25 : "add_geochemistry_reactor"); 26 : 27 : InputParameters 28 293 : AddTimeIndependentReactionSolverAction::validParams() 29 : { 30 293 : InputParameters params = AddGeochemistrySolverAction::validParams(); 31 293 : params.set<ExecFlagEnum>("execute_console_output_on") = EXEC_FINAL; 32 293 : params.set<bool>("solver_info") = true; 33 586 : params.addParam<Real>("temperature", 25.0, "The temperature (degC) of the aqueous solution"); 34 293 : params.addClassDescription( 35 : "Action that sets up a time-dependent equilibrium reaction solver. This creates creates a " 36 : "time-dependent geochemistry solver, and adds AuxVariables corresonding to the molalities, " 37 : "etc"); 38 : 39 293 : return params; 40 0 : } 41 : 42 293 : AddTimeIndependentReactionSolverAction::AddTimeIndependentReactionSolverAction( 43 293 : const InputParameters & params) 44 293 : : AddGeochemistrySolverAction(params) 45 : { 46 293 : } 47 : 48 : void 49 2344 : AddTimeIndependentReactionSolverAction::act() 50 : { 51 : // create Output and Aux objects 52 2344 : AddGeochemistrySolverAction::act(); 53 : 54 : // Set up an arbitrary mesh 55 2344 : if (_current_task == "setup_mesh") 56 : { 57 293 : const std::string class_name = "GeneratedMesh"; 58 293 : InputParameters params = _factory.getValidParams(class_name); 59 586 : params.set<MooseEnum>("dim") = "1"; 60 293 : _mesh = _factory.create<MooseMesh>(class_name, "mesh", params); 61 293 : } 62 : // Initialize the arbitrary mesh 63 2051 : else if (_current_task == "init_mesh") 64 : { 65 293 : _mesh->init(); 66 : } 67 : // Create a "solve=false" FEProblem, if appropriate 68 1758 : else if (_current_task == "create_problem") 69 : { 70 293 : const std::string class_name = "FEProblem"; 71 293 : InputParameters params = _factory.getValidParams(class_name); 72 293 : params.set<MooseMesh *>("mesh") = _mesh.get(); 73 293 : params.set<bool>("use_nonlinear") = true; 74 586 : params.set<bool>("solve") = getParam<bool>("include_moose_solve"); 75 293 : _problem = _factory.create<FEProblemBase>(class_name, "Problem", params); 76 586 : _problem->setKernelCoverageCheck(getParam<bool>("include_moose_solve") 77 : ? FEProblemBase::CoverageCheckMode::TRUE 78 : : FEProblemBase::CoverageCheckMode::FALSE); 79 293 : } 80 : // Set up an arbitrary steady executioner 81 1465 : else if (_current_task == "setup_executioner") 82 : { 83 293 : const std::string class_name = "Steady"; 84 293 : InputParameters params = _factory.getValidParams(class_name); 85 293 : params.set<FEProblemBase *>("_fe_problem_base") = _problem.get(); 86 293 : params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get(); 87 : std::shared_ptr<Executioner> executioner = 88 293 : _factory.create<Executioner>(class_name, "Executioner", params); 89 293 : _app.setExecutioner(std::move(executioner)); 90 293 : } 91 1172 : else if (_current_task == "add_geochemistry_reactor") 92 : { 93 293 : const std::string class_name = "GeochemistryTimeIndependentReactor"; 94 293 : auto params = _factory.getValidParams(class_name); 95 : // Only pass parameters that were supplied to this action 96 586 : if (isParamValid("block")) 97 0 : params.set<std::vector<SubdomainName>>("block") = 98 0 : getParam<std::vector<SubdomainName>>("block"); 99 586 : if (isParamValid("boundary")) 100 0 : params.set<std::vector<BoundaryName>>("boundary") = 101 0 : getParam<std::vector<BoundaryName>>("boundary"); 102 879 : params.set<UserObjectName>("model_definition") = getParam<UserObjectName>("model_definition"); 103 586 : if (isParamValid("swap_out_of_basis")) 104 586 : params.set<std::vector<std::string>>("swap_out_of_basis") = 105 879 : getParam<std::vector<std::string>>("swap_out_of_basis"); 106 586 : if (isParamValid("swap_into_basis")) 107 586 : params.set<std::vector<std::string>>("swap_into_basis") = 108 879 : getParam<std::vector<std::string>>("swap_into_basis"); 109 586 : params.set<MultiMooseEnum>("constraint_meaning") = 110 586 : getParam<MultiMooseEnum>("constraint_meaning"); 111 586 : params.set<std::vector<std::string>>("constraint_species") = 112 586 : getParam<std::vector<std::string>>("constraint_species"); 113 586 : params.set<std::vector<Real>>("constraint_value") = 114 586 : getParam<std::vector<Real>>("constraint_value"); 115 879 : params.set<MultiMooseEnum>("constraint_unit") = getParam<MultiMooseEnum>("constraint_unit"); 116 586 : params.set<Real>("max_ionic_strength") = getParam<Real>("max_ionic_strength"); 117 293 : params.set<unsigned>("extra_iterations_to_make_consistent") = 118 586 : getParam<unsigned>("extra_iterations_to_make_consistent"); 119 586 : params.set<Real>("stoichiometry_tolerance") = getParam<Real>("stoichiometry_tolerance"); 120 586 : params.set<std::string>("charge_balance_species") = 121 293 : getParam<std::string>("charge_balance_species"); 122 586 : if (isParamValid("prevent_precipitation")) 123 586 : params.set<std::vector<std::string>>("prevent_precipitation") = 124 879 : getParam<std::vector<std::string>>("prevent_precipitation"); 125 586 : params.set<Real>("abs_tol") = getParam<Real>("abs_tol"); 126 586 : params.set<Real>("rel_tol") = getParam<Real>("rel_tol"); 127 586 : params.set<Real>("min_initial_molality") = getParam<Real>("min_initial_molality"); 128 586 : params.set<unsigned>("max_iter") = getParam<unsigned>("max_iter"); 129 586 : params.set<Real>("max_initial_residual") = getParam<Real>("max_initial_residual"); 130 586 : params.set<Real>("swap_threshold") = getParam<Real>("swap_threshold"); 131 586 : params.set<unsigned>("max_swaps_allowed") = getParam<unsigned>("max_swaps_allowed"); 132 293 : params.set<unsigned>("ramp_max_ionic_strength_initial") = 133 586 : getParam<unsigned>("ramp_max_ionic_strength_initial"); 134 586 : params.set<bool>("ionic_str_using_basis_only") = getParam<bool>("ionic_str_using_basis_only"); 135 293 : params.set<bool>("stoichiometric_ionic_str_using_Cl_only") = 136 586 : getParam<bool>("stoichiometric_ionic_str_using_Cl_only"); 137 586 : params.set<Real>("temperature") = getParam<Real>("temperature"); 138 879 : params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL}; 139 586 : _problem->addUserObject( 140 293 : class_name, getParam<UserObjectName>("geochemistry_reactor_name"), params); 141 293 : } 142 2637 : }