Remove the PeriodicSurface class

This commit is contained in:
Sterling Harper 2020-10-18 12:19:46 -06:00
parent 8e6842dfc5
commit 2fa449de5a
4 changed files with 28 additions and 51 deletions

View file

@ -143,7 +143,6 @@ public:
//! Write all information needed to reconstruct the surface to an HDF5 group.
//! \param group_id An HDF5 group id.
//TODO: this probably needs to include i_periodic for PeriodicSurface
virtual void to_hdf5(hid_t group_id) const = 0;
//! Get the BoundingBox for this surface.
@ -182,21 +181,6 @@ public:
int32_t dag_index_; //!< DagMC index of surface
};
#endif
//==============================================================================
//! A `Surface` that supports periodic boundary conditions.
//!
//! Translational periodicity is supported for the `XPlane`, `YPlane`, `ZPlane`,
//! and `Plane` types. Rotational periodicity is supported for
//! `XPlane`-`YPlane` pairs.
//==============================================================================
class PeriodicSurface : public CSGSurface
{
public:
int i_periodic_{C_NONE}; //!< Index of corresponding periodic surface
explicit PeriodicSurface(pugi::xml_node surf_node);
};
//==============================================================================
//! A plane perpendicular to the x-axis.
@ -204,7 +188,7 @@ public:
//! The plane is described by the equation \f$x - x_0 = 0\f$
//==============================================================================
class SurfaceXPlane : public PeriodicSurface
class SurfaceXPlane : public CSGSurface
{
public:
explicit SurfaceXPlane(pugi::xml_node surf_node);
@ -212,8 +196,6 @@ public:
double distance(Position r, Direction u, bool coincident) const;
Direction normal(Position r) const;
void to_hdf5_inner(hid_t group_id) const;
bool periodic_translate(const PeriodicSurface* other, Position& r,
Direction& u) const;
BoundingBox bounding_box(bool pos_side) const;
double x0_;
@ -225,7 +207,7 @@ public:
//! The plane is described by the equation \f$y - y_0 = 0\f$
//==============================================================================
class SurfaceYPlane : public PeriodicSurface
class SurfaceYPlane : public CSGSurface
{
public:
explicit SurfaceYPlane(pugi::xml_node surf_node);
@ -233,8 +215,6 @@ public:
double distance(Position r, Direction u, bool coincident) const;
Direction normal(Position r) const;
void to_hdf5_inner(hid_t group_id) const;
bool periodic_translate(const PeriodicSurface* other, Position& r,
Direction& u) const;
BoundingBox bounding_box(bool pos_side) const;
double y0_;
@ -246,7 +226,7 @@ public:
//! The plane is described by the equation \f$z - z_0 = 0\f$
//==============================================================================
class SurfaceZPlane : public PeriodicSurface
class SurfaceZPlane : public CSGSurface
{
public:
explicit SurfaceZPlane(pugi::xml_node surf_node);
@ -254,8 +234,6 @@ public:
double distance(Position r, Direction u, bool coincident) const;
Direction normal(Position r) const;
void to_hdf5_inner(hid_t group_id) const;
bool periodic_translate(const PeriodicSurface* other, Position& r,
Direction& u) const;
BoundingBox bounding_box(bool pos_side) const;
double z0_;
@ -267,7 +245,7 @@ public:
//! The plane is described by the equation \f$A x + B y + C z - D = 0\f$
//==============================================================================
class SurfacePlane : public PeriodicSurface
class SurfacePlane : public CSGSurface
{
public:
explicit SurfacePlane(pugi::xml_node surf_node);
@ -275,8 +253,6 @@ public:
double distance(Position r, Direction u, bool coincident) const;
Direction normal(Position r) const;
void to_hdf5_inner(hid_t group_id) const;
bool periodic_translate(const PeriodicSurface* other, Position& r,
Direction& u) const;
double A_, B_, C_, D_;
};

View file

@ -9,12 +9,20 @@
namespace openmc {
//==============================================================================
// VacuumBC implementation
//==============================================================================
void
VacuumBC::handle_particle(Particle& p, const Surface& surf) const
{
p.cross_vacuum_bc(surf);
}
//==============================================================================
// ReflectiveBC implementation
//==============================================================================
void
ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const
{
@ -24,6 +32,10 @@ ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const
p.cross_reflective_bc(surf, u);
}
//==============================================================================
// WhiteBC implementation
//==============================================================================
void
WhiteBC::handle_particle(Particle& p, const Surface& surf) const
{
@ -33,6 +45,10 @@ WhiteBC::handle_particle(Particle& p, const Surface& surf) const
p.cross_reflective_bc(surf, u);
}
//==============================================================================
// TranslationalPeriodicBC implementation
//==============================================================================
TranslationalPeriodicBC::TranslationalPeriodicBC(int i_surf, int j_surf)
: PeriodicBC(i_surf, j_surf)
{
@ -102,6 +118,10 @@ TranslationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
p.cross_periodic_bc(surf, new_r, p.u(), new_surface);
}
//==============================================================================
// RotationalPeriodicBC implementation
//==============================================================================
RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf)
: PeriodicBC(i_surf, j_surf)
{

View file

@ -577,11 +577,6 @@ Particle::cross_periodic_bc(const Surface& surf, Position new_r,
this->r() = r;
}
// Get a pointer to the partner periodic surface
auto surf_p = dynamic_cast<const PeriodicSurface*>(&surf);
auto other = dynamic_cast<const PeriodicSurface*>(
model::surfaces[surf_p->i_periodic_].get());
// Adjust the particle's location and direction.
r() = new_r;
u() = new_u;

View file

@ -293,17 +293,6 @@ Direction DAGSurface::reflect(Position r, Direction u, Particle* p) const
void DAGSurface::to_hdf5(hid_t group_id) const {}
#endif
//==============================================================================
// PeriodicSurface implementation
//==============================================================================
PeriodicSurface::PeriodicSurface(pugi::xml_node surf_node)
: CSGSurface {surf_node}
{
if (check_for_node(surf_node, "periodic_surface_id")) {
i_periodic_ = std::stoi(get_node_value(surf_node, "periodic_surface_id"));
}
}
//==============================================================================
// Generic functions for x-, y-, and z-, planes.
@ -325,7 +314,7 @@ axis_aligned_plane_distance(Position r, Direction u, bool coincident, double off
//==============================================================================
SurfaceXPlane::SurfaceXPlane(pugi::xml_node surf_node)
: PeriodicSurface(surf_node)
: CSGSurface(surf_node)
{
read_coeffs(surf_node, id_, x0_);
}
@ -367,7 +356,7 @@ SurfaceXPlane::bounding_box(bool pos_side) const
//==============================================================================
SurfaceYPlane::SurfaceYPlane(pugi::xml_node surf_node)
: PeriodicSurface(surf_node)
: CSGSurface(surf_node)
{
read_coeffs(surf_node, id_, y0_);
}
@ -409,7 +398,7 @@ SurfaceYPlane::bounding_box(bool pos_side) const
//==============================================================================
SurfaceZPlane::SurfaceZPlane(pugi::xml_node surf_node)
: PeriodicSurface(surf_node)
: CSGSurface(surf_node)
{
read_coeffs(surf_node, id_, z0_);
}
@ -451,7 +440,7 @@ SurfaceZPlane::bounding_box(bool pos_side) const
//==============================================================================
SurfacePlane::SurfacePlane(pugi::xml_node surf_node)
: PeriodicSurface(surf_node)
: CSGSurface(surf_node)
{
read_coeffs(surf_node, id_, A_, B_, C_, D_);
}
@ -1190,9 +1179,6 @@ void read_surfaces(pugi::xml_node node)
surf1.new_bc_ = std::make_shared<RotationalPeriodicBC>(i_surf, j_surf);
surf2.new_bc_ = surf1.new_bc_;
}
dynamic_cast<PeriodicSurface*>(&surf1)->i_periodic_ = j_surf;
dynamic_cast<PeriodicSurface*>(&surf2)->i_periodic_ = i_surf;
}
// Check to make sure a boundary condition was applied to at least one