www.mooseframework.org
NearestNodeDistanceAux.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 // MOOSE includes
11 #include "NearestNodeDistanceAux.h"
12 #include "NearestNodeLocator.h"
13 #include "MooseMesh.h"
14 
16 
19 {
21  params.addClassDescription(
22  "Stores the distance between a block and boundary or between two boundaries.");
23  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to find the distance to.");
24  params.set<bool>("use_displaced_mesh") = true;
25  return params;
26 }
27 
29  : AuxKernel(parameters),
30  _nearest_node(_nodal ? getNearestNodeLocator(parameters.get<BoundaryName>("paired_boundary"),
31  boundaryNames()[0])
32  : getQuadratureNearestNodeLocator(
33  parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0]))
34 {
35  if (boundaryNames().size() > 1)
36  mooseError("NearestNodeDistanceAux can only be used with one boundary at a time!");
37 }
38 
39 Real
41 {
42  if (_nodal)
43  return _nearest_node.distance(_current_node->id());
44 
46 
47  return _nearest_node.distance(qnode->id());
48 }
registerMooseObject("MooseApp", NearestNodeDistanceAux)
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:177
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
Computes the distance from a block or boundary to another boundary.
static InputParameters validParams()
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.
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...
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...
virtual Real computeValue() override
Compute and return the value of the aux variable.
NearestNodeDistanceAux(const InputParameters &parameters)
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
Definition: MooseMesh.C:1444
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
NearestNodeLocator & _nearest_node
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...
static InputParameters validParams()
Definition: AuxKernel.C:27
const std::vector< BoundaryName > & boundaryNames() const
Return the boundary names for this object.