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 56 : AddGeochemicalModelInterrogatorAction::validParams() 23 : { 24 56 : InputParameters params = Action::validParams(); 25 56 : params += GeochemicalModelInterrogator::sharedParams(); 26 56 : params.addClassDescription("Action that sets up the geochemical model interrogator"); 27 : 28 56 : return params; 29 0 : } 30 : 31 56 : AddGeochemicalModelInterrogatorAction::AddGeochemicalModelInterrogatorAction( 32 56 : const InputParameters & params) 33 56 : : Action(params) 34 : { 35 56 : } 36 : 37 : void 38 280 : AddGeochemicalModelInterrogatorAction::act() 39 : { 40 : // Set up an arbitrary mesh 41 280 : if (_current_task == "setup_mesh") 42 : { 43 56 : const std::string class_name = "GeneratedMesh"; 44 56 : InputParameters params = _factory.getValidParams(class_name); 45 112 : params.set<MooseEnum>("dim") = "1"; 46 56 : _mesh = _factory.create<MooseMesh>(class_name, "mesh", params); 47 56 : } 48 : // Initialize the arbitrary mesh 49 224 : else if (_current_task == "init_mesh") 50 : { 51 56 : _mesh->init(); 52 : } 53 : // Create a "solve=false" FEProblem 54 168 : else if (_current_task == "create_problem") 55 : { 56 56 : const std::string class_name = "FEProblem"; 57 56 : InputParameters params = _factory.getValidParams(class_name); 58 56 : params.set<MooseMesh *>("mesh") = _mesh.get(); 59 56 : params.set<bool>("use_nonlinear") = true; 60 56 : params.set<bool>("solve") = false; 61 56 : _problem = _factory.create<FEProblemBase>(class_name, "Problem", params); 62 56 : _problem->setKernelCoverageCheck(FEProblemBase::CoverageCheckMode::FALSE); 63 56 : } 64 : // Set up an arbitrary steady executioner 65 112 : else if (_current_task == "setup_executioner") 66 : { 67 56 : const std::string class_name = "Steady"; 68 56 : InputParameters params = _factory.getValidParams(class_name); 69 56 : params.set<FEProblemBase *>("_fe_problem_base") = _problem.get(); 70 56 : params.set<FEProblem *>("_fe_problem") = (std::dynamic_pointer_cast<FEProblem>(_problem)).get(); 71 : std::shared_ptr<Executioner> executioner = 72 56 : _factory.create<Executioner>(class_name, "Executioner", params); 73 56 : _app.setExecutioner(std::move(executioner)); 74 56 : } 75 : // Create a console that executes only on FINAL and does not print system info 76 56 : else if (_current_task == "add_output") 77 : { 78 56 : const std::string class_name = "GeochemicalModelInterrogator"; 79 56 : auto params = _factory.getValidParams(class_name); 80 168 : params.set<UserObjectName>("model_definition") = getParam<UserObjectName>("model_definition"); 81 : // Only pass parameters that were supplied to this action 82 112 : if (isParamValid("swap_out_of_basis")) 83 112 : params.set<std::vector<std::string>>("swap_out_of_basis") = 84 168 : getParam<std::vector<std::string>>("swap_out_of_basis"); 85 112 : if (isParamValid("swap_into_basis")) 86 112 : params.set<std::vector<std::string>>("swap_into_basis") = 87 168 : getParam<std::vector<std::string>>("swap_into_basis"); 88 112 : if (isParamValid("activity_species")) 89 112 : params.set<std::vector<std::string>>("activity_species") = 90 168 : getParam<std::vector<std::string>>("activity_species"); 91 112 : if (isParamValid("activity_values")) 92 112 : params.set<std::vector<Real>>("activity_values") = 93 168 : getParam<std::vector<Real>>("activity_values"); 94 112 : params.set<unsigned int>("precision") = getParam<unsigned int>("precision"); 95 168 : params.set<std::string>("equilibrium_species") = getParam<std::string>("equilibrium_species"); 96 168 : params.set<MooseEnum>("interrogation") = getParam<MooseEnum>("interrogation"); 97 112 : params.set<Real>("temperature") = getParam<Real>("temperature"); 98 112 : params.set<Real>("stoichiometry_tolerance") = getParam<Real>("stoichiometry_tolerance"); 99 56 : _problem->addOutput(class_name, "geochemical_model_interrogator", params); 100 56 : } 101 280 : }