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 
18 
21 {
23  params.addClassDescription(
24  "Stores the distance between a block and boundary or between two boundaries.");
25  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to find the distance to.");
26  params.set<bool>("use_displaced_mesh") = true;
27  return params;
28 }
29 
31  : AuxKernel(parameters),
32  _nearest_node(_nodal ? getNearestNodeLocator(parameters.get<BoundaryName>("paired_boundary"),
33  boundaryNames()[0])
34  : getQuadratureNearestNodeLocator(
35  parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0]))
36 {
37  if (boundaryNames().size() > 1)
38  mooseError("NearestNodeDistanceAux can only be used with one boundary at a time!");
39 }
40 
41 Real
43 {
44  if (_nodal)
45  return _nearest_node.distance(_current_node->id());
46 
48 
49  return _nearest_node.distance(qnode->id());
50 }
MooseMesh.h
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition: MooseObject.h:141
NearestNodeDistanceAux
Computes the distance from a block or boundary to another boundary.
Definition: NearestNodeDistanceAux.h:24
NearestNodeDistanceAux.h
AuxKernelTempl
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:35
MooseMesh::getQuadratureNode
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
Definition: MooseMesh.C:1009
NearestNodeLocator::distance
Real distance(dof_id_type node_id)
Valid to call this after findNodes() has been called to get the distance to the nearest node.
Definition: NearestNodeLocator.C:230
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
InputParameters::set
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Definition: InputParameters.h:987
NearestNodeDistanceAux::NearestNodeDistanceAux
NearestNodeDistanceAux(const InputParameters &parameters)
Definition: NearestNodeDistanceAux.C:30
AuxKernelTempl::_current_side
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:210
defineLegacyParams
defineLegacyParams(NearestNodeDistanceAux)
AuxKernelTempl::_mesh
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:195
NearestNodeDistanceAux::computeValue
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: NearestNodeDistanceAux.C:42
AuxKernelTempl::_current_elem
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:208
InputParameters::addClassDescription
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.
Definition: InputParameters.C:70
AuxKernelTempl::validParams
static InputParameters validParams()
Definition: AuxKernel.C:28
NearestNodeDistanceAux::_nearest_node
NearestNodeLocator & _nearest_node
Definition: NearestNodeDistanceAux.h:34
AuxKernelTempl::_nodal
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:175
AuxKernelTempl::_current_node
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:218
AuxKernelTempl::_qp
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:227
registerMooseObject
registerMooseObject("MooseApp", NearestNodeDistanceAux)
NearestNodeLocator.h
InputParameters::addRequiredParam
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...
Definition: InputParameters.h:1176
NearestNodeDistanceAux::validParams
static InputParameters validParams()
Definition: NearestNodeDistanceAux.C:20
BoundaryRestrictable::boundaryNames
const std::vector< BoundaryName > & boundaryNames() const
Return the boundary names for this object.
Definition: BoundaryRestrictable.C:176