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 "ReadExecutorParamsAction.h" 11 : #include "Factory.h" 12 : #include "PetscSupport.h" 13 : #include "MooseApp.h" 14 : #include "Executor.h" 15 : #include "Eigenvalue.h" 16 : #include "FEProblem.h" 17 : #include "EigenProblem.h" 18 : 19 : registerMooseAction("MooseApp", ReadExecutorParamsAction, "read_executor"); 20 : 21 : InputParameters 22 271 : ReadExecutorParamsAction::validParams() 23 : { 24 271 : InputParameters params = MooseObjectAction::validParams(); 25 271 : params.addClassDescription("Add an Executor object to the simulation."); 26 813 : params.addParam<bool>( 27 : "auto_preconditioning", 28 542 : true, 29 : "When true and a [Preconditioning] block does not exist, the application will attempt to use " 30 : "the correct preconditioning given the Executor settings."); 31 271 : return params; 32 0 : } 33 : 34 68 : ReadExecutorParamsAction::ReadExecutorParamsAction(const InputParameters & params) 35 68 : : MooseObjectAction(params), _auto_preconditioning(getParam<bool>("auto_preconditioning")) 36 : { 37 68 : } 38 : 39 : void 40 68 : ReadExecutorParamsAction::act() 41 : { 42 : // If enabled, automatically create a Preconditioner if the [Preconditioning] block is not found 43 204 : if (_auto_preconditioning && !_awh.hasActions("add_preconditioning") && 44 136 : _moose_object_pars.isParamValid("solve_type")) 45 0 : setupAutoPreconditioning(); 46 : 47 68 : _app.addExecutorParams(_type, _name, _moose_object_pars); 48 68 : } 49 : 50 : void 51 0 : ReadExecutorParamsAction::setupAutoPreconditioning() 52 : { 53 : // If using NEWTON or LINEAR then automatically create SingleMatrixPreconditioner object with 54 : // full=true 55 0 : const MooseEnum & solve_type = _moose_object_pars.get<MooseEnum>("solve_type"); 56 0 : if (((solve_type.find("NEWTON") != solve_type.items().end()) && (solve_type == "NEWTON")) || 57 0 : ((solve_type.find("LINEAR") != solve_type.items().end()) && (solve_type == "LINEAR"))) 58 : { 59 : // Action Parameters 60 0 : InputParameters params = _action_factory.getValidParams("SetupPreconditionerAction"); 61 0 : params.set<std::string>("type") = "SMP"; 62 : 63 : // Associate errors with "solve_type" 64 0 : associateWithParameter(_moose_object_pars, "solve_type", params); 65 : 66 : // Create the Action that will build the Preconditioner object 67 : std::shared_ptr<Action> ptr = 68 0 : _action_factory.create("SetupPreconditionerAction", "_moose_auto", params); 69 : 70 : // Set 'full=true' 71 0 : std::shared_ptr<MooseObjectAction> moa_ptr = std::static_pointer_cast<MooseObjectAction>(ptr); 72 0 : InputParameters & mo_params = moa_ptr->getObjectParams(); 73 0 : mo_params.set<bool>("full") = true; 74 : 75 0 : _awh.addActionBlock(ptr); 76 0 : } 77 0 : }