mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Change (surface_)bins_crossed to accept const ref instead of pointer
This commit is contained in:
parent
23b984ba3a
commit
498fb181d6
4 changed files with 31 additions and 33 deletions
|
|
@ -53,7 +53,7 @@ public:
|
|||
//! \param[in] p Particle to check
|
||||
//! \param[out] bins Bins that were crossed
|
||||
//! \param[out] lengths Fraction of tracklength in each bin
|
||||
virtual void bins_crossed(const Particle* p, std::vector<int>& bins,
|
||||
virtual void bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const = 0;
|
||||
|
||||
//! Determine which surface bins were crossed by a particle
|
||||
|
|
@ -61,7 +61,7 @@ public:
|
|||
//! \param[in] p Particle to check
|
||||
//! \param[out] bins Surface bins that were crossed
|
||||
virtual void
|
||||
surface_bins_crossed(const Particle* p, std::vector<int>& bins) const = 0;
|
||||
surface_bins_crossed(const Particle& p, std::vector<int>& bins) const = 0;
|
||||
|
||||
//! Get bin at a given position in space
|
||||
//
|
||||
|
|
@ -145,10 +145,10 @@ public:
|
|||
|
||||
// Overriden methods
|
||||
|
||||
void bins_crossed(const Particle* p, std::vector<int>& bins,
|
||||
void bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
||||
void surface_bins_crossed(const Particle* p, std::vector<int>& bins)
|
||||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins)
|
||||
const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
|
@ -207,10 +207,10 @@ public:
|
|||
|
||||
// Overriden methods
|
||||
|
||||
void bins_crossed(const Particle* p, std::vector<int>& bins,
|
||||
void bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
||||
void surface_bins_crossed(const Particle* p, std::vector<int>& bins)
|
||||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins)
|
||||
const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
|
@ -256,7 +256,7 @@ public:
|
|||
UnstructuredMesh(pugi::xml_node);
|
||||
~UnstructuredMesh() = default;
|
||||
|
||||
void bins_crossed(const Particle* p,
|
||||
void bins_crossed(const Particle& p,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ public:
|
|||
//
|
||||
//! \param[in] p Particle to check
|
||||
//! \param[out] bins Surface bins that were crossed
|
||||
void surface_bins_crossed(const Particle* p, std::vector<int>& bins) const;
|
||||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins) const;
|
||||
|
||||
//! Write mesh data to an HDF5 group.
|
||||
//
|
||||
|
|
|
|||
44
src/mesh.cpp
44
src/mesh.cpp
|
|
@ -508,16 +508,16 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
return min_dist < INFTY;
|
||||
}
|
||||
|
||||
void RegularMesh::bins_crossed(const Particle* p, std::vector<int>& bins,
|
||||
void RegularMesh::bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
{
|
||||
// ========================================================================
|
||||
// Determine where the track intersects the mesh and if it intersects at all.
|
||||
|
||||
// Copy the starting and ending coordinates of the particle.
|
||||
Position last_r {p->r_last_};
|
||||
Position r {p->r()};
|
||||
Direction u {p->u()};
|
||||
Position last_r {p.r_last_};
|
||||
Position r {p.r()};
|
||||
Direction u {p.u()};
|
||||
|
||||
// Compute the length of the entire track.
|
||||
double total_distance = (r - last_r).norm();
|
||||
|
|
@ -614,16 +614,16 @@ void RegularMesh::bins_crossed(const Particle* p, std::vector<int>& bins,
|
|||
}
|
||||
}
|
||||
|
||||
void RegularMesh::surface_bins_crossed(const Particle* p,
|
||||
void RegularMesh::surface_bins_crossed(const Particle& p,
|
||||
std::vector<int>& bins) const
|
||||
{
|
||||
// ========================================================================
|
||||
// Determine if the track intersects the tally mesh.
|
||||
|
||||
// Copy the starting and ending coordinates of the particle.
|
||||
Position r0 {p->r_last_current_};
|
||||
Position r1 {p->r()};
|
||||
Direction u {p->u()};
|
||||
Position r0 {p.r_last_current_};
|
||||
Position r1 {p.r()};
|
||||
Direction u {p.u()};
|
||||
|
||||
// Determine indices for starting and ending location.
|
||||
int n = n_dimension_;
|
||||
|
|
@ -899,16 +899,16 @@ RectilinearMesh::RectilinearMesh(pugi::xml_node node)
|
|||
upper_right_ = {grid_[0].back(), grid_[1].back(), grid_[2].back()};
|
||||
}
|
||||
|
||||
void RectilinearMesh::bins_crossed(const Particle* p, std::vector<int>& bins,
|
||||
void RectilinearMesh::bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
{
|
||||
// ========================================================================
|
||||
// Determine where the track intersects the mesh and if it intersects at all.
|
||||
|
||||
// Copy the starting and ending coordinates of the particle.
|
||||
Position last_r {p->r_last_};
|
||||
Position r {p->r()};
|
||||
Direction u {p->u()};
|
||||
Position last_r {p.r_last_};
|
||||
Position r {p.r()};
|
||||
Direction u {p.u()};
|
||||
|
||||
// Compute the length of the entire track.
|
||||
double total_distance = (r - last_r).norm();
|
||||
|
|
@ -1004,16 +1004,16 @@ void RectilinearMesh::bins_crossed(const Particle* p, std::vector<int>& bins,
|
|||
}
|
||||
}
|
||||
|
||||
void RectilinearMesh::surface_bins_crossed(const Particle* p,
|
||||
void RectilinearMesh::surface_bins_crossed(const Particle& p,
|
||||
std::vector<int>& bins) const
|
||||
{
|
||||
// ========================================================================
|
||||
// Determine if the track intersects the tally mesh.
|
||||
|
||||
// Copy the starting and ending coordinates of the particle.
|
||||
Position r0 {p->r_last_current_};
|
||||
Position r1 {p->r()};
|
||||
Direction u {p->u()};
|
||||
Position r0 {p.r_last_current_};
|
||||
Position r1 {p.r()};
|
||||
Direction u {p.u()};
|
||||
|
||||
// Determine indices for starting and ending location.
|
||||
int ijk0[3], ijk1[3];
|
||||
|
|
@ -1650,15 +1650,13 @@ UnstructuredMesh::intersect_track(const moab::CartVect& start,
|
|||
}
|
||||
|
||||
void
|
||||
UnstructuredMesh::bins_crossed(const Particle* p,
|
||||
UnstructuredMesh::bins_crossed(const Particle& p,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
{
|
||||
|
||||
moab::ErrorCode rval;
|
||||
Position last_r{p->r_last_};
|
||||
Position r{p->r()};
|
||||
Direction u{p->u()};
|
||||
Position last_r{p.r_last_};
|
||||
Position r{p.r()};
|
||||
Direction u{p.u()};
|
||||
u /= u.norm();
|
||||
moab::CartVect r0(last_r.x, last_r.y, last_r.z);
|
||||
moab::CartVect r1(r.x, r.y, r.z);
|
||||
|
|
@ -1772,7 +1770,7 @@ double UnstructuredMesh::tet_volume(moab::EntityHandle tet) const {
|
|||
return 1.0 / 6.0 * (((p[1] - p[0]) * (p[2] - p[0])) % (p[3] - p[0]));
|
||||
}
|
||||
|
||||
void UnstructuredMesh::surface_bins_crossed(const Particle* p, std::vector<int>& bins) const {
|
||||
void UnstructuredMesh::surface_bins_crossed(const Particle& p, std::vector<int>& bins) const {
|
||||
// TODO: Implement triangle crossings here
|
||||
throw std::runtime_error{"Unstructured mesh surface tallies are not implemented."};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const
|
|||
match.weights_.push_back(1.0);
|
||||
}
|
||||
} else {
|
||||
model::meshes[mesh_]->bins_crossed(&p, match.bins_, match.weights_);
|
||||
model::meshes[mesh_]->bins_crossed(p, match.bins_, match.weights_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ void
|
|||
MeshSurfaceFilter::get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const
|
||||
{
|
||||
model::meshes[mesh_]->surface_bins_crossed(&p, match.bins_);
|
||||
model::meshes[mesh_]->surface_bins_crossed(p, match.bins_);
|
||||
for (auto b : match.bins_) match.weights_.push_back(1.0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue