-
Notifications
You must be signed in to change notification settings - Fork 1k
/
CreateProblemAction.C
59 lines (50 loc) · 1.92 KB
/
CreateProblemAction.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#include "CreateProblemAction.h"
#include "Factory.h"
#include "FEProblem.h"
#include "EigenProblem.h"
#include "NonlinearSystemBase.h"
#include "MooseApp.h"
registerMooseAction("MooseApp", CreateProblemAction, "create_problem");
template <>
InputParameters
validParams<CreateProblemAction>()
{
InputParameters params = validParams<MooseObjectAction>();
params.addParam<std::string>("type", "FEProblem", "Problem type");
params.addParam<std::string>("name", "MOOSE Problem", "The name the problem");
return params;
}
CreateProblemAction::CreateProblemAction(InputParameters parameters)
: MooseObjectAction(parameters)
{
}
void
CreateProblemAction::act()
{
// build the problem only if we have mesh
if (_mesh.get() != NULL)
{
// when this action is built by parser with Problem input block, this action
// must act i.e. create a problem. Thus if a problem has been created, it will error out.
if (_problem)
mooseError("Trying to build a problem but problem has already existed");
_moose_object_pars.set<MooseMesh *>("mesh") = _mesh.get();
_moose_object_pars.set<bool>("use_nonlinear") = _app.useNonlinear();
// we can do the following because FEProblem and EigenProblem have the same valid parameters.
// Ideally, type should be required but it will require large change on existing files.
if (_app.useEigenvalue() && !_pars.isParamSetByUser("type"))
_type = "EigenProblem";
_problem =
_factory.create<FEProblemBase>(_type, getParam<std::string>("name"), _moose_object_pars);
if (!_problem.get())
mooseError("Problem has to be of a FEProblemBase type");
}
}