Line data Source code
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 : 12 : registerMooseObject("MooseApp", ElementNormalAux); 13 : registerMooseObjectRenamed("MooseApp", 14 : PorousFlowElementNormal, 15 : "06/30/2027 24:00", 16 : ElementNormalAux); 17 : 18 : InputParameters 19 6248 : ElementNormalAux::validParams() 20 : { 21 6248 : InputParameters params = AuxKernel::validParams(); 22 24992 : MooseEnum component("x=0 y=1 z=2"); 23 24992 : params.addRequiredParam<MooseEnum>("component", component, "The component to compute"); 24 : 25 18744 : params.addParam<RealVectorValue>("3D_default", 26 12496 : 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 18744 : params.addParam<RealVectorValue>( 30 : "1D_perp", 31 12496 : RealVectorValue(0, 0, 1), 32 : "The normal for all 1D elements will be perpendicular to this vector"); 33 : 34 6248 : 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 12496 : return params; 40 6248 : } 41 : 42 66 : ElementNormalAux::ElementNormalAux(const InputParameters & parameters) 43 : : AuxKernel(parameters), 44 66 : _component(getParam<MooseEnum>("component")), 45 132 : _1D_perp(getParam<RealVectorValue>("1D_perp")), 46 198 : _3D_default(getParam<RealVectorValue>("3D_default")) 47 : { 48 66 : if (isNodal()) 49 0 : paramError("variable", "The variable must be an elemental variable"); 50 66 : if (_1D_perp.norm() == 0.0) 51 0 : paramError("1D_perp", "Must not be the zero vector"); 52 66 : if (_3D_default.norm() == 0.0) 53 0 : paramError("3D_default", "Must not be the zero vector"); 54 66 : } 55 : 56 : Real 57 168 : ElementNormalAux::computeValue() 58 : { 59 168 : RealVectorValue n; 60 168 : const auto num_nodes = _current_elem->n_nodes(); 61 168 : switch (_current_elem->dim()) 62 : { 63 0 : case 1: 64 : { 65 0 : for (unsigned i = 0; i < num_nodes - 1; ++i) 66 : { 67 0 : RealVectorValue v = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i); 68 0 : n += v.cross(_1D_perp); 69 : } 70 0 : break; 71 : } 72 168 : case 2: 73 : { 74 504 : for (unsigned i = 0; i < num_nodes - 2; ++i) 75 : { 76 336 : RealVectorValue v1 = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i); 77 : RealVectorValue v2 = 78 336 : _current_elem->point((i + 2) % num_nodes) - _current_elem->point((i + 1) % num_nodes); 79 336 : n += v1.cross(v2); 80 : } 81 168 : break; 82 : } 83 0 : default: 84 0 : n = _3D_default; 85 : } 86 168 : return n.unit()(_component); 87 : }