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
10 #include "CreateProblemAction.h"
11 #include "Factory.h"
12 #include "FEProblem.h"
13 #include "MooseApp.h"
15 registerMooseAction("MooseApp", CreateProblemAction, "create_problem");
17 template <>
20 {
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 }
28 {
29 }
31 void
33 {
34  // build the problem only if we have mesh
35  if (_mesh.get() != NULL && _pars.isParamSetByUser("type"))
36  {
37  // when this action is built by parser with Problem input block, this action
38  // must act i.e. create a problem. Thus if a problem has been created, it will error out.
39  if (_problem)
40  mooseError("Trying to build a problem but problem has already existed");
42  _moose_object_pars.set<MooseMesh *>("mesh") = _mesh.get();
43  _moose_object_pars.set<bool>("use_nonlinear") = _app.useNonlinear();
45  _problem =
46  _factory.create<FEProblemBase>(_type, getParam<std::string>("name"), _moose_object_pars);
47  }
48 }
bool & useNonlinear()
Set a Boolean indicating whether this app will use a Nonlinear or Eigen System.
Definition: MooseApp.h:276
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, 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:87
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Factory & _factory
The Factory associated with the MooseApp.
Definition: Action.h:186
InputParameters validParams< CreateProblemAction >()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
InputParameters _pars
Input parameters for the action.
Definition: Action.h:171
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
InputParameters validParams< MooseObjectAction >()
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:212
std::string _type
The Object type that is being created.
InputParameters _moose_object_pars
The parameters for the object to be created.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:216
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...
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:183
CreateProblemAction(InputParameters parameters)