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 : #pragma once 11 : 12 : #include "MooseTypes.h" 13 : #include "InputParameters.h" 14 : #include "libmesh/vector_value.h" 15 : #include "libmesh/tensor_value.h" 16 : 17 : class MooseObject; 18 : 19 : /** 20 : * Defines a discretized line segment in 3D space 21 : */ 22 : class DiscreteLineSegmentInterface 23 : { 24 : public: 25 : DiscreteLineSegmentInterface(const MooseObject * moose_object); 26 : 27 2262 : virtual Point getPosition() const { return _position; } 28 10563 : virtual RealVectorValue getDirection() const { return _dir; } 29 0 : virtual Real getRotation() const { return _rotation; } 30 : 31 83 : virtual Real getNumElems() const { return _n_elem; } 32 283 : virtual Real getLength() const { return _length; } 33 : 34 : /* 35 : * Computes the axial coordinate for a given point in 3-D space. 36 : * 37 : * @param[in] p Point in 3-D space 38 : */ 39 : Real computeAxialCoordinate(const Point & p) const; 40 : 41 : /* 42 : * Computes the radial coordinate from the line axis for a given point in 3-D space. 43 : * 44 : * @param[in] p Point in 3-D space 45 : */ 46 : Real computeRadialCoordinate(const Point & p) const; 47 : 48 : /* 49 : * Gets the axial section index for a given point in 3-D space. 50 : * 51 : * @param[in] p Point in 3-D space 52 : */ 53 : unsigned int getAxialSectionIndex(const Point & p) const; 54 : 55 : /* 56 : * Gets the axial element index for a given element center point in 3-D space. 57 : * 58 : * @param[in] p_center Element center point in 3-D space 59 : */ 60 : unsigned int getAxialElementIndex(const Point & p_center) const; 61 : 62 : /** 63 : * Computes point in 3-D space from a point in reference space. 64 : * 65 : * @param[in] p Point in reference space 66 : */ 67 : Point computeRealPointFromReferencePoint(const Point & p) const; 68 : 69 : /** 70 : * Computes point in reference space from a point in 3-D space. 71 : * 72 : * @param[in] p Point in 3-D space 73 : */ 74 : Point computeReferencePointFromRealPoint(const Point & p) const; 75 : 76 : /** 77 : * Gets an axis MooseEnum for the axis the component is aligned with. 78 : * 79 : * If the axis does not align with the x, y, or z axis, then an invalid 80 : * MooseEnum is returned. 81 : */ 82 : MooseEnum getAlignmentAxis() const; 83 : 84 : /** 85 : * Gets the element boundary coordinates for the aligned axis. 86 : */ 87 : std::vector<Real> getElementBoundaryCoordinates() const; 88 : 89 : protected: 90 : /// Start position of axis in 3-D space 91 : const Point & _position; 92 : /// Unnormalized direction of axis from start position to end position 93 : const RealVectorValue & _dir_unnormalized; 94 : /// Normalized direction of axis from start position to end position 95 : const RealVectorValue _dir; 96 : /// Angle of rotation about the x-axis 97 : const Real & _rotation; 98 : 99 : /// Length of each axial section 100 : std::vector<Real> _lengths; 101 : /// Total axial length 102 : Real _length; 103 : 104 : /// Number of elements in each axial section 105 : const std::vector<unsigned int> & _n_elems; 106 : /// Total number of axial elements 107 : const unsigned int _n_elem; 108 : 109 : /// Number of axial sections 110 : const unsigned int _n_sections; 111 : /// Axial coordinate of the end of each axial section using the line 'position' as the origin 112 : std::vector<Real> _section_end; 113 : 114 : /// Center axial coordinate of each axial element 115 : std::vector<Real> _x_centers; 116 : 117 : /// Direction transformation tensor 118 : const RealTensorValue _R; 119 : /// Rotational transformation tensor about x-axis 120 : const RealTensorValue _Rx; 121 : 122 : /// Inverse direction transformation tensor 123 : const RealTensorValue _R_inv; 124 : /// Inverse rotational transformation tensor about x-axis 125 : const RealTensorValue _Rx_inv; 126 : 127 : /// Name of the MOOSE object 128 : const std::string _moose_object_name_dlsi; 129 : 130 : private: 131 : /** 132 : * Computes a normalized direction vector or reports an error if the zero vector is provided 133 : * 134 : * @param[in] dir_unnormalized Unnormalized direction vector 135 : */ 136 : static RealVectorValue initializeDirectionVector(const RealVectorValue & dir_unnormalized); 137 : 138 : public: 139 : static InputParameters validParams(); 140 : 141 : /** 142 : * Computes the direction transformation tensor 143 : * 144 : * @param[in] dir Direction vector 145 : */ 146 : static RealTensorValue computeDirectionTransformationTensor(const RealVectorValue & dir); 147 : 148 : /** 149 : * Computes the rotation transformation tensor 150 : * 151 : * @param[in] rotation Rotation about the x-axis, in degrees 152 : */ 153 : static RealTensorValue computeXRotationTransformationTensor(const Real & rotation); 154 : 155 : /** 156 : * Computes point in 3-D space from a point in reference space. 157 : * 158 : * @param[in] p Point in reference space 159 : */ 160 : static Point computeRealPointFromReferencePoint(const Point & p, 161 : const RealVectorValue & position, 162 : const RealTensorValue & R, 163 : const RealTensorValue & Rx); 164 : 165 : /** 166 : * Computes point in reference space from a point in 3-D space. 167 : * 168 : * @param[in] p Point in 3-D space 169 : */ 170 : static Point computeReferencePointFromRealPoint(const Point & p, 171 : const RealVectorValue & position, 172 : const RealTensorValue & R_inv, 173 : const RealTensorValue & Rx_inv); 174 : 175 : /** 176 : * Gets an axis MooseEnum for the axis the component is aligned with. 177 : * 178 : * If the axis does not align with the x, y, or z axis, then an invalid 179 : * MooseEnum is returned. 180 : */ 181 : static MooseEnum getAlignmentAxis(const RealVectorValue & dir); 182 : 183 : /** 184 : * Gets the element boundary coordinates for the aligned axis. 185 : * 186 : * @param[in] position Start position of axis in 3-D space 187 : * @param[in] orientation Direction of axis from start position to end position 188 : * @param[in] rotation Angle of rotation about the x-axis, in degrees 189 : * @param[in] lengths Length of each axial section 190 : * @param[in] n_elems Number of elements in each axial section 191 : */ 192 : static std::vector<Real> getElementBoundaryCoordinates(const RealVectorValue & position, 193 : const RealVectorValue & orientation, 194 : const Real & rotation, 195 : const std::vector<Real> & lengths, 196 : const std::vector<unsigned int> & n_elems); 197 : };