https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ReadExecutorParamsAction.C
Go to the documentation of this file.
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
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
19registerMooseAction("MooseApp", ReadExecutorParamsAction, "read_executor");
20
23{
25 params.addClassDescription("Add an Executor object to the simulation.");
26 params.addParam<bool>(
27 "auto_preconditioning",
28 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 return params;
32}
33
35 : MooseObjectAction(params), _auto_preconditioning(getParam<bool>("auto_preconditioning"))
36{
37}
38
39void
41{
42 // If enabled, automatically create a Preconditioner if the [Preconditioning] block is not found
43 if (_auto_preconditioning && !_awh.hasActions("add_preconditioning") &&
44 _moose_object_pars.isParamValid("solve_type"))
46
48}
49
50void
52{
53 // If using NEWTON or LINEAR then automatically create SingleMatrixPreconditioner object with
54 // full=true
55 const MooseEnum & solve_type = _moose_object_pars.get<MooseEnum>("solve_type");
56 if (((solve_type.find("NEWTON") != solve_type.items().end()) && (solve_type == "NEWTON")) ||
57 ((solve_type.find("LINEAR") != solve_type.items().end()) && (solve_type == "LINEAR")))
58 {
59 // Action Parameters
60 InputParameters params = _action_factory.getValidParams("SetupPreconditionerAction");
61 params.set<std::string>("type") = "SMP";
62
63 // Associate errors with "solve_type"
64 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 _action_factory.create("SetupPreconditionerAction", "_moose_auto", params);
69
70 // Set 'full=true'
71 std::shared_ptr<MooseObjectAction> moa_ptr = std::static_pointer_cast<MooseObjectAction>(ptr);
72 InputParameters & mo_params = moa_ptr->getObjectParams();
73 mo_params.set<bool>("full") = true;
74
76 }
77}
registerMooseAction("MooseApp", ReadExecutorParamsAction, "read_executor")
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name)
bool hasActions(const std::string &task) const
Check if Actions associated with passed in task exist.
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
void associateWithParameter(const std::string &param_name, InputParameters &params) const
Associates the object's parameters params with the input location from this Action's parameter with t...
Definition Action.C:170
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition Action.h:169
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
void addExecutorParams(const std::string &type, const std::string &name, const InputParameters &params)
Adds the parameters for an Executor to the list of parameters.
Definition MooseApp.C:1871
const std::string & _name
The name of this class.
Definition MooseBase.h:381
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
const std::set< MooseEnumItem > & items() const
Return the complete set of available flags.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
InputParameters _moose_object_pars
The parameters for the object to be created.
static InputParameters validParams()
std::string _type
The Object type that is being created.
ActionFactory & _action_factory
Builds Actions.
static InputParameters validParams()
const bool _auto_preconditioning
Whether to automatically add a preconditioner.
ReadExecutorParamsAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.