https://mooseframework.inl.gov
PorousFlowElementNormal.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  MooseEnum component("x=0 y=1 z=2");
19  params.addRequiredParam<MooseEnum>("component", component, "The component to compute");
20 
21  params.addParam<RealVectorValue>("3D_default",
22  RealVectorValue(0, 0, 1),
23  "The value that will be produced for 3D elements, since such "
24  "elements do not have a 'normal direction'");
25  params.addParam<RealVectorValue>(
26  "1D_perp",
27  RealVectorValue(0, 0, 1),
28  "The normal for all 1D elements will be perpendicular to this vector");
29 
30  params.addClassDescription(
31  "AuxKernel to compute components of the element normal. This is mostly designed for 2D "
32  "elements living in 3D space, however, the 1D-element and 3D-element cases are handled as "
33  "special cases. The Variable for this AuxKernel must be an elemental Variable");
34 
35  return params;
36 }
37 
39  : AuxKernel(parameters),
40  _component(getParam<MooseEnum>("component")),
41  _1D_perp(getParam<RealVectorValue>("1D_perp")),
42  _3D_default(getParam<RealVectorValue>("3D_default"))
43 {
44  if (isNodal())
45  paramError("variable", "The variable must be an elemental variable");
46  if (_1D_perp.norm() == 0.0)
47  paramError("1D_perp", "Must not be the zero vector");
48  if (_3D_default.norm() == 0.0)
49  paramError("3D_default", "Must not be the zero vector");
50 }
51 
52 Real
54 {
56  const auto num_nodes = _current_elem->n_nodes();
57  switch (_current_elem->dim())
58  {
59  case 1:
60  {
61  for (unsigned i = 0; i < num_nodes - 1; ++i)
62  {
63  RealVectorValue v = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i);
64  n += v.cross(_1D_perp);
65  }
66  break;
67  }
68  case 2:
69  {
70  for (unsigned i = 0; i < num_nodes - 2; ++i)
71  {
72  RealVectorValue v1 = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i);
73  RealVectorValue v2 =
74  _current_elem->point((i + 2) % num_nodes) - _current_elem->point((i + 1) % num_nodes);
75  n += v1.cross(v2);
76  }
77  break;
78  }
79  default:
80  n = _3D_default;
81  }
82  return n.unit()(_component);
83 }
auto norm() const -> decltype(std::norm(Real()))
const RealVectorValue _1D_perp
For 1D elements, the value computed will be perpendicular to this vector.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static const std::string component
Definition: NS.h:153
void addRequiredParam(const std::string &name, const std::string &doc_string)
const RealVectorValue _3D_default
Value used for 3D elements.
TypeVector< Real > unit() const
registerMooseObject("PorousFlowApp", PorousFlowElementNormal)
void paramError(const std::string &param, Args... args) const
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
static InputParameters validParams()
PorousFlowElementNormal(const InputParameters &parameters)
Computes a component of the normal of elements.
virtual Real computeValue() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
const Elem *const & _current_elem
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const unsigned _component
Desired component.