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 "PorousFlowElementNormal.h" 11 : 12 : registerMooseObject("PorousFlowApp", PorousFlowElementNormal); 13 : 14 : InputParameters 15 375 : PorousFlowElementNormal::validParams() 16 : { 17 375 : InputParameters params = AuxKernel::validParams(); 18 750 : MooseEnum component("x=0 y=1 z=2"); 19 750 : params.addRequiredParam<MooseEnum>("component", component, "The component to compute"); 20 : 21 375 : params.addParam<RealVectorValue>("3D_default", 22 375 : 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 375 : params.addParam<RealVectorValue>( 26 : "1D_perp", 27 375 : RealVectorValue(0, 0, 1), 28 : "The normal for all 1D elements will be perpendicular to this vector"); 29 : 30 375 : 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 375 : return params; 36 375 : } 37 : 38 204 : PorousFlowElementNormal::PorousFlowElementNormal(const InputParameters & parameters) 39 : : AuxKernel(parameters), 40 204 : _component(getParam<MooseEnum>("component")), 41 408 : _1D_perp(getParam<RealVectorValue>("1D_perp")), 42 612 : _3D_default(getParam<RealVectorValue>("3D_default")) 43 : { 44 204 : if (isNodal()) 45 2 : paramError("variable", "The variable must be an elemental variable"); 46 202 : if (_1D_perp.norm() == 0.0) 47 2 : paramError("1D_perp", "Must not be the zero vector"); 48 200 : if (_3D_default.norm() == 0.0) 49 2 : paramError("3D_default", "Must not be the zero vector"); 50 198 : } 51 : 52 : Real 53 734640 : PorousFlowElementNormal::computeValue() 54 : { 55 : RealVectorValue n; 56 734640 : const auto num_nodes = _current_elem->n_nodes(); 57 734640 : switch (_current_elem->dim()) 58 : { 59 : case 1: 60 : { 61 720 : for (unsigned i = 0; i < num_nodes - 1; ++i) 62 : { 63 360 : RealVectorValue v = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i); 64 360 : n += v.cross(_1D_perp); 65 : } 66 : break; 67 : } 68 : case 2: 69 : { 70 1468560 : for (unsigned i = 0; i < num_nodes - 2; ++i) 71 : { 72 734760 : RealVectorValue v1 = _current_elem->point((i + 1) % num_nodes) - _current_elem->point(i); 73 : RealVectorValue v2 = 74 734760 : _current_elem->point((i + 2) % num_nodes) - _current_elem->point((i + 1) % num_nodes); 75 734760 : n += v1.cross(v2); 76 : } 77 : break; 78 : } 79 480 : default: 80 480 : n = _3D_default; 81 : } 82 734640 : return n.unit()(_component); 83 : }