16 #include "libmesh/dense_vector.h" 19 const unsigned int polar_order,
20 const unsigned int azimuthal_order,
24 _polar_order(polar_order),
25 _azimuthal_order(azimuthal_order),
30 mooseError(
"polar_order must be positive in RayTracingAngularQuadrature");
32 mooseError(
"azimuthal_order must be positive in RayTracingAngularQuadrature");
34 mooseError(
"mu_min must be < mu_max in RayTracingAngularQuadrature");
36 mooseError(
"mu_min must be >= -1 in RayTracingAngularQuadrature");
38 mooseError(
"mu_max must be <= 1 in RayTracingAngularQuadrature");
40 mooseError(
"RayTracingAngularQuadrature only supports dimensions 2 and 3");
58 std::vector<Real> gauss_legendre_x;
59 std::vector<Real> gauss_legendre_w;
67 for (std::size_t i = 0; i < chebyshev_x.size(); ++i)
68 for (std::size_t
j = 0;
j < gauss_legendre_x.size(); ++
j)
71 if (
_dim == 2 && gauss_legendre_x[
j] < 0.5 - TOLERANCE * TOLERANCE)
74 _phi.push_back(chebyshev_x[i]);
78 const Real weight_factor =
80 _w.push_back(weight_factor * chebyshev_w[i] * gauss_legendre_w[
j]);
86 std::vector<Real> &
x,
87 std::vector<Real> & w)
90 mooseError(
"Order must be positive in gaussLegendre()");
99 for (
unsigned int i = 1; i < order; ++i)
102 mat(i, i - 1) = ri / std::sqrt(((2. * ri - 1.) * (2. * ri + 1.)));
103 mat(i - 1, i) = mat(i, i - 1);
107 for (
unsigned int i = 0; i < order; ++i)
109 x[i] = 0.5 * (lambda(i) + 1.0);
110 w[i] = vec(0, i) * vec(0, i);
114 std::vector<std::size_t> sorted_indices(
x.size());
115 std::iota(sorted_indices.begin(), sorted_indices.end(), 0);
116 std::stable_sort(sorted_indices.begin(),
117 sorted_indices.end(),
118 [&
x](
size_t i1,
size_t i2) {
return x[i1] <
x[i2]; });
119 const auto x_copy =
x;
120 const auto w_copy = w;
121 for (std::size_t i = 0; i <
x.size(); ++i)
123 x[i] = x_copy[sorted_indices[i]];
124 w[i] = w_copy[sorted_indices[i]];
149 for (std::size_t q = 0; q <
_phi.size(); ++q)
158 direction(0) = omega_p(0);
159 direction(1) = omega_p(1);
160 direction(2) = omega_p(2);
175 direction /= direction.norm();
194 mooseAssert(
_dim == 2,
"Should only have duplicates in 2D");
209 const std::vector<Real> &
223 const std::vector<Real> &
243 mooseError(
"RayTracingAngularQuadrature does not have direction ", l);
248 std::vector<Real> &
x,
249 std::vector<Real> & w)
254 for (std::size_t i = 0; i < order; ++i)
257 w[i] = 2 * M_PI / (
Real)order;
273 for (
unsigned int j = 0;
j < 3; ++
j)
275 matrix(
j, 0) = tx(
j);
276 matrix(
j, 1) = ty(
j);
277 matrix(
j, 2) = direction(
j);
285 ::mooseError(
"Vector v has norm close to 0 in orthonormalVector()");
static void gaussLegendre(const unsigned int order, std::vector< Real > &x, std::vector< Real > &w)
Builds Gauss-Legendre quadrature on 0, 1, with weights that sum to 1.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void mooseError(Args &&... args)
virtual void zero() override final
std::vector< std::vector< Real > > _current_polar_sins
const unsigned int _polar_order
The polar order.
static void chebyshev(const unsigned int order, std::vector< Real > &x, std::vector< Real > &w)
Builds Chebyshev quadrature on [0, 2] with weights that sum to 2.
std::vector< Real > _phi
Quadrature phi.
std::vector< Real > _mu
Quadrature mu.
const libMesh::Point & getDirection(const unsigned int l) const
Get the direction associated with direction l.
const Real _mu_min
The minimum mu.
std::vector< Real > _w
Quadrature combined weights.
TypeVector< Real > unit() const
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
void build()
Build the quadrature.
const std::vector< double > x
std::vector< libMesh::Point > _current_directions
The current quadrature information.
libMesh::Point _current_rotation_direction
The current rotation direction.
void evd_right(DenseVector< T > &lambda_real, DenseVector< T > &lambda_imag, DenseMatrix< T > &VR)
std::vector< std::vector< Real > > _current_weights
std::size_t numPolar(const unsigned int l) const
The number of polar directions associated with the given direction.
const unsigned int _azimuthal_order
The azimuthal order.
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
static void rotationMatrix(const libMesh::Point &direction, libMesh::DenseMatrix< Real > &matrix)
Builds the rotation matrix for direction direction into matrix.
const Real _mu_max
The maximum mu.
unsigned int dim() const
Get the quadrature dimension.
bool hasDirection(const unsigned int l) const
Whether or not the angular quadrature has direction l.
Real getTotalWeight(const unsigned int l) const
Gets the total of the weights associated with the direction l.
bool absolute_fuzzy_equals(const T &var1, const T2 &var2, const Real tol=TOLERANCE *TOLERANCE)
void rotate(const libMesh::Point &rotation_direction)
Rotates the quadrature to a given direction.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
const std::vector< Real > & getPolarSins(const unsigned int l) const
Gets the polar sins for the direction l.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
bool absoluteFuzzyLessEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void resize(const unsigned int new_m, const unsigned int new_n)
static libMesh::Point orthonormalVector(const libMesh::Point &v)
Gets the vector that is orthonormal to v.
void checkDirection(const unsigned int l) const
Throws a MooseError if the angular quadrature does not have direction l.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const std::vector< Real > & getWeights(const unsigned int l) const
Get the weights associated with the direction l.
RayTracingAngularQuadrature(const unsigned int dim, const unsigned int polar_order, const unsigned int azimuthal_order, const Real mu_min, const Real mu_max)
Constructor.
const unsigned int _dim
The dimension.
std::vector< Real > _polar_sin
Quadrature polar sin.
void vector_mult(DenseVector< T > &dest, const DenseVector< T > &arg) const