www.mooseframework.org
AddNodalNormalsAction.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 
15 #include "AddNodalNormalsAction.h"
16 #include "FEProblem.h"
17 #include "Factory.h"
18 
19 #include "libmesh/fe.h"
20 #include "libmesh/string_to_enum.h"
21 
22 template <>
25 {
27 
28  // Initialize the 'boundary' input option to default to any boundary
29  std::vector<BoundaryName> everywhere(1, "ANY_BOUNDARY_ID");
30  params.addParam<std::vector<BoundaryName>>(
31  "boundary", everywhere, "The boundary ID or name where the normals will be computed");
32  params.addParam<BoundaryName>("corner_boundary", "boundary ID or name with nodes at 'corners'");
33  MooseEnum orders("FIRST SECOND", "FIRST");
34  params.addParam<MooseEnum>("order",
35  orders,
36  "Specifies the order of variables that hold the "
37  "nodal normals. Needs to match the order of the "
38  "mesh");
39 
40  return params;
41 }
42 
44  : Action(parameters),
45  _boundary(getParam<std::vector<BoundaryName>>("boundary")),
46  _has_corners(isParamValid("corner_boundary")),
47  _corner_boundary(_has_corners ? getParam<BoundaryName>("corner_boundary") : BoundaryName())
48 {
49 }
50 
51 void
53 {
54  // Set the order from the input
55  Order order = Utility::string_to_enum<Order>(getParam<MooseEnum>("order"));
56  FEFamily family = LAGRANGE;
57  FEType fe_type(order, family);
58 
59  // Add 3 aux variables for each component of the normal
60  if (_current_task == "add_aux_variable")
61  {
62  _problem->addAuxVariable("nodal_normal_x", fe_type);
63  _problem->addAuxVariable("nodal_normal_y", fe_type);
64  _problem->addAuxVariable("nodal_normal_z", fe_type);
65  }
66 
67  // Set the execute options
69  execute_options = "initial timestep_begin";
70 
71  // Create the NodalNormalsPreprocessor UserObject
72  if (_current_task == "add_postprocessor")
73  {
74  InputParameters pars = _factory.getValidParams("NodalNormalsPreprocessor");
75  pars.set<Order>("fe_order") = order;
76  pars.set<FEFamily>("fe_family") = family;
77  pars.set<MultiMooseEnum>("execute_on") = execute_options;
78  pars.set<std::vector<BoundaryName>>("surface_boundary") = _boundary;
79 
80  if (_has_corners)
81  pars.set<BoundaryName>("corner_boundary") = _corner_boundary;
82 
83  _problem->addUserObject("NodalNormalsPreprocessor", "nodal_normals_preprocessor", pars);
84  }
85 
86  if (_current_task == "add_user_object")
87  {
89  if (_has_corners)
90  {
91  InputParameters pars = _factory.getValidParams("NodalNormalsCorner");
92  pars.set<MultiMooseEnum>("execute_on") = execute_options;
93  pars.set<std::vector<BoundaryName>>("boundary") = _boundary;
94  pars.set<BoundaryName>("corner_boundary") = _corner_boundary;
95  _problem->addUserObject("NodalNormalsCorner", "nodal_normals_corner", pars);
96  }
97 
99  {
100  InputParameters pars = _factory.getValidParams("NodalNormalsEvaluator");
101  pars.set<MultiMooseEnum>("execute_on") = execute_options;
102  pars.set<std::vector<BoundaryName>>("boundary") = _boundary;
103  _problem->addUserObject("NodalNormalsEvaluator", "nodal_normals_evaluator", pars);
104  }
105  }
106 }
std::vector< BoundaryName > _boundary
The supplied boundary name from the user.
bool _has_corners
Flag for testing the existance of the corner boundary input.
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
Definition: Factory.C:26
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
Base class for actions.
Definition: Action.h:39
virtual void act() override
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
const std::string & _current_task
The current action (even though we have seperate instances for each action)
Definition: Action.h:125
InputParameters validParams< AddNodalNormalsAction >()
AddNodalNormalsAction(InputParameters parameters)
BoundaryName _corner_boundary
The supplied boundary name for the corner boundary.
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...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static MultiMooseEnum getExecuteOptions()
Returns the available options for the &#39;execute_on&#39; input parameters.
InputParameters validParams< Action >()
Definition: Action.C:23