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