Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions include/openmc/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ class Region {
//! \param r The 3D Cartesian coordinate to check.
//! \param u A direction used to "break ties" the coordinates are very
//! close to a surface.
//! \param t The time coordinate to check.
//! \param speed Particle speed to "break ties" for moving surface.
//! \param on_surface The signed index of a surface that the coordinate is
//! known to be on. This index takes precedence over surface sense
//! calculations.
bool contains(Position r, Direction u, int32_t on_surface) const;
bool contains(
Position r, Direction u, double t, double speed, int32_t on_surface) const;

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

//! Get the BoundingBox for this cell.
BoundingBox bounding_box(int32_t cell_id) const;
Expand All @@ -108,14 +111,18 @@ class Region {

//! Determine if a particle is inside the cell for a simple cell (only
//! intersection operators)
bool contains_simple(Position r, Direction u, int32_t on_surface) const;
bool contains_simple(

Position r, Direction u, double t, double speed, int32_t on_surface) const;

//! Determine if a particle is inside the cell for a complex cell.
//!
//! Uses the comobination of half-spaces and binary operators to determine
//! if short circuiting can be used. Short cicuiting uses the relative and
//! absolute depth of parentheses in the expression.
bool contains_complex(Position r, Direction u, int32_t on_surface) const;
bool contains_complex(
Position r, Direction u, double t, double speed, int32_t on_surface) const;

//! BoundingBox if the paritcle is in a simple cell.
BoundingBox bounding_box_simple() const;
Expand Down Expand Up @@ -175,14 +182,17 @@ class Cell {
//! \param r The 3D Cartesian coordinate to check.
//! \param u A direction used to "break ties" the coordinates are very
//! close to a surface.
//! \param t The time coordinate to check.
//! \param speed Particle speed to "break ties" for moving surface.
//! \param on_surface The signed index of a surface that the coordinate is
//! known to be on. This index takes precedence over surface sense
//! calculations.
virtual bool contains(Position r, Direction u, int32_t on_surface) const = 0;
virtual bool contains(Position r, Direction u, double t, double speed,
int32_t on_surface) const = 0;

//! Find the oncoming boundary of this cell.
virtual std::pair<double, int32_t> distance(
Position r, Direction u, int32_t on_surface, GeometryState* p) const = 0;
Position r, Direction u, double t, double speed, 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 @@ -371,14 +381,15 @@ class CSGCell : public Cell {
vector<int32_t> surfaces() const override { return region_.surfaces(); }

std::pair<double, int32_t> distance(Position r, Direction u,
int32_t on_surface, GeometryState* p) const override
double t, double speed, int32_t on_surface, GeometryState* p) const override
{
return region_.distance(r, u, on_surface);
return region_.distance(r, u, t, speed, on_surface);
}

bool contains(Position r, Direction u, int32_t on_surface) const override
bool contains(Position r, Direction u, double t, double speed,
int32_t on_surface) const override
{
return region_.contains(r, u, on_surface);
return region_.contains(r, u, t, speed, on_surface);
}

BoundingBox bounding_box() const override
Expand Down
4 changes: 3 additions & 1 deletion include/openmc/dagmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ class DAGSurface : public Surface {

moab::EntityHandle mesh_handle() const;

double evaluate(Position r) const override;
double evaluate(Position r, double t) const override;
double distance(Position r, Direction u, bool coincident) const override;
Direction normal(Position r) const override;
double dot_normal(
Position r, Direction u, double t, double speed) const override;
Direction reflect(
Position r, Direction u, GeometryState* p = nullptr) const override;

Expand Down
2 changes: 1 addition & 1 deletion include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Particle : public ParticleData {
//==========================================================================
// Methods

double speed() const;
double get_speed() const;

//! create a secondary particle
//
Expand Down
24 changes: 15 additions & 9 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ class GeometryState {
Direction& u_local() { return coord_[n_coord_ - 1].u; }
const Direction& u_local() const { return coord_[n_coord_ - 1].u; }

// Accessors for time (units are seconds).
double& time() { return time_; }
const double& time() const { return time_; }
double& time_last() { return time_last_; }
const double& time_last() const { return time_last_; }

// Accessors for speed (cm/s).
double& speed() { return speed_; }
const double& speed() const { return speed_; }

// Surface token for the surface that the particle is currently on
int& surface() { return surface_; }
const int& surface() const { return surface_; }
Expand Down Expand Up @@ -364,6 +374,11 @@ class GeometryState {
Position r_last_; //!< previous coordinates
Direction u_last_; //!< previous direction coordinates

double time_; //!< time
double time_last_; //!< previous time

double speed_;

int surface_ {
SURFACE_NONE}; //!< surface token for surface the particle is currently on

Expand Down Expand Up @@ -437,8 +452,6 @@ class ParticleData : public GeometryState {
double wgt_born_ {1.0};
double wgt_ww_born_ {-1.0};
double mu_;
double time_ {0.0};
double time_last_ {0.0};
double wgt_last_ {1.0};

bool fission_ {false};
Expand Down Expand Up @@ -561,13 +574,6 @@ class ParticleData : public GeometryState {
double& mu() { return mu_; }
const double& mu() const { return mu_; }

// Tracks the time of a particle as it traverses the problem.
// Units are seconds.
double& time() { return time_; }
const double& time() const { return time_; }
double& time_last() { return time_last_; }
const double& time_last() const { return time_last_; }

// Particle lifetime
double& lifetime() { return lifetime_; }
const double& lifetime() const { return lifetime_; }
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class SlicePlotBase {
Position origin_; //!< Plot origin in geometry
Position width_; //!< Plot width in geometry
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
double time_; //!< Plot time
array<size_t, 3> pixels_; //!< Plot size in pixels
bool slice_color_overlaps_; //!< Show overlapping cells?
int slice_level_ {-1}; //!< Plot universe level
Expand Down Expand Up @@ -223,6 +224,7 @@ T SlicePlotBase::get_map() const
GeometryState p;
p.r() = xyz;
p.u() = dir;
p.time() = time_;
p.coord(0).universe = model::root_universe;
int level = slice_level_;
int j {};
Expand Down
2 changes: 1 addition & 1 deletion include/openmc/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Source {

// Methods for constraints
void read_constraints(pugi::xml_node node);
bool satisfies_spatial_constraints(Position r) const;
bool satisfies_spatial_constraints(Position r, double time) const;
bool satisfies_energy_constraints(double E) const;
bool satisfies_time_constraints(double time) const;

Expand Down
Loading