www.mooseframework.org
GapValueAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "GapValueAux.h"
11 
12 #include "MooseMesh.h"
13 #include "SystemBase.h"
14 #include "MooseEnum.h"
15 #include "PenetrationLocator.h"
16 
17 #include "libmesh/string_to_enum.h"
18 
19 registerMooseObject("MooseApp", GapValueAux);
20 
21 template <>
24 {
25  MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");
26 
28  params.set<bool>("_dual_restrictable") = true;
29  params.addRequiredParam<BoundaryName>("paired_boundary",
30  "The boundary on the other side of a gap.");
31  params.addRequiredParam<VariableName>("paired_variable", "The variable to get the value of.");
32  params.set<bool>("use_displaced_mesh") = true;
33  params.addParam<Real>("tangential_tolerance",
34  "Tangential distance to extend edges of contact surfaces");
35  params.addParam<Real>(
36  "normal_smoothing_distance",
37  "Distance from edge in parametric coordinates over which to smooth contact normal");
38  params.addParam<std::string>("normal_smoothing_method",
39  "Method to use to smooth normals (edge_based|nodal_normal_based)");
40  params.addParam<MooseEnum>("order", orders, "The finite element order");
41  params.addParam<bool>(
42  "warnings", false, "Whether to output warning messages concerning nodes not being found");
43  return params;
44 }
45 
47  : AuxKernel(parameters),
48  _penetration_locator(
49  _nodal ? getPenetrationLocator(
50  parameters.get<BoundaryName>("paired_boundary"),
51  boundaryNames()[0],
52  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))
53  : getQuadraturePenetrationLocator(
54  parameters.get<BoundaryName>("paired_boundary"),
55  boundaryNames()[0],
56  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
57  _moose_var(_subproblem.getStandardVariable(_tid, getParam<VariableName>("paired_variable"))),
58  _serialized_solution(_moose_var.sys().currentSolution()),
59  _dof_map(_moose_var.dofMap()),
60  _warnings(getParam<bool>("warnings"))
61 {
62  if (parameters.isParamValid("tangential_tolerance"))
63  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
64 
65  if (parameters.isParamValid("normal_smoothing_distance"))
66  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
67 
68  if (parameters.isParamValid("normal_smoothing_method"))
70  parameters.get<std::string>("normal_smoothing_method"));
71 
72  Order pairedVarOrder(_moose_var.order());
73  Order gvaOrder(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")));
74  if (pairedVarOrder != gvaOrder && pairedVarOrder != CONSTANT)
75  mooseError("ERROR: specified order for GapValueAux (",
76  Utility::enum_to_string<Order>(gvaOrder),
77  ") does not match order for paired_variable \"",
78  _moose_var.name(),
79  "\" (",
80  Utility::enum_to_string<Order>(pairedVarOrder),
81  ")");
82 }
83 
84 Real
86 {
87  const Node * current_node = NULL;
88 
89  if (_nodal)
90  current_node = _current_node;
91  else
93 
94  PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];
95 
96  Real gap_value = 0.0;
97 
98  if (pinfo)
99  {
100  std::vector<std::vector<Real>> & side_phi = pinfo->_side_phi;
101  if (_moose_var.feType().order != CONSTANT)
102  gap_value = _moose_var.getValue(pinfo->_side, side_phi);
103  else
104  gap_value = _moose_var.getValue(pinfo->_elem, side_phi);
105  }
106  else
107  {
108  if (_warnings)
109  {
110  std::stringstream msg;
111  msg << "No gap value information found for node ";
112  msg << current_node->id();
113  msg << " on processor ";
114  msg << processor_id();
115  mooseWarning(msg.str());
116  }
117  }
118  return gap_value;
119 }
registerMooseObject("MooseApp", GapValueAux)
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:170
GapValueAux(const InputParameters &parameters)
Definition: GapValueAux.C:46
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:205
void mooseWarning(Args &&... args) const
Definition: MooseObject.h:155
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:190
void setNormalSmoothingDistance(Real normal_smoothing_distance)
Data structure used to hold penetration information.
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:213
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...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
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)
MooseVariable & _moose_var
Definition: GapValueAux.h:31
const FEType & feType() const
Get the type of finite element object.
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...
InputParameters validParams< GapValueAux >()
Definition: GapValueAux.C:23
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
const Elem * _elem
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:25
const bool _warnings
Definition: GapValueAux.h:37
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
const Elem * _side
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
Definition: MooseMesh.C:977
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
OutputType getValue(const Elem *elem, const std::vector< std::vector< OutputType >> &phi) const
Compute the variable value at a point on an element.
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: GapValueAux.C:85
const std::string & name() const
Get the variable name.
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:203
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:219
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...
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33
void setNormalSmoothingMethod(std::string nsmString)
PenetrationLocator & _penetration_locator
Definition: GapValueAux.h:29
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.