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 
23 {
24  MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");
25 
27  params.addClassDescription(
28  "Return the nearest value of a variable on a boundary from across a gap.");
29  params.set<bool>("_dual_restrictable") = true;
30  params.addRequiredParam<BoundaryName>("paired_boundary",
31  "The boundary on the other side of a gap.");
32  params.addRequiredParam<VariableName>("paired_variable", "The variable to get the value of.");
33  params.set<bool>("use_displaced_mesh") = true;
34  params.addParam<Real>("tangential_tolerance",
35  "Tangential distance to extend edges of contact surfaces");
36  params.addParam<Real>(
37  "normal_smoothing_distance",
38  "Distance from edge in parametric coordinates over which to smooth contact normal");
39  params.addParam<std::string>("normal_smoothing_method",
40  "Method to use to smooth normals (edge_based|nodal_normal_based)");
41  params.addParam<MooseEnum>("order", orders, "The finite element order");
42  params.addParam<bool>(
43  "warnings", false, "Whether to output warning messages concerning nodes not being found");
44  return params;
45 }
46 
48  : AuxKernel(parameters),
49  _penetration_locator(
50  _nodal ? getPenetrationLocator(
51  parameters.get<BoundaryName>("paired_boundary"),
52  boundaryNames()[0],
53  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))
54  : getQuadraturePenetrationLocator(
55  parameters.get<BoundaryName>("paired_boundary"),
56  boundaryNames()[0],
57  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
58  _moose_var(_subproblem.getStandardVariable(_tid, getParam<VariableName>("paired_variable"))),
59  _serialized_solution(_moose_var.sys().currentSolution()),
60  _dof_map(_moose_var.dofMap()),
61  _warnings(getParam<bool>("warnings"))
62 {
63  if (parameters.isParamValid("tangential_tolerance"))
64  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
65 
66  if (parameters.isParamValid("normal_smoothing_distance"))
67  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
68 
69  if (parameters.isParamValid("normal_smoothing_method"))
71  parameters.get<std::string>("normal_smoothing_method"));
72 
73  Order pairedVarOrder(_moose_var.order());
74  Order gvaOrder(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")));
75  if (pairedVarOrder != gvaOrder && pairedVarOrder != CONSTANT)
76  mooseError("ERROR: specified order for GapValueAux (",
77  Utility::enum_to_string<Order>(gvaOrder),
78  ") does not match order for paired_variable \"",
79  _moose_var.name(),
80  "\" (",
81  Utility::enum_to_string<Order>(pairedVarOrder),
82  ")");
83 }
84 
85 Real
87 {
88  const Node * current_node = NULL;
89 
90  if (_nodal)
91  current_node = _current_node;
92  else
94 
95  PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];
96 
97  Real gap_value = 0.0;
98 
99  if (pinfo)
100  {
101  std::vector<std::vector<Real>> & side_phi = pinfo->_side_phi;
102  if (_moose_var.feType().order != CONSTANT)
103  gap_value = _moose_var.getValue(pinfo->_side, side_phi);
104  else
105  gap_value = _moose_var.getValue(pinfo->_elem, side_phi);
106  }
107  else
108  {
109  if (_warnings)
110  {
111  std::stringstream msg;
112  msg << "No gap value information found for node ";
113  msg << current_node->id();
114  msg << " on processor ";
115  msg << processor_id();
116  mooseWarning(msg.str());
117  }
118  }
119  return gap_value;
120 }
Order
registerMooseObject("MooseApp", GapValueAux)
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:177
GapValueAux(const InputParameters &parameters)
Definition: GapValueAux.C:47
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:206
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:188
OutputType getValue(const Elem *elem, const std::vector< std::vector< OutputShape >> &phi) const
Compute the variable value at a point on an element.
void setNormalSmoothingDistance(Real normal_smoothing_distance)
Data structure used to hold penetration information.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:214
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1147
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const std::string & name() const override
Get the variable name.
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)
MooseVariable & _moose_var
Definition: GapValueAux.h:28
const FEType & feType() const
Get the type of finite element object.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
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...
static InputParameters validParams()
Definition: GapValueAux.C:22
CONSTANT
const Elem * _elem
T string_to_enum(const std::string &s)
const bool _warnings
Definition: GapValueAux.h:34
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:1444
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: GapValueAux.C:86
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:204
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:230
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
const InputParameters & parameters() const
Get the parameters of the object.
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...
static InputParameters validParams()
Definition: AuxKernel.C:27
void setNormalSmoothingMethod(std::string nsmString)
processor_id_type processor_id() const
PenetrationLocator & _penetration_locator
Definition: GapValueAux.h:26
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.