www.mooseframework.org
NearestNodeDistanceAux.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 // MOOSE includes
16 #include "NearestNodeDistanceAux.h"
17 #include "NearestNodeLocator.h"
18 #include "MooseMesh.h"
19 
20 template <>
23 {
25  params.addClassDescription(
26  "Stores the distance between a block and boundary or between two boundaries.");
27  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to find the distance to.");
28  params.set<bool>("use_displaced_mesh") = true;
29  return params;
30 }
31 
33  : AuxKernel(parameters),
34  _nearest_node(_nodal ? getNearestNodeLocator(parameters.get<BoundaryName>("paired_boundary"),
35  boundaryNames()[0])
36  : getQuadratureNearestNodeLocator(
37  parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0]))
38 {
39  if (boundaryNames().size() > 1)
40  mooseError("NearestNodeDistanceAux can only be used with one boundary at a time!");
41 }
42 
43 Real
45 {
46  if (_nodal)
47  return _nearest_node.distance(_current_node->id());
48 
50 
51  return _nearest_node.distance(qnode->id());
52 }
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
Real distance(dof_id_type node_id)
Valid to call this after findNodes() has been called to get the distance to the nearest node...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:154
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::vector< BoundaryName > & boundaryNames() const
Return the boundary names for this object.
virtual Real computeValue() override
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:30
const Node *& _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:186
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
InputParameters validParams< NearestNodeDistanceAux >()
NearestNodeDistanceAux(const InputParameters &parameters)
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:899
NearestNodeLocator & _nearest_node
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80