https://mooseframework.inl.gov
PorousFlowElementLength.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
11 
13 
16 {
18 
19  params.addCoupledVar("direction",
20  "Direction (3-component vector) along which to compute the length. This "
21  "may be 3 real numbers, or 3 variables.");
22 
23  params.addClassDescription(
24  "AuxKernel to compute the 'length' of elements along a given direction. A plane is "
25  "constructed through the element's centroid, with normal equal to the direction given. The "
26  "average of the distance of the nodal positions to this plane is the 'length' returned. The "
27  "Variable for this AuxKernel must be an elemental Variable");
28 
29  return params;
30 }
31 
33  : AuxKernel(parameters),
34  _num_direction(coupledComponents("direction")),
35  _direction_x(coupledValue("direction", 0)),
36  // if _num_direction!=3,an informative error message is produced below
37  _direction_y(coupledValue("direction", std::min(_num_direction - 1, (unsigned)1))),
38  _direction_z(coupledValue("direction", std::min(_num_direction - 1, (unsigned)2)))
39 {
40  if (isNodal())
41  paramError("variable", "The variable must be an elemental variable");
42  if (_num_direction != 3)
43  paramError("direction", "Three values or variables must be provided");
44 }
45 
46 Real
48 {
49  const auto direction =
51  const auto centroid = _current_elem->vertex_average();
52  Real length = 0.0;
53  for (const auto & node : _current_elem->node_ref_range())
54  length += std::abs((node - centroid) * direction);
55  length /= _current_elem->n_nodes();
56  return length;
57 }
Computes a measure of element length.
const VariableValue & _direction_z
z component of direction along which the element length is calculated
const VariableValue & _direction_y
y component of direction along which the element length is calculated
const VariableValue & _direction_x
x component of direction along which the element length is calculated
registerMooseObject("PorousFlowApp", PorousFlowElementLength)
TypeVector< Real > unit() const
void paramError(const std::string &param, Args... args) const
void addCoupledVar(const std::string &name, const std::string &doc_string)
const unsigned _num_direction
number of direction components provided (needs to be 3)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeValue() override
const Elem *const & _current_elem
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static InputParameters validParams()
auto min(const L &left, const R &right)
PorousFlowElementLength(const InputParameters &parameters)