https://mooseframework.inl.gov
ElementNormalAux.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 
10 #include "ElementNormalAux.h"
11 
14  PorousFlowElementNormal,
15  "06/30/2027 24:00",
17 
20 {
22  MooseEnum component("x=0 y=1 z=2");
23  params.addRequiredParam<MooseEnum>("component", component, "The component to compute");
24 
25  params.addParam<RealVectorValue>("3D_default",
26  RealVectorValue(0, 0, 1),
27  "The value that will be produced for 3D elements, since such "
28  "elements do not have a 'normal direction'");
29  params.addParam<RealVectorValue>(
30  "1D_perp",
31  RealVectorValue(0, 0, 1),
32  "The normal for all 1D elements will be perpendicular to this vector");
33 
34  params.addClassDescription(
35  "AuxKernel to compute components of the element normal. This is mostly designed for 2D "
36  "elements living in 3D space, however, the 1D-element and 3D-element cases are handled as "
37  "special cases. The Variable for this AuxKernel must be an elemental Variable");
38 
39  return params;
40 }
41 
43  : AuxKernel(parameters),
44  _component(getParam<MooseEnum>("component")),
45  _1D_perp(getParam<RealVectorValue>("1D_perp")),
46  _3D_default(getParam<RealVectorValue>("3D_default"))
47 {
48  if (isNodal())
49  paramError("variable", "The variable must be an elemental variable");
50  if (_1D_perp.norm() == 0.0)
51  paramError("1D_perp", "Must not be the zero vector");
52  if (_3D_default.norm() == 0.0)
53  paramError("3D_default", "Must not be the zero vector");
54 }
55 
56 Real
58 {
60  const auto num_nodes = _current_elem->n_nodes();
61  switch (_current_elem->dim())
62  {
63  case 1:
64  {
65  for (unsigned i = 0; i < num_nodes - 1; ++i)
66  {
67  RealVectorValue v = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i);
68  n += v.cross(_1D_perp);
69  }
70  break;
71  }
72  case 2:
73  {
74  for (unsigned i = 0; i < num_nodes - 2; ++i)
75  {
76  RealVectorValue v1 = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i);
77  RealVectorValue v2 =
78  _current_elem->point((i + 2) % num_nodes) - _current_elem->point((i + 1) % num_nodes);
79  n += v1.cross(v2);
80  }
81  break;
82  }
83  default:
84  n = _3D_default;
85  }
86  return n.unit()(_component);
87 }
static InputParameters validParams()
Computes a component of the normal of elements.
auto norm() const
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:467
registerMooseObjectRenamed("MooseApp", PorousFlowElementNormal, "06/30/2027 24:00", ElementNormalAux)
const RealVectorValue _1D_perp
For 1D elements, the value computed will be perpendicular to this vector.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", ElementNormalAux)
ElementNormalAux(const InputParameters &parameters)
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...
TypeVector< Real > unit() const
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const RealVectorValue _3D_default
Value used for 3D elements.
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:128
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:17
const unsigned _component
Desired component.
virtual Real computeValue() override
Compute and return the value of the aux variable.
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:43