mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Updating variable names of the methods.
This commit is contained in:
parent
56362eceb9
commit
73aef414ca
2 changed files with 42 additions and 40 deletions
|
|
@ -71,13 +71,13 @@ public:
|
|||
|
||||
//! Determine which bins were crossed by a particle
|
||||
//
|
||||
//! \param[in] last_r Previous position of the particle
|
||||
//! \param[in] r Current position of the particle
|
||||
//! \param[in] r0 Previous position of the particle
|
||||
//! \param[in] r1 Current position of the particle
|
||||
//! \param[in] u Particle direction
|
||||
//! \param[out] bins Bins that were crossed
|
||||
//! \param[out] lengths Fraction of tracklength in each bin
|
||||
virtual void bins_crossed(Position last_r,
|
||||
Position r,
|
||||
virtual void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const = 0;
|
||||
|
|
@ -147,8 +147,8 @@ public:
|
|||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
void bins_crossed(Position last_r,
|
||||
Position r,
|
||||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
|
@ -341,7 +341,8 @@ public:
|
|||
|
||||
std::string bin_label(int bin) const override;
|
||||
|
||||
void surface_bins_crossed(const Particle& p,
|
||||
void surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
std::vector<int>& bins) const;
|
||||
|
||||
void to_hdf5(hid_t group) const override;
|
||||
|
|
@ -365,8 +366,8 @@ public:
|
|||
MOABMesh(pugi::xml_node);
|
||||
MOABMesh(const std::string& filename);
|
||||
|
||||
void bins_crossed(Position last_r,
|
||||
Position r,
|
||||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
|
@ -521,8 +522,8 @@ public:
|
|||
LibMesh(const std::string& filename);
|
||||
|
||||
// Methods
|
||||
void bins_crossed(Position last_r,
|
||||
Position r,
|
||||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
|
|
|||
59
src/mesh.cpp
59
src/mesh.cpp
|
|
@ -190,7 +190,8 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) {
|
|||
}
|
||||
|
||||
void
|
||||
UnstructuredMesh::surface_bins_crossed(const Particle& p,
|
||||
UnstructuredMesh::surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
std::vector<int>& bins) const {
|
||||
fatal_error("Unstructured mesh surface tallies are not implemented.");
|
||||
}
|
||||
|
|
@ -581,8 +582,8 @@ bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
return min_dist < INFTY;
|
||||
}
|
||||
|
||||
void StructuredMesh::bins_crossed(Position last_r,
|
||||
Position r,
|
||||
void StructuredMesh::bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
|
|
@ -591,14 +592,14 @@ void StructuredMesh::bins_crossed(Position last_r,
|
|||
// Determine where the track intersects the mesh and if it intersects at all.
|
||||
|
||||
// Compute the length of the entire track.
|
||||
double total_distance = (r - last_r).norm();
|
||||
double total_distance = (r1 - r0).norm();
|
||||
if (total_distance == 0.0) return;
|
||||
|
||||
// While determining if this track intersects the mesh, offset the starting
|
||||
// and ending coords by a bit. This avoid finite-precision errors that can
|
||||
// occur when the mesh surfaces coincide with lattice or geometric surfaces.
|
||||
Position r0 = last_r + TINY_BIT*u;
|
||||
Position r1 = r - TINY_BIT*u;
|
||||
Position last_r = r0 + TINY_BIT*u;
|
||||
Position r = r1 - TINY_BIT*u;
|
||||
|
||||
// Determine the mesh indices for the starting and ending coords. Here, we
|
||||
// use arrays for ijk0 and ijk1 instead of std::vector because we obtain a
|
||||
|
|
@ -609,21 +610,21 @@ void StructuredMesh::bins_crossed(Position last_r,
|
|||
int n = n_dimension_;
|
||||
int ijk0[3], ijk1[3];
|
||||
bool start_in_mesh;
|
||||
get_indices(r0, ijk0, &start_in_mesh);
|
||||
get_indices(last_r, ijk0, &start_in_mesh);
|
||||
bool end_in_mesh;
|
||||
get_indices(r1, ijk1, &end_in_mesh);
|
||||
get_indices(r, ijk1, &end_in_mesh);
|
||||
|
||||
// Reset coordinates and check for a mesh intersection if necessary.
|
||||
if (start_in_mesh) {
|
||||
// The initial coords lie in the mesh, use those coords for tallying.
|
||||
r0 = last_r;
|
||||
last_r = r0;
|
||||
} else {
|
||||
// The initial coords do not lie in the mesh. Check to see if the particle
|
||||
// eventually intersects the mesh and compute the relevant coords and
|
||||
// indices.
|
||||
if (!intersects(r0, r1, ijk0)) return;
|
||||
if (!intersects(last_r, r, ijk0)) return;
|
||||
}
|
||||
r1 = r;
|
||||
r = r1;
|
||||
|
||||
// The TINY_BIT offsets above mean that the preceding logic cannot always find
|
||||
// the correct ijk0 and ijk1 indices. For tracks shorter than 2*TINY_BIT, just
|
||||
|
|
@ -642,7 +643,7 @@ void StructuredMesh::bins_crossed(Position last_r,
|
|||
if (std::equal(ijk0, ijk0 + n, ijk1)) {
|
||||
// The track ends in this cell. Use the particle end location rather
|
||||
// than the mesh surface and stop iterating.
|
||||
double distance = (r1 - r0).norm();
|
||||
double distance = (last_r - r).norm();
|
||||
bins.push_back(get_bin_from_indices(ijk0));
|
||||
lengths.push_back(distance / total_distance);
|
||||
break;
|
||||
|
|
@ -655,10 +656,10 @@ void StructuredMesh::bins_crossed(Position last_r,
|
|||
d[k] = INFTY;
|
||||
} else if (u[k] > 0) {
|
||||
double xyz_cross = positive_grid_boundary(ijk0, k);
|
||||
d[k] = (xyz_cross - r0[k]) / u[k];
|
||||
d[k] = (xyz_cross - last_r[k]) / u[k];
|
||||
} else {
|
||||
double xyz_cross = negative_grid_boundary(ijk0, k);
|
||||
d[k] = (xyz_cross - r0[k]) / u[k];
|
||||
d[k] = (xyz_cross - last_r[k]) / u[k];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -669,7 +670,7 @@ void StructuredMesh::bins_crossed(Position last_r,
|
|||
lengths.push_back(distance / total_distance);
|
||||
|
||||
// Translate to the oncoming mesh surface.
|
||||
r0 += distance * u;
|
||||
last_r += distance * u;
|
||||
|
||||
// Increment the indices into the next mesh cell.
|
||||
if (u[j] > 0.0) {
|
||||
|
|
@ -1688,25 +1689,25 @@ MOABMesh::intersect_track(const moab::CartVect& start,
|
|||
}
|
||||
|
||||
void
|
||||
MOABMesh::bins_crossed(Position last_r,
|
||||
Position r,
|
||||
MOABMesh::bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
{
|
||||
moab::CartVect r0(last_r.x, last_r.y, last_r.z);
|
||||
moab::CartVect r1(r.x, r.y, r.z);
|
||||
moab::CartVect start(r0.x, r0.y, r0.z);
|
||||
moab::CartVect end(r1.x, r1.y, r1.z);
|
||||
moab::CartVect dir(u.x, u.y, u.z);
|
||||
dir.normalize();
|
||||
|
||||
double track_len = (r1 - r0).length();
|
||||
double track_len = (end - start).length();
|
||||
if (track_len == 0.0) return;
|
||||
|
||||
r0 -= TINY_BIT * dir;
|
||||
r1 += TINY_BIT * dir;
|
||||
start -= TINY_BIT * dir;
|
||||
end += TINY_BIT * dir;
|
||||
|
||||
std::vector<double> hits;
|
||||
intersect_track(r0, dir, track_len, hits);
|
||||
intersect_track(start, dir, track_len, hits);
|
||||
|
||||
bins.clear();
|
||||
lengths.clear();
|
||||
|
|
@ -1715,7 +1716,7 @@ MOABMesh::bins_crossed(Position last_r,
|
|||
// within a single tet. If this is the case, apply entire
|
||||
// score to that tet and return.
|
||||
if (hits.size() == 0) {
|
||||
Position midpoint = last_r + u * (track_len * 0.5);
|
||||
Position midpoint = r0 + u * (track_len * 0.5);
|
||||
int bin = this->get_bin(midpoint);
|
||||
if (bin != -1) {
|
||||
bins.push_back(bin);
|
||||
|
|
@ -1726,7 +1727,7 @@ MOABMesh::bins_crossed(Position last_r,
|
|||
|
||||
// for each segment in the set of tracks, try to look up a tet
|
||||
// at the midpoint of the segment
|
||||
Position current = last_r;
|
||||
Position current = r0;
|
||||
double last_dist = 0.0;
|
||||
for (const auto& hit : hits) {
|
||||
// get the segment length
|
||||
|
|
@ -1738,7 +1739,7 @@ MOABMesh::bins_crossed(Position last_r,
|
|||
int bin = this->get_bin(midpoint);
|
||||
|
||||
// determine the start point for this segment
|
||||
current = last_r + u * hit;
|
||||
current = r0 + u * hit;
|
||||
|
||||
if (bin == -1) {
|
||||
continue;
|
||||
|
|
@ -1753,7 +1754,7 @@ MOABMesh::bins_crossed(Position last_r,
|
|||
// the last segment of the track is in the mesh but doesn't
|
||||
// reach the other side of the tet
|
||||
if (hits.back() < track_len) {
|
||||
Position segment_start = last_r + u * hits.back();
|
||||
Position segment_start = r0 + u * hits.back();
|
||||
double segment_length = track_len - hits.back();
|
||||
Position midpoint = segment_start + u * (segment_length * 0.5);
|
||||
int bin = this->get_bin(midpoint);
|
||||
|
|
@ -2306,8 +2307,8 @@ void LibMesh::write(const std::string& filename) const
|
|||
}
|
||||
|
||||
void
|
||||
LibMesh::bins_crossed(Position last_r,
|
||||
Position r,
|
||||
LibMesh::bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue