Add comments to periodic BC implementation

This commit is contained in:
Sterling Harper 2020-10-26 22:15:20 -06:00
parent 1af80b1d39
commit 5fb806bcb5
2 changed files with 18 additions and 0 deletions

View file

@ -241,12 +241,26 @@ public:
void cross_surface();
//! Cross a vacuum boundary condition.
//
//! \param surf The surface (with the vacuum boundary condition) that the
//! particle struck.
void cross_vacuum_bc(const Surface& surf);
//! Cross a reflective boundary condition.
//
//! \param surf The surface (with the reflective boundary condition) that the
//! particle struck.
//! \param new_u The direction of the particle after reflection.
void cross_reflective_bc(const Surface& surf, Direction new_u);
//! Cross a periodic boundary condition.
//
//! \param surf The surface (with the periodic boundary condition) that the
//! particle struck.
//! \param new_r The position of the particle after translation/rotation.
//! \param new_u The direction of the particle after translation/rotation.
//! \param new_surface The signed index of the surface that the particle will
//! reside on after translation/rotation.
void cross_periodic_bc(const Surface& surf, Position new_r, Direction new_u,
int new_surface);

View file

@ -1148,10 +1148,14 @@ void read_surfaces(pugi::xml_node node)
Surface& surf1 {*model::surfaces[i_surf]};
Surface& surf2 {*model::surfaces[j_surf]};
// Compute the dot product of the surface normals
Direction norm1 = surf1.normal({0, 0, 0});
Direction norm2 = surf2.normal({0, 0, 0});
double dot_prod = norm1.dot(norm2);
// If the dot product is 1 (to within floating point precision) then the
// planes are parallel which indicates a translational periodic boundary
// condition. Otherwise, it is a rotational periodic BC.
if (std::abs(1.0 - dot_prod) < FP_PRECISION) {
surf1.bc_ = std::make_shared<TranslationalPeriodicBC>(i_surf, j_surf);
surf2.bc_ = surf1.bc_;