Apply suggestions from code review

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Sterling Harper 2020-10-26 21:31:26 -06:00 committed by GitHub
parent fb8bae8e9e
commit 1af80b1d39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 23 deletions

View file

@ -13,13 +13,12 @@ class Surface;
//! A class that tells particles what to do after they strike an outer boundary.
//==============================================================================
class BoundaryCondition
{
class BoundaryCondition {
public:
//! Perform tracking operations for a particle that strikes the boundary.
//! \param p The particle that struck the boundary. This class is not meant
//! to directly modify anything about the particle, but it will do so
//! indirectly by calling the particle's appropriate cross*bc function.
//! indirectly by calling the particle's appropriate cross_*_bc function.
//! \param surf The specific surface on the boundary the particle struck.
virtual void
handle_particle(Particle& p, const Surface& surf) const = 0;
@ -32,8 +31,7 @@ public:
//! A BC that kills particles, indicating they left the problem.
//==============================================================================
class VacuumBC : public BoundaryCondition
{
class VacuumBC : public BoundaryCondition {
public:
void
handle_particle(Particle& p, const Surface& surf) const override;
@ -45,8 +43,7 @@ public:
//! A BC that returns particles via specular reflection.
//==============================================================================
class ReflectiveBC : public BoundaryCondition
{
class ReflectiveBC : public BoundaryCondition {
public:
void
handle_particle(Particle& p, const Surface& surf) const override;
@ -58,8 +55,7 @@ public:
//! A BC that returns particles via diffuse reflection.
//==============================================================================
class WhiteBC : public BoundaryCondition
{
class WhiteBC : public BoundaryCondition {
public:
void
handle_particle(Particle& p, const Surface& surf) const override;
@ -71,8 +67,7 @@ public:
//! A BC that moves particles to another part of the problem.
//==============================================================================
class PeriodicBC : public BoundaryCondition
{
class PeriodicBC : public BoundaryCondition {
public:
PeriodicBC(int i_surf, int j_surf)
: i_surf_(i_surf), j_surf_(j_surf)
@ -89,8 +84,7 @@ protected:
//! A BC that moves particles to another part of the problem without rotation.
//==============================================================================
class TranslationalPeriodicBC : public PeriodicBC
{
class TranslationalPeriodicBC : public PeriodicBC {
public:
TranslationalPeriodicBC(int i_surf, int j_surf);
@ -108,8 +102,7 @@ protected:
//! Currently only rotations about the z-axis are supported.
//==============================================================================
class RotationalPeriodicBC : public PeriodicBC
{
class RotationalPeriodicBC : public PeriodicBC {
public:
RotationalPeriodicBC(int i_surf, int j_surf);

View file

@ -190,12 +190,12 @@ RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf)
// Make sure both surfaces intersect the origin
if (std::abs(surf1.evaluate({0, 0, 0})) > FP_COINCIDENT) {
throw std::invalid_argument(fmt::format("Rotational periodic BCs are only "
"supported for rotations about the origin, but surface{} does not "
"supported for rotations about the origin, but surface {} does not "
"intersect the origin.", surf1.id_));
}
if (std::abs(surf2.evaluate({0, 0, 0})) > FP_COINCIDENT) {
throw std::invalid_argument(fmt::format("Rotational periodic BCs are only "
"supported for rotations about the origin, but surface{} does not "
"supported for rotations about the origin, but surface {} does not "
"intersect the origin.", surf2.id_));
}
@ -253,14 +253,16 @@ RotationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
// Rotate the particle's position and direction about the z-axis.
Position r = p.r();
Direction u = p.u();
double cos_theta = std::cos(theta);
double sin_theta = std::sin(theta);
Position new_r = {
std::cos(theta)*r[0] - std::sin(theta)*r[1],
std::sin(theta)*r[0] + std::cos(theta)*r[1],
r[2]};
cos_theta*r.x - sin_theta*r.y,
sin_theta*r.x + cos_theta*r.y,
r.z};
Direction new_u = {
std::cos(theta)*u[0] - std::sin(theta)*u[1],
std::sin(theta)*u[0] + std::cos(theta)*u[1],
u[2]};
cos_theta*u.x - sin_theta*u.y,
sin_theta*u.x + cos_theta*u.y,
u.z};
// Pass the new location, direction, and surface to the particle.
p.cross_periodic_bc(surf, new_r, new_u, new_surface);