Skip to content

Commit

Permalink
Add a new empty surface constant
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Jan 10, 2025
1 parent 1eca46f commit e6f4fd1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
7 changes: 0 additions & 7 deletions include/openmc/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ namespace openmc {

enum class Fill { MATERIAL, UNIVERSE, LATTICE };

// TODO: Convert to enum
constexpr int32_t OP_LEFT_PAREN {std::numeric_limits<int32_t>::max()};
constexpr int32_t OP_RIGHT_PAREN {std::numeric_limits<int32_t>::max() - 1};
constexpr int32_t OP_COMPLEMENT {std::numeric_limits<int32_t>::max() - 2};
constexpr int32_t OP_INTERSECTION {std::numeric_limits<int32_t>::max() - 3};
constexpr int32_t OP_UNION {std::numeric_limits<int32_t>::max() - 4};

//==============================================================================
// Global variables
//==============================================================================
Expand Down
8 changes: 8 additions & 0 deletions include/openmc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ enum class RandomRaySourceShape { FLAT, LINEAR, LINEAR_XY };

enum class GeometryType { CSG, DAG };

constexpr int32_t OP_LEFT_PAREN {std::numeric_limits<int32_t>::max()};
constexpr int32_t OP_RIGHT_PAREN {std::numeric_limits<int32_t>::max() - 1};
constexpr int32_t OP_COMPLEMENT {std::numeric_limits<int32_t>::max() - 2};
constexpr int32_t OP_INTERSECTION {std::numeric_limits<int32_t>::max() - 3};
constexpr int32_t OP_UNION {std::numeric_limits<int32_t>::max() - 4};
constexpr int32_t NO_SURFACE {std::numeric_limits<int32_t>::max() - 5};


} // namespace openmc

#endif // OPENMC_CONSTANTS_H
4 changes: 2 additions & 2 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class GeometryState {
void init_from_r_u(Position r_a, Direction u_a)
{
clear();
surface() = 0;
surface() = NO_SURFACE;
material() = C_NONE;
r() = r_a;
u() = u_a;
Expand Down Expand Up @@ -337,7 +337,7 @@ class GeometryState {
Position r_last_; //!< previous coordinates
Direction u_last_; //!< previous direction coordinates

int surface_ {0}; //!< index for surface particle is on
int surface_ {NO_SURFACE}; //!< index for surface particle is on

BoundaryInfo boundary_; //!< Info about the next intersection

Expand Down
2 changes: 1 addition & 1 deletion src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void print_particle(Particle& p)
}

// Display miscellaneous info.
if (p.surface() != 0) {
if (p.surface() != NO_SURFACE) {
// Surfaces identifiers are >= 1, but indices are >= 0 so we need -1
const Surface& surf {*model::surfaces[std::abs(p.surface()) - 1]};
fmt::print(" Surface = {}\n", (p.surface() > 0) ? surf.id_ : -surf.id_);
Expand Down
6 changes: 3 additions & 3 deletions src/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Particle::from_source(const SourceSite* src)
{
// Reset some attributes
clear();
surface() = 0;
surface() = NO_SURFACE;
cell_born() = C_NONE;
material() = C_NONE;
n_collision() = 0;
Expand Down Expand Up @@ -328,7 +328,7 @@ void Particle::event_collide()
score_surface_tally(*this, model::active_meshsurf_tallies);

// Clear surface component
surface() = 0;
surface() = NO_SURFACE;

if (settings::run_CE) {
collision(*this);
Expand Down Expand Up @@ -587,7 +587,7 @@ void Particle::cross_surface(const Surface& surf)
// the particle is really traveling tangent to a surface, if we move it
// forward a tiny bit it should fix the problem.

surface() = 0;
surface() = NO_SURFACE;
n_coord() = 1;
r() += TINY_BIT * u();

Expand Down

0 comments on commit e6f4fd1

Please sign in to comment.