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 
17 template <>
20 {
22  params.addClassDescription(
23  "Stores the distance between a block and boundary or between two boundaries.");
24  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to find the distance to.");
25  params.set<bool>("use_displaced_mesh") = true;
26  return params;
27 }
28 
30  : AuxKernel(parameters),
31  _nearest_node(_nodal ? getNearestNodeLocator(parameters.get<BoundaryName>("paired_boundary"),
32  boundaryNames()[0])
33  : getQuadratureNearestNodeLocator(
34  parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0]))
35 {
36  if (boundaryNames().size() > 1)
37  mooseError("NearestNodeDistanceAux can only be used with one boundary at a time!");
38 }
39 
40 Real
42 {
43  if (_nodal)
44  return _nearest_node.distance(_current_node->id());
45 
47 
48  return _nearest_node.distance(qnode->id());
49 }
registerMooseObject("MooseApp", NearestNodeDistanceAux)
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:170
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:205
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:190
Computes the distance from a block or boundary to another boundary.
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.
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 mooseError(Args &&... args) const
Definition: MooseObject.h:147
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.
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:25
InputParameters validParams< NearestNodeDistanceAux >()
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:977
NearestNodeLocator & _nearest_node
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33
const std::vector< BoundaryName > & boundaryNames() const
Return the boundary names for this object.