Skip to content

Commit

Permalink
Geometron -> GeometryState
Browse files Browse the repository at this point in the history
  • Loading branch information
gridley committed Jan 13, 2024
1 parent 926f2ba commit b9ff5d5
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 53 deletions.
11 changes: 6 additions & 5 deletions include/openmc/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ constexpr int32_t OP_UNION {std::numeric_limits<int32_t>::max() - 4};
//==============================================================================

class Cell;
class Geometron;
class GeometryState;
class ParentCell;
class CellInstance;
class Universe;
Expand Down Expand Up @@ -184,7 +184,7 @@ class Cell {

//! Find the oncoming boundary of this cell.
virtual std::pair<double, int32_t> distance(
Position r, Direction u, int32_t on_surface, Geometron* p) const = 0;
Position r, Direction u, int32_t on_surface, GeometryState* p) const = 0;

//! Write all information needed to reconstruct the cell to an HDF5 group.
//! \param group_id An HDF5 group id.
Expand Down Expand Up @@ -261,7 +261,8 @@ class Cell {
//! \param[in] instance of the cell to find parent cells for
//! \param[in] p particle used to do a fast search for parent cells
//! \return parent cells
vector<ParentCell> find_parent_cells(int32_t instance, Geometron& p) const;
vector<ParentCell> find_parent_cells(
int32_t instance, GeometryState& p) const;

//! Determine the path to this cell instance in the geometry hierarchy
//! \param[in] instance of the cell to find parent cells for
Expand Down Expand Up @@ -333,8 +334,8 @@ class CSGCell : public Cell {
// Methods
vector<int32_t> surfaces() const override { return region_.surfaces(); }

std::pair<double, int32_t> distance(
Position r, Direction u, int32_t on_surface, Geometron* p) const override
std::pair<double, int32_t> distance(Position r, Direction u,
int32_t on_surface, GeometryState* p) const override
{
return region_.distance(r, u, on_surface);
}
Expand Down
8 changes: 4 additions & 4 deletions include/openmc/dagmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DAGSurface : public Surface {
double evaluate(Position r) const override;
double distance(Position r, Direction u, bool coincident) const override;
Direction normal(Position r) const override;
Direction reflect(Position r, Direction u, Geometron* p) const override;
Direction reflect(Position r, Direction u, GeometryState* p) const override;

inline void to_hdf5_inner(hid_t group_id) const override {};

Expand All @@ -63,8 +63,8 @@ class DAGCell : public Cell {

bool contains(Position r, Direction u, int32_t on_surface) const override;

std::pair<double, int32_t> distance(
Position r, Direction u, int32_t on_surface, Geometron* p) const override;
std::pair<double, int32_t> distance(Position r, Direction u,
int32_t on_surface, GeometryState* p) const override;

BoundingBox bounding_box() const override;

Expand Down Expand Up @@ -143,7 +143,7 @@ class DAGUniverse : public Universe {
//! string of the ID ranges for entities of dimension \p dim
std::string dagmc_ids_for_dim(int dim) const;

bool find_cell(Geometron& p) const override;
bool find_cell(GeometryState& p) const override;

void to_hdf5(hid_t universes_group) const override;

Expand Down
14 changes: 7 additions & 7 deletions include/openmc/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace openmc {

class BoundaryInfo;
class Geometron;
class GeometryState;

//==============================================================================
// Global variables
Expand Down Expand Up @@ -39,7 +39,7 @@ inline bool coincident(double d1, double d2)
//! Check for overlapping cells at a particle's position.
//==============================================================================

bool check_cell_overlap(Geometron& p, bool error = true);
bool check_cell_overlap(GeometryState& p, bool error = true);

//==============================================================================
//! Get the cell instance for a particle at the specified universe level
Expand All @@ -50,7 +50,7 @@ bool check_cell_overlap(Geometron& p, bool error = true);
//! should be computed. \return The instance of the cell at the specified level.
//==============================================================================

int cell_instance_at_level(const Geometron& p, int level);
int cell_instance_at_level(const GeometryState& p, int level);

//==============================================================================
//! Locate a particle in the geometry tree and set its geometry data fields.
Expand All @@ -60,22 +60,22 @@ int cell_instance_at_level(const Geometron& p, int level);
//! \return True if the particle's location could be found and ascribed to a
//! valid geometry coordinate stack.
//==============================================================================
bool exhaustive_find_cell(Geometron& p, bool verbose = false);
bool exhaustive_find_cell(GeometryState& p, bool verbose = false);
bool neighbor_list_find_cell(
Geometron& p, bool verbose = false); // Only usable on surface crossings
GeometryState& p, bool verbose = false); // Only usable on surface crossings

//==============================================================================
//! Move a particle into a new lattice tile.
//==============================================================================

void cross_lattice(
Geometron& p, const BoundaryInfo& boundary, bool verbose = false);
GeometryState& p, const BoundaryInfo& boundary, bool verbose = false);

//==============================================================================
//! Find the next boundary a particle will intersect.
//==============================================================================

BoundaryInfo distance_to_boundary(Geometron& p);
BoundaryInfo distance_to_boundary(GeometryState& p);

} // namespace openmc

Expand Down
2 changes: 1 addition & 1 deletion include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Particle : public ParticleData {
//! mark a particle as lost and create a particle restart file
//! \param message A warning message to display
virtual void mark_as_lost(const char* message) override;
using Geometron::mark_as_lost;
using GeometryState::mark_as_lost;

//! create a particle restart HDF5 file
void write_restart() const;
Expand Down
8 changes: 4 additions & 4 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ struct BoundaryInfo {
/*
* Contains all geometry state information for a particle.
*/
class Geometron {
class GeometryState {
public:
Geometron();
GeometryState();

/*
* Geometron does not store any ID info, so give some reasonable behavior
* GeometryState does not store any ID info, so give some reasonable behavior
* here. The Particle class redefines this. This is only here for the error
* reporting behavior that occurs in geometry.cpp. The explanation for
* mark_as_lost is the same.
Expand Down Expand Up @@ -380,7 +380,7 @@ class Geometron {
* Algorithms.” Annals of Nuclear Energy 113 (March 2018): 506–18.
* https://doi.org/10.1016/j.anucene.2017.11.032.
*/
class ParticleData : public Geometron {
class ParticleData : public GeometryState {
private:
//==========================================================================
// Data members -- see public: below for descriptions
Expand Down
8 changes: 4 additions & 4 deletions include/openmc/plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct IdData {
IdData(size_t h_res, size_t v_res);

// Methods
void set_value(size_t y, size_t x, const Geometron& p, int level);
void set_value(size_t y, size_t x, const GeometryState& p, int level);
void set_overlap(size_t y, size_t x);

// Members
Expand All @@ -133,7 +133,7 @@ struct PropertyData {
PropertyData(size_t h_res, size_t v_res);

// Methods
void set_value(size_t y, size_t x, const Geometron& p, int level);
void set_value(size_t y, size_t x, const GeometryState& p, int level);
void set_overlap(size_t y, size_t x);

// Members
Expand Down Expand Up @@ -205,7 +205,7 @@ T SlicePlotBase::get_map() const

#pragma omp parallel
{
Geometron p;
GeometryState p;
p.r() = xyz;
p.u() = dir;
p.coord(0).universe = model::root_universe;
Expand Down Expand Up @@ -291,7 +291,7 @@ class ProjectionPlot : public PlottableInterface {
* find a distance to the boundary in a non-standard surface intersection
* check. It's an exhaustive search over surfaces in the top-level universe.
*/
static int advance_to_boundary_from_void(Geometron& p);
static int advance_to_boundary_from_void(GeometryState& p);

/* Checks if a vector of two TrackSegments is equivalent. We define this
* to mean not having matching intersection lengths, but rather having
Expand Down
4 changes: 2 additions & 2 deletions include/openmc/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ class Surface {
//! \param[inout] p Pointer to the particle. Only DAGMC uses this.
//! \return Outgoing direction of the ray
virtual Direction reflect(
Position r, Direction u, Geometron* p = nullptr) const;
Position r, Direction u, GeometryState* p = nullptr) const;

virtual Direction diffuse_reflect(
Position r, Direction u, uint64_t* seed, Geometron* p = nullptr) const;
Position r, Direction u, uint64_t* seed, GeometryState* p = nullptr) const;

//! Evaluate the equation describing the surface.
//!
Expand Down
4 changes: 2 additions & 2 deletions include/openmc/universe.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace openmc {
class DAGUniverse;
#endif

class Geometron;
class GeometryState;
class Universe;
class UniversePartitioner;

Expand All @@ -33,7 +33,7 @@ class Universe {
//! \param group_id An HDF5 group id.
virtual void to_hdf5(hid_t group_id) const;

virtual bool find_cell(Geometron& p) const;
virtual bool find_cell(GeometryState& p) const;

BoundingBox bounding_box() const;

Expand Down
5 changes: 3 additions & 2 deletions src/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,14 +1279,15 @@ vector<ParentCell> Cell::find_parent_cells(
{

// create a temporary particle
Geometron dummy_particle {};
GeometryState dummy_particle {};
dummy_particle.r() = r;
dummy_particle.u() = {0., 0., 1.};

return find_parent_cells(instance, dummy_particle);
}

vector<ParentCell> Cell::find_parent_cells(int32_t instance, Geometron& p) const
vector<ParentCell> Cell::find_parent_cells(
int32_t instance, GeometryState& p) const
{
// look up the particle's location
exhaustive_find_cell(p);
Expand Down
6 changes: 3 additions & 3 deletions src/dagmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ int32_t DAGUniverse::implicit_complement_idx() const
return cell_idx_offset_ + dagmc_instance_->index_by_handle(ic) - 1;
}

bool DAGUniverse::find_cell(Geometron& p) const
bool DAGUniverse::find_cell(GeometryState& p) const
{
// if the particle isn't in any of the other DagMC
// cells, place it in the implicit complement
Expand Down Expand Up @@ -583,7 +583,7 @@ DAGCell::DAGCell(std::shared_ptr<moab::DagMC> dag_ptr, int32_t dag_idx)
};

std::pair<double, int32_t> DAGCell::distance(
Position r, Direction u, int32_t on_surface, Geometron* p) const
Position r, Direction u, int32_t on_surface, GeometryState* p) const
{
// if we've changed direction or we're not on a surface,
// reset the history and update last direction
Expand Down Expand Up @@ -721,7 +721,7 @@ Direction DAGSurface::normal(Position r) const
return dir;
}

Direction DAGSurface::reflect(Position r, Direction u, Geometron* p) const
Direction DAGSurface::reflect(Position r, Direction u, GeometryState* p) const
{
Expects(p);
p->history().reset_to_last_intersection();
Expand Down
16 changes: 8 additions & 8 deletions src/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ vector<int64_t> overlap_check_count;
// Non-member functions
//==============================================================================

bool check_cell_overlap(Geometron& p, bool error)
bool check_cell_overlap(GeometryState& p, bool error)
{
int n_coord = p.n_coord();

Expand Down Expand Up @@ -63,7 +63,7 @@ bool check_cell_overlap(Geometron& p, bool error)

//==============================================================================

int cell_instance_at_level(const Geometron& p, int level)
int cell_instance_at_level(const GeometryState& p, int level)
{
// throw error if the requested level is too deep for the geometry
if (level > model::n_coord_levels) {
Expand Down Expand Up @@ -100,7 +100,7 @@ int cell_instance_at_level(const Geometron& p, int level)
//==============================================================================

bool find_cell_inner(
Geometron& p, const NeighborList* neighbor_list, bool verbose)
GeometryState& p, const NeighborList* neighbor_list, bool verbose)
{
// Find which cell of this universe the particle is in. Use the neighbor list
// to shorten the search if one was provided.
Expand Down Expand Up @@ -259,7 +259,7 @@ bool find_cell_inner(

//==============================================================================

bool neighbor_list_find_cell(Geometron& p, bool verbose)
bool neighbor_list_find_cell(GeometryState& p, bool verbose)
{

// Reset all the deeper coordinate levels.
Expand Down Expand Up @@ -287,7 +287,7 @@ bool neighbor_list_find_cell(Geometron& p, bool verbose)
return found;
}

bool exhaustive_find_cell(Geometron& p, bool verbose)
bool exhaustive_find_cell(GeometryState& p, bool verbose)
{
int i_universe = p.lowest_coord().universe;
if (i_universe == C_NONE) {
Expand All @@ -304,7 +304,7 @@ bool exhaustive_find_cell(Geometron& p, bool verbose)

//==============================================================================

void cross_lattice(Geometron& p, const BoundaryInfo& boundary, bool verbose)
void cross_lattice(GeometryState& p, const BoundaryInfo& boundary, bool verbose)
{
auto& coord {p.lowest_coord()};
auto& lat {*model::lattices[coord.lattice]};
Expand Down Expand Up @@ -364,7 +364,7 @@ void cross_lattice(Geometron& p, const BoundaryInfo& boundary, bool verbose)

//==============================================================================

BoundaryInfo distance_to_boundary(Geometron& p)
BoundaryInfo distance_to_boundary(GeometryState& p)
{
BoundaryInfo info;
double d_lat = INFINITY;
Expand Down Expand Up @@ -465,7 +465,7 @@ BoundaryInfo distance_to_boundary(Geometron& p)
extern "C" int openmc_find_cell(
const double* xyz, int32_t* index, int32_t* instance)
{
Geometron geom_state;
GeometryState geom_state;

geom_state.r() = Position {xyz};
geom_state.u() = {0.0, 0.0, 1.0};
Expand Down
8 changes: 4 additions & 4 deletions src/particle_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

namespace openmc {

void Geometron::mark_as_lost(const std::string& message)
void GeometryState::mark_as_lost(const std::string& message)
{
mark_as_lost(message.c_str());
}

void Geometron::mark_as_lost(const std::stringstream& message)
void GeometryState::mark_as_lost(const std::stringstream& message)
{
mark_as_lost(message.str());
}

void Geometron::mark_as_lost(const char* message)
void GeometryState::mark_as_lost(const char* message)
{
fatal_error(message);
}
Expand All @@ -48,7 +48,7 @@ void LocalCoord::reset()
rotated = false;
}

Geometron::Geometron()
GeometryState::GeometryState()
{
// Create and clear coordinate levels
coord_.resize(model::n_coord_levels);
Expand Down
Loading

0 comments on commit b9ff5d5

Please sign in to comment.