Skip to content

Commit

Permalink
Geometron (#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
gridley committed Jan 16, 2024
1 parent 971c5f7 commit 5549b58
Show file tree
Hide file tree
Showing 16 changed files with 403 additions and 284 deletions.
14 changes: 8 additions & 6 deletions include/openmc/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ constexpr int32_t OP_UNION {std::numeric_limits<int32_t>::max() - 4};
//==============================================================================

class Cell;
class GeometryState;
class ParentCell;
class CellInstance;
class Universe;
Expand Down Expand Up @@ -82,7 +83,7 @@ class Region {

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

//! Get the BoundingBox for this cell.
BoundingBox bounding_box(int32_t cell_id) const;
Expand Down Expand Up @@ -183,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, Particle* 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 @@ -260,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, Particle& 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 @@ -332,10 +334,10 @@ 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, Particle* 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, p);
return region_.distance(r, u, on_surface);
}

bool contains(Position r, Direction u, int32_t on_surface) const override
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, Particle* 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, Particle* 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(Particle& p) const override;
bool find_cell(GeometryState& p) const override;

void to_hdf5(hid_t universes_group) const override;

Expand Down
16 changes: 9 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 Particle;
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(Particle& 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(Particle& p, bool error = true);
//! should be computed. \return The instance of the cell at the specified level.
//==============================================================================

int cell_instance_at_level(const Particle& 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,20 +60,22 @@ int cell_instance_at_level(const Particle& 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(Particle& p);
bool neighbor_list_find_cell(Particle& p); // Only usable on surface crossings
bool exhaustive_find_cell(GeometryState& p, bool verbose = false);
bool neighbor_list_find_cell(
GeometryState& p, bool verbose = false); // Only usable on surface crossings

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

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

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

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

} // namespace openmc

Expand Down
14 changes: 2 additions & 12 deletions include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! \brief Particle type

#include <cstdint>
#include <sstream>
#include <string>

#include "openmc/constants.h"
Expand Down Expand Up @@ -103,17 +102,8 @@ class Particle : public ParticleData {

//! mark a particle as lost and create a particle restart file
//! \param message A warning message to display
void mark_as_lost(const char* message);

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

void mark_as_lost(const std::stringstream& message)
{
mark_as_lost(message.str());
}
virtual void mark_as_lost(const char* message) override;
using GeometryState::mark_as_lost;

//! create a particle restart HDF5 file
void write_restart() const;
Expand Down

0 comments on commit 5549b58

Please sign in to comment.