https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
56Real
58{
59 RealVectorValue n;
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}
registerMooseObjectRenamed("MooseApp", PorousFlowElementNormal, "06/30/2027 24:00", ElementNormalAux)
registerMooseObject("MooseApp", ElementNormalAux)
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition AuxKernel.h:133
static InputParameters validParams()
Definition AuxKernel.C:27
Computes a component of the normal of elements.
ElementNormalAux(const InputParameters &parameters)
const RealVectorValue _3D_default
Value used for 3D elements.
static InputParameters validParams()
virtual Real computeValue() override
Compute and return the value of the aux variable.
const RealVectorValue _1D_perp
For 1D elements, the value computed will be perpendicular to this vector.
const unsigned _component
Desired component.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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 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:457
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const