www.mooseframework.org
CreateProblemAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "CreateProblemAction.h"
11 #include "Factory.h"
12 #include "FEProblem.h"
13 #include "MooseApp.h"
14 
15 registerMooseAction("MooseApp", CreateProblemAction, "create_problem");
16 
19 {
21  params.addClassDescription("Add a Problem object to the simulation.");
22  params.addParam<std::string>("type", "FEProblem", "Problem type");
23  params.addParam<std::string>("name", "MOOSE Problem", "The name the problem");
24  return params;
25 }
26 
28  : MooseObjectAction(parameters)
29 {
30 }
31 
32 void
34 {
35  // build the problem only if we have mesh
36  if (_mesh.get() != NULL && _pars.isParamSetByUser("type"))
37  {
38  // when this action is built by parser with Problem input block, this action
39  // must act i.e. create a problem. Thus if a problem has been created, it will error out.
40  if (_problem)
41  mooseError("Trying to build a problem but problem has already existed");
42 
43  _moose_object_pars.set<MooseMesh *>("mesh") = _mesh.get();
44  _moose_object_pars.set<bool>("use_nonlinear") = _app.useNonlinear();
45 
46  _problem =
47  _factory.create<FEProblemBase>(_type, getParam<std::string>("name"), _moose_object_pars);
48  }
49 }
CreateProblemAction(const InputParameters &parameters)
bool & useNonlinear()
Returns a writable Boolean indicating whether this app will use a Nonlinear or Eigen System...
Definition: MooseApp.h:398
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
static InputParameters validParams()
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters &parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:86
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Factory & _factory
The Factory associated with the MooseApp.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
registerMooseAction("MooseApp", CreateProblemAction, "create_problem")
std::shared_ptr< MooseMesh > & _mesh
Definition: Action.h:147
std::string _type
The Object type that is being created.
InputParameters _moose_object_pars
The parameters for the object to be created.
static InputParameters validParams()
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
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...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:151
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...