hummingbird
Solving the self-adjoint angular flux transport equation using spectral elements on Cartesian geometry
Loading...
Searching...
No Matches
ordinate.cc
Go to the documentation of this file.
2
3#include <cmath>
4#include <stdexcept>
5
6namespace hummingbird {
7Ordinate::Ordinate(const double azimuth, const double polar)
10}
11
13 const arma::vec3 surface_normal) {
14 arma::vec3 initial_direction = ordinate.CartesianUnitVector();
15 arma::vec3 new_direction =
16 initial_direction -
17 2.0 * arma::dot(initial_direction, surface_normal) * surface_normal;
18 arma::vec3 normalized_direction = arma::normalise(new_direction);
19 return Ordinate(std::atan2(normalized_direction(1), normalized_direction(0)),
20 std::acos(normalized_direction(2)));
21}
22
23void Ordinate::CheckInput(const double azimuth, const double polar) {
24 if (polar > M_PI) throw std::invalid_argument("Polar angle must be <= pi.");
25 if (polar < 0) throw std::invalid_argument("Polar angle must be >= 0.");
26 if (azimuth > M_PI)
27 throw std::invalid_argument("Azimuthal angle must be <= pi.");
28 if (azimuth < -M_PI)
29 throw std::invalid_argument("Azimuthal angle must be >= 0.");
30}
31
32double Ordinate::x() const { return std::cos(azimuth_) * std::sin(polar_); }
33
34double Ordinate::y() const { return std::sin(azimuth_) * std::sin(polar_); }
35
36double Ordinate::z() const { return std::cos(polar_); }
37
39 arma::vec3 vec3;
40 vec3(0) = this->x();
41 vec3(1) = this->y();
42 vec3(2) = this->z();
43 return vec3;
44}
45} // namespace hummingbird
Ordinate(const double azimuth, const double polar)
Construct a new Ordinate object.
Definition ordinate.cc:7
const double polar_
Polar angle in radians.
Definition ordinate.h:82
const double azimuth_
Azimuthal angle in radians.
Definition ordinate.h:79
double polar() const
Getter for polar angle.
Definition ordinate.h:47
double x() const
Evaluate the x-direction cosine.
Definition ordinate.cc:32
double azimuth() const
Getter for azimuthal angle.
Definition ordinate.h:40
double y() const
Evaluate the y-direction cosine.
Definition ordinate.cc:34
arma::vec3 CartesianUnitVector() const
Returns the Ordinate as a Cartesian unit vector.
Definition ordinate.cc:38
void CheckInput(const double azimuth, const double polar)
Check that input angles are within expected bounds.
Definition ordinate.cc:23
static Ordinate Reflect(const Ordinate &ordinate, const arma::vec3 surface_normal)
Construct a new Ordinate object in the reflected direction given a starting direction and surface nor...
Definition ordinate.cc:12
double z() const
Evaluate the z-direction cosine.
Definition ordinate.cc:36