www.mooseframework.org
CreateDisplacedProblemAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 #include "MooseApp.h"
17 #include "FEProblem.h"
18 #include "DisplacedProblem.h"
19 
20 template <>
23 {
25  params.addParam<std::vector<std::string>>(
26  "displacements",
27  "The variables corresponding to the x y z displacements of the mesh. If "
28  "this is provided then the displacements will be taken into account during "
29  "the computation.");
30 
31  return params;
32 }
33 
35  : Action(parameters)
36 {
37 }
38 
39 void
41 {
42  if (isParamValid("displacements"))
43  {
44  if (!_displaced_mesh)
45  mooseError("displacements were set but a displaced mesh wasn't created!");
46 
47  // Define the parameters
48  InputParameters object_params = _factory.getValidParams("DisplacedProblem");
49  object_params.set<std::vector<std::string>>("displacements") =
50  getParam<std::vector<std::string>>("displacements");
51  object_params.set<MooseMesh *>("mesh") = _displaced_mesh.get();
52  object_params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
53 
54  // Create the object
55  std::shared_ptr<DisplacedProblem> disp_problem =
56  _factory.create<DisplacedProblem>("DisplacedProblem", "DisplacedProblem", object_params);
57 
58  // Add the Displaced Problem to FEProblemBase
59  _problem->addDisplacedProblem(disp_problem);
60  }
61 }
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:46
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
Definition: Factory.C:26
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
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:101
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Base class for actions.
Definition: Action.h:39
std::shared_ptr< MooseMesh > & _displaced_mesh
Definition: Action.h:128
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
bool isParamValid(const std::string &name) const
Definition: Action.h:80
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:131
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...
InputParameters validParams< CreateDisplacedProblemAction >()
InputParameters validParams< Action >()
Definition: Action.C:23
CreateDisplacedProblemAction(InputParameters parameters)
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: Action.h:139