From 2fa449de5ad92110cdfc93537a50dc9a3d33567f Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Sun, 18 Oct 2020 12:19:46 -0600 Subject: [PATCH] Remove the PeriodicSurface class --- include/openmc/surface.h | 32 ++++---------------------------- src/boundary_condition.cpp | 20 ++++++++++++++++++++ src/particle.cpp | 5 ----- src/surface.cpp | 22 ++++------------------ 4 files changed, 28 insertions(+), 51 deletions(-) diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 4de7fd6ac8..14fbe047b0 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -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_; }; diff --git a/src/boundary_condition.cpp b/src/boundary_condition.cpp index 5f1b0d68a5..a1bd8721a0 100644 --- a/src/boundary_condition.cpp +++ b/src/boundary_condition.cpp @@ -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) { diff --git a/src/particle.cpp b/src/particle.cpp index a7532f8c98..b2e4013502 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -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(&surf); - auto other = dynamic_cast( - model::surfaces[surf_p->i_periodic_].get()); - // Adjust the particle's location and direction. r() = new_r; u() = new_u; diff --git a/src/surface.cpp b/src/surface.cpp index 9b270472cc..5eba9d2100 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -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(i_surf, j_surf); surf2.new_bc_ = surf1.new_bc_; } - - dynamic_cast(&surf1)->i_periodic_ = j_surf; - dynamic_cast(&surf2)->i_periodic_ = i_surf; } // Check to make sure a boundary condition was applied to at least one