www.mooseframework.org
GapValueAux.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 "GapValueAux.h"
16 
17 #include "MooseMesh.h"
18 #include "SystemBase.h"
19 #include "MooseEnum.h"
20 #include "PenetrationLocator.h"
21 
22 #include "libmesh/string_to_enum.h"
23 
24 template <>
27 {
28  MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");
29 
31  params.set<bool>("_dual_restrictable") = true;
32  params.addRequiredParam<BoundaryName>("paired_boundary",
33  "The boundary on the other side of a gap.");
34  params.addRequiredParam<VariableName>("paired_variable", "The variable to get the value of.");
35  params.set<bool>("use_displaced_mesh") = true;
36  params.addParam<Real>("tangential_tolerance",
37  "Tangential distance to extend edges of contact surfaces");
38  params.addParam<Real>(
39  "normal_smoothing_distance",
40  "Distance from edge in parametric coordinates over which to smooth contact normal");
41  params.addParam<std::string>("normal_smoothing_method",
42  "Method to use to smooth normals (edge_based|nodal_normal_based)");
43  params.addParam<MooseEnum>("order", orders, "The finite element order");
44  params.addParam<bool>(
45  "warnings", false, "Whether to output warning messages concerning nodes not being found");
46  return params;
47 }
48 
50  : AuxKernel(parameters),
51  _penetration_locator(
52  _nodal ? getPenetrationLocator(
53  parameters.get<BoundaryName>("paired_boundary"),
54  boundaryNames()[0],
55  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))
56  : getQuadraturePenetrationLocator(
57  parameters.get<BoundaryName>("paired_boundary"),
58  boundaryNames()[0],
59  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
60  _moose_var(_subproblem.getVariable(_tid, getParam<VariableName>("paired_variable"))),
61  _serialized_solution(_moose_var.sys().currentSolution()),
62  _dof_map(_moose_var.dofMap()),
63  _warnings(getParam<bool>("warnings"))
64 {
65  if (parameters.isParamValid("tangential_tolerance"))
66  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
67 
68  if (parameters.isParamValid("normal_smoothing_distance"))
69  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
70 
71  if (parameters.isParamValid("normal_smoothing_method"))
73  parameters.get<std::string>("normal_smoothing_method"));
74 
75  Order pairedVarOrder(_moose_var.order());
76  Order gvaOrder(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")));
77  if (pairedVarOrder != gvaOrder && pairedVarOrder != CONSTANT)
78  mooseError("ERROR: specified order for GapValueAux (",
79  Utility::enum_to_string<Order>(gvaOrder),
80  ") does not match order for paired_variable \"",
81  _moose_var.name(),
82  "\" (",
83  Utility::enum_to_string<Order>(pairedVarOrder),
84  ")");
85 }
86 
87 Real
89 {
90  const Node * current_node = NULL;
91 
92  if (_nodal)
93  current_node = _current_node;
94  else
96 
97  PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];
98 
99  Real gap_value = 0.0;
100 
101  if (pinfo)
102  {
103  std::vector<std::vector<Real>> & side_phi = pinfo->_side_phi;
104  if (_moose_var.feType().order != CONSTANT)
105  gap_value = _moose_var.getValue(pinfo->_side, side_phi);
106  else
107  gap_value = _moose_var.getValue(pinfo->_elem, side_phi);
108  }
109  else
110  {
111  if (_warnings)
112  {
113  std::stringstream msg;
114  msg << "No gap value information found for node ";
115  msg << current_node->id();
116  msg << " on processor ";
117  msg << processor_id();
118  mooseWarning(msg.str());
119  }
120  }
121  return gap_value;
122 }
void mooseWarning(Args &&...args) const
Definition: MooseObject.h:89
const FEType & feType() const
Get the type of finite element object.
GapValueAux(const InputParameters &parameters)
Definition: GapValueAux.C:49
void setNormalSmoothingDistance(Real normal_smoothing_distance)
Data structure used to hold penetration information.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const Elem *& _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:176
unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:178
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< std::vector< Real > > _side_phi
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
void setTangentialTolerance(Real tangential_tolerance)
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:154
MooseVariable & _moose_var
Definition: GapValueAux.h:37
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
const std::string & name() const
Get the variable name.
InputParameters validParams< GapValueAux >()
Definition: GapValueAux.C:26
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
const Elem * _elem
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:30
const Node *& _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:186
const bool _warnings
Definition: GapValueAux.h:43
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:192
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:51
const Elem * _side
bool _nodal
true if the kernel is nodal, false if it is elemental
Definition: AuxKernel.h:150
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
Definition: MooseMesh.C:938
Real getValue(const Elem *elem, const std::vector< std::vector< Real >> &phi) const
Compute the variable value at a point on an element.
virtual Real computeValue() override
Definition: GapValueAux.C:88
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
void setNormalSmoothingMethod(std::string nsmString)
PenetrationLocator & _penetration_locator
Definition: GapValueAux.h:35