LCOV - code coverage report
Current view: top level - src/actions - AddGeochemicalModelInterrogatorAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose geochemistry: 2bf808 Lines: 59 60 98.3 %
Date: 2025-07-17 01:29:12 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 "AddGeochemicalModelInterrogatorAction.h"
      11             : #include "GeochemicalModelInterrogator.h"
      12             : #include "Executioner.h"
      13             : #include "FEProblem.h"
      14             : 
      15             : registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "setup_mesh");
      16             : registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "init_mesh");
      17             : registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "create_problem");
      18             : registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "setup_executioner");
      19             : registerMooseAction("GeochemistryApp", AddGeochemicalModelInterrogatorAction, "add_output");
      20             : 
      21             : InputParameters
      22          74 : AddGeochemicalModelInterrogatorAction::validParams()
      23             : {
      24          74 :   InputParameters params = Action::validParams();
      25          74 :   params += GeochemicalModelInterrogator::sharedParams();
      26          74 :   params.addClassDescription("Action that sets up the geochemical model interrogator");
      27             : 
      28          74 :   return params;
      29           0 : }
      30             : 
      31          74 : AddGeochemicalModelInterrogatorAction::AddGeochemicalModelInterrogatorAction(
      32          74 :     const InputParameters & params)
      33          74 :   : Action(params)
      34             : {
      35          74 : }
      36             : 
      37             : void
      38         370 : AddGeochemicalModelInterrogatorAction::act()
      39             : {
      40             :   // Set up an arbitrary mesh
      41         370 :   if (_current_task == "setup_mesh")
      42             :   {
      43          74 :     const std::string class_name = "GeneratedMesh";
      44          74 :     InputParameters params = _factory.getValidParams(class_name);
      45         148 :     params.set<MooseEnum>("dim") = "1";
      46          74 :     _mesh = _factory.create<MooseMesh>(class_name, "mesh", params);
      47          74 :   }
      48             :   // Initialize the arbitrary mesh
      49         296 :   else if (_current_task == "init_mesh")
      50             :   {
      51          74 :     _mesh->init();
      52             :   }
      53             :   // Create a "solve=false" FEProblem
      54         222 :   else if (_current_task == "create_problem")
      55             :   {
      56          74 :     const std::string class_name = "FEProblem";
      57          74 :     InputParameters params = _factory.getValidParams(class_name);
      58          74 :     params.set<MooseMesh *>("mesh") = _mesh.get();
      59          74 :     params.set<bool>("use_nonlinear") = true;
      60          74 :     params.set<bool>("solve") = false;
      61          74 :     _problem = _factory.create<FEProblemBase>(class_name, "Problem", params);
      62          74 :     _problem->setKernelCoverageCheck(FEProblemBase::CoverageCheckMode::FALSE);
      63          74 :   }
      64             :   // Set up an arbitrary steady executioner
      65         148 :   else if (_current_task == "setup_executioner")
      66             :   {
      67          74 :     const std::string class_name = "Steady";
      68          74 :     InputParameters params = _factory.getValidParams(class_name);
      69          74 :     params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
      70          74 :     params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get();
      71             :     std::shared_ptr<Executioner> executioner =
      72          74 :         _factory.create<Executioner>(class_name, "Executioner", params);
      73          74 :     _app.setExecutioner(std::move(executioner));
      74          74 :   }
      75             :   // Create a console that executes only on FINAL and does not print system info
      76          74 :   else if (_current_task == "add_output")
      77             :   {
      78          74 :     const std::string class_name = "GeochemicalModelInterrogator";
      79          74 :     auto params = _factory.getValidParams(class_name);
      80         222 :     params.set<UserObjectName>("model_definition") = getParam<UserObjectName>("model_definition");
      81             :     // Only pass parameters that were supplied to this action
      82         148 :     if (isParamValid("swap_out_of_basis"))
      83         148 :       params.set<std::vector<std::string>>("swap_out_of_basis") =
      84         222 :           getParam<std::vector<std::string>>("swap_out_of_basis");
      85         148 :     if (isParamValid("swap_into_basis"))
      86         148 :       params.set<std::vector<std::string>>("swap_into_basis") =
      87         222 :           getParam<std::vector<std::string>>("swap_into_basis");
      88         148 :     if (isParamValid("activity_species"))
      89         148 :       params.set<std::vector<std::string>>("activity_species") =
      90         222 :           getParam<std::vector<std::string>>("activity_species");
      91         148 :     if (isParamValid("activity_values"))
      92         148 :       params.set<std::vector<Real>>("activity_values") =
      93         222 :           getParam<std::vector<Real>>("activity_values");
      94         148 :     params.set<unsigned int>("precision") = getParam<unsigned int>("precision");
      95         222 :     params.set<std::string>("equilibrium_species") = getParam<std::string>("equilibrium_species");
      96         222 :     params.set<MooseEnum>("interrogation") = getParam<MooseEnum>("interrogation");
      97         148 :     params.set<Real>("temperature") = getParam<Real>("temperature");
      98         148 :     params.set<Real>("stoichiometry_tolerance") = getParam<Real>("stoichiometry_tolerance");
      99          74 :     _problem->addOutput(class_name, "geochemical_model_interrogator", params);
     100          74 :   }
     101         370 : }

Generated by: LCOV version 1.14