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 "AddTimeDependentReactionSolverAction.h" 11 : #include "GeochemistryTimeDependentReactor.h" 12 : #include "FEProblem.h" 13 : 14 : registerMooseAction("GeochemistryApp", AddTimeDependentReactionSolverAction, "setup_mesh"); 15 : registerMooseAction("GeochemistryApp", AddTimeDependentReactionSolverAction, "init_mesh"); 16 : registerMooseAction("GeochemistryApp", AddTimeDependentReactionSolverAction, "create_problem"); 17 : registerMooseAction("GeochemistryApp", AddTimeDependentReactionSolverAction, "add_output"); 18 : registerMooseAction("GeochemistryApp", AddTimeDependentReactionSolverAction, "add_user_object"); 19 : registerMooseAction("GeochemistryApp", 20 : AddTimeDependentReactionSolverAction, 21 : "add_geochemistry_molality_aux"); 22 : registerMooseAction("GeochemistryApp", 23 : AddTimeDependentReactionSolverAction, 24 : "add_geochemistry_reactor"); 25 : 26 : InputParameters 27 222 : AddTimeDependentReactionSolverAction::validParams() 28 : { 29 222 : InputParameters params = AddGeochemistrySolverAction::validParams(); 30 222 : params += GeochemistryTimeDependentReactor::sharedParams(); 31 222 : params.addClassDescription( 32 : "Action that sets up a time-dependent equilibrium reaction solver. This creates creates a " 33 : "time-dependent geochemistry solver, and adds AuxVariables corresonding to the molalities, " 34 : "etc"); 35 : 36 222 : return params; 37 0 : } 38 : 39 222 : AddTimeDependentReactionSolverAction::AddTimeDependentReactionSolverAction( 40 222 : const InputParameters & params) 41 222 : : AddGeochemistrySolverAction(params) 42 : { 43 222 : } 44 : 45 : void 46 1530 : AddTimeDependentReactionSolverAction::act() 47 : { 48 : // create Output and Aux objects 49 1530 : AddGeochemistrySolverAction::act(); 50 : 51 : // Set up an arbitrary mesh 52 1530 : if (_current_task == "setup_mesh") 53 : { 54 222 : const std::string class_name = "GeneratedMesh"; 55 222 : InputParameters params = _factory.getValidParams(class_name); 56 444 : params.set<MooseEnum>("dim") = "1"; 57 222 : _mesh = _factory.create<MooseMesh>(class_name, "mesh", params); 58 222 : } 59 : // Initialize the arbitrary mesh 60 1308 : else if (_current_task == "init_mesh") 61 : { 62 222 : _mesh->init(); 63 : } 64 : // Create a "solve=false" FEProblem, if appropriate 65 1086 : else if (_current_task == "create_problem") 66 : { 67 222 : const std::string class_name = "FEProblem"; 68 222 : InputParameters params = _factory.getValidParams(class_name); 69 222 : params.set<MooseMesh *>("mesh") = _mesh.get(); 70 222 : params.set<bool>("use_nonlinear") = true; 71 444 : params.set<bool>("solve") = getParam<bool>("include_moose_solve"); 72 222 : _problem = _factory.create<FEProblemBase>(class_name, "Problem", params); 73 444 : _problem->setKernelCoverageCheck(getParam<bool>("include_moose_solve") 74 : ? FEProblemBase::CoverageCheckMode::TRUE 75 : : FEProblemBase::CoverageCheckMode::FALSE); 76 222 : } 77 864 : else if (_current_task == "add_geochemistry_reactor") 78 : { 79 222 : const std::string class_name = "GeochemistryTimeDependentReactor"; 80 222 : auto params = _factory.getValidParams(class_name); 81 : // Only pass parameters that were supplied to this action 82 444 : if (isParamValid("block")) 83 0 : params.set<std::vector<SubdomainName>>("block") = 84 0 : getParam<std::vector<SubdomainName>>("block"); 85 444 : if (isParamValid("boundary")) 86 0 : params.set<std::vector<BoundaryName>>("boundary") = 87 0 : getParam<std::vector<BoundaryName>>("boundary"); 88 666 : params.set<UserObjectName>("model_definition") = getParam<UserObjectName>("model_definition"); 89 444 : if (isParamValid("swap_out_of_basis")) 90 444 : params.set<std::vector<std::string>>("swap_out_of_basis") = 91 666 : getParam<std::vector<std::string>>("swap_out_of_basis"); 92 444 : if (isParamValid("swap_into_basis")) 93 444 : params.set<std::vector<std::string>>("swap_into_basis") = 94 666 : getParam<std::vector<std::string>>("swap_into_basis"); 95 444 : params.set<MultiMooseEnum>("constraint_meaning") = 96 444 : getParam<MultiMooseEnum>("constraint_meaning"); 97 444 : params.set<std::vector<std::string>>("constraint_species") = 98 444 : getParam<std::vector<std::string>>("constraint_species"); 99 444 : params.set<std::vector<Real>>("constraint_value") = 100 444 : getParam<std::vector<Real>>("constraint_value"); 101 666 : params.set<MultiMooseEnum>("constraint_unit") = getParam<MultiMooseEnum>("constraint_unit"); 102 444 : params.set<Real>("max_ionic_strength") = getParam<Real>("max_ionic_strength"); 103 222 : params.set<unsigned>("extra_iterations_to_make_consistent") = 104 444 : getParam<unsigned>("extra_iterations_to_make_consistent"); 105 444 : params.applySpecificParameters(parameters(), {"temperature"}); 106 444 : params.applySpecificParameters(parameters(), {"cold_temperature"}); 107 222 : params.set<unsigned>("heating_increments") = getParam<unsigned>("heating_increments"); 108 444 : params.set<Real>("stoichiometry_tolerance") = getParam<Real>("stoichiometry_tolerance"); 109 444 : params.set<std::string>("charge_balance_species") = 110 222 : getParam<std::string>("charge_balance_species"); 111 444 : if (isParamValid("prevent_precipitation")) 112 444 : params.set<std::vector<std::string>>("prevent_precipitation") = 113 666 : getParam<std::vector<std::string>>("prevent_precipitation"); 114 444 : params.set<Real>("abs_tol") = getParam<Real>("abs_tol"); 115 444 : params.set<Real>("rel_tol") = getParam<Real>("rel_tol"); 116 444 : params.set<Real>("min_initial_molality") = getParam<Real>("min_initial_molality"); 117 444 : params.set<unsigned>("max_iter") = getParam<unsigned>("max_iter"); 118 444 : params.set<Real>("max_initial_residual") = getParam<Real>("max_initial_residual"); 119 444 : params.set<Real>("swap_threshold") = getParam<Real>("swap_threshold"); 120 444 : params.set<unsigned>("max_swaps_allowed") = getParam<unsigned>("max_swaps_allowed"); 121 222 : params.set<unsigned>("ramp_max_ionic_strength_initial") = 122 444 : getParam<unsigned>("ramp_max_ionic_strength_initial"); 123 222 : params.set<unsigned>("ramp_max_ionic_strength_subsequent") = 124 444 : getParam<unsigned>("ramp_max_ionic_strength_subsequent"); 125 444 : params.set<bool>("ionic_str_using_basis_only") = getParam<bool>("ionic_str_using_basis_only"); 126 222 : params.set<bool>("stoichiometric_ionic_str_using_Cl_only") = 127 444 : getParam<bool>("stoichiometric_ionic_str_using_Cl_only"); 128 444 : params.set<Real>("close_system_at_time") = getParam<Real>("close_system_at_time"); 129 444 : if (isParamValid("remove_fixed_activity_name")) 130 444 : params.set<std::vector<std::string>>("remove_fixed_activity_name") = 131 666 : getParam<std::vector<std::string>>("remove_fixed_activity_name"); 132 444 : if (isParamValid("remove_fixed_activity_time")) 133 444 : params.set<std::vector<Real>>("remove_fixed_activity_time") = 134 666 : getParam<std::vector<Real>>("remove_fixed_activity_time"); 135 444 : if (isParamValid("source_species_names")) 136 444 : params.set<std::vector<std::string>>("source_species_names") = 137 666 : getParam<std::vector<std::string>>("source_species_names"); 138 444 : if (isParamValid("source_species_rates")) 139 168 : params.applySpecificParameters(parameters(), {"source_species_rates"}); 140 444 : if (isParamValid("controlled_activity_name")) 141 444 : params.set<std::vector<std::string>>("controlled_activity_name") = 142 666 : getParam<std::vector<std::string>>("controlled_activity_name"); 143 444 : if (isParamValid("controlled_activity_value")) 144 100 : params.applySpecificParameters(parameters(), {"controlled_activity_value"}); 145 444 : params.applySpecificParameters(parameters(), {"mode"}); 146 222 : params.set<Real>("initial_temperature") = getParam<Real>("initial_temperature"); 147 222 : params.set<bool>("evaluate_kinetic_rates_always") = 148 444 : getParam<bool>("evaluate_kinetic_rates_always"); 149 444 : if (isParamValid("kinetic_species_name")) 150 444 : params.set<std::vector<std::string>>("kinetic_species_name") = 151 666 : getParam<std::vector<std::string>>("kinetic_species_name"); 152 444 : if (isParamValid("kinetic_species_initial_value")) 153 444 : params.set<std::vector<Real>>("kinetic_species_initial_value") = 154 666 : getParam<std::vector<Real>>("kinetic_species_initial_value"); 155 444 : if (isParamValid("kinetic_species_unit")) 156 228 : params.set<MultiMooseEnum>("kinetic_species_unit") = 157 342 : getParam<MultiMooseEnum>("kinetic_species_unit"); 158 666 : params.set<ExecFlagEnum>("execute_on") = {EXEC_TIMESTEP_END}; 159 444 : _problem->addUserObject( 160 222 : class_name, getParam<UserObjectName>("geochemistry_reactor_name"), params); 161 210 : } 162 3068 : }