Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring problem creation to allow custom actions to create specia…
…l problems #12002
- Loading branch information
Showing
14 changed files
with
229 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//* 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 | ||
|
||
#ifndef CREATEPROBLEMDEFAULTACTION_H | ||
#define CREATEPROBLEMDEFAULTACTION_H | ||
|
||
// MOOSE includes | ||
#include "Action.h" | ||
|
||
class CreateProblemDefaultAction; | ||
|
||
template <> | ||
InputParameters validParams<CreateProblemDefaultAction>(); | ||
|
||
class CreateProblemDefaultAction : public Action | ||
{ | ||
public: | ||
CreateProblemDefaultAction(InputParameters parameters); | ||
|
||
virtual void act() override; | ||
}; | ||
|
||
#endif /* CREATEPROBLEMDEFAULTACTION_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//* 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 "CreateProblemDefaultAction.h" | ||
|
||
#include "Factory.h" | ||
#include "FEProblem.h" | ||
#include "EigenProblem.h" | ||
#include "NonlinearSystemBase.h" | ||
#include "MooseApp.h" | ||
#include "CreateExecutionerAction.h" | ||
|
||
registerMooseAction("MooseApp", CreateProblemDefaultAction, "create_problem_default"); | ||
|
||
template <> | ||
InputParameters | ||
validParams<CreateProblemDefaultAction>() | ||
{ | ||
InputParameters params = validParams<Action>(); | ||
params.addParam<bool>("solve", | ||
true, | ||
"Whether or not to actually solve the Nonlinear system. " | ||
"This is handy in the case that all you want to do is " | ||
"execute AuxKernels, Transfers, etc. without actually " | ||
"solving anything"); | ||
return params; | ||
} | ||
|
||
CreateProblemDefaultAction::CreateProblemDefaultAction(InputParameters parameters) | ||
: Action(parameters) | ||
{ | ||
} | ||
|
||
void | ||
CreateProblemDefaultAction::act() | ||
{ | ||
// act only if we have mesh | ||
if (_mesh.get() != NULL) | ||
{ | ||
// Make sure the problem hasn't already been created elsewhere | ||
if (!_problem) | ||
{ | ||
std::string type; | ||
if (_app.useEigenvalue()) | ||
type = "EigenProblem"; | ||
else | ||
type = "FEProblem"; | ||
auto params = _factory.getValidParams(type); | ||
|
||
params.set<MooseMesh *>("mesh") = _mesh.get(); | ||
params.set<bool>("use_nonlinear") = _app.useNonlinear(); | ||
params.set<bool>("solve") = getParam<bool>("solve"); | ||
|
||
_problem = _factory.create<FEProblemBase>(type, "MOOSE Problem", params); | ||
} | ||
else | ||
{ | ||
if (_app.useEigenvalue() && !(std::dynamic_pointer_cast<EigenProblem>(_problem))) | ||
mooseError("Problem has to be of a EigenProblem (or derived subclass) type when using " | ||
"eigen executioner"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.