https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CreateProblemAction.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
10#include "CreateProblemAction.h"
11#include "Factory.h"
12#include "FEProblem.h"
13#include "MooseApp.h"
14
15registerMooseAction("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
31
32void
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}
registerMooseAction("MooseApp", CreateProblemAction, "create_problem")
std::shared_ptr< MooseMesh > & _mesh
Definition Action.h:174
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
CreateProblemAction(const InputParameters &parameters)
static InputParameters validParams()
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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)
Definition Factory.C:142
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
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.
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 & useNonlinear()
Returns a writable Boolean indicating whether this app will use a Nonlinear or Eigen System.
Definition MooseApp.h:397
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
const InputParameters & _pars
The object's parameters.
Definition MooseBase.h:384
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
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.
Factory & _factory
The Factory associated with the MooseApp.