LCOV - code coverage report
Current view: top level - src/actions - AddTimeDependentReactionSolverAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose geochemistry: 419b9d Lines: 108 113 95.6 %
Date: 2025-08-08 20:01:54 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14