mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Move get_bin implementation up to StructuredMesh base class. Refs #1695
This commit is contained in:
parent
bcc072e0a8
commit
9a36ea405a
2 changed files with 16 additions and 30 deletions
|
|
@ -105,6 +105,8 @@ public:
|
|||
StructuredMesh(pugi::xml_node node) : Mesh {node} {};
|
||||
virtual ~StructuredMesh() = default;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
//! Get bin given mesh indices
|
||||
//
|
||||
//! \param[in] Array of mesh indices
|
||||
|
|
@ -171,9 +173,7 @@ public:
|
|||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins)
|
||||
const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
int get_index_in_direction(Position r, int i) const override;
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
int n_bins() const override;
|
||||
|
||||
|
|
@ -215,9 +215,7 @@ public:
|
|||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins)
|
||||
const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
int get_index_in_direction(Position r, int i) const override;
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
int n_bins() const override;
|
||||
|
||||
|
|
|
|||
36
src/mesh.cpp
36
src/mesh.cpp
|
|
@ -140,6 +140,18 @@ void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const
|
|||
}
|
||||
}
|
||||
|
||||
int StructuredMesh::get_bin(Position r) const
|
||||
{
|
||||
// Determine indices
|
||||
std::vector<int> ijk(n_dimension_);
|
||||
bool in_mesh;
|
||||
get_indices(r, ijk.data(), &in_mesh);
|
||||
if (!in_mesh) return -1;
|
||||
|
||||
// Convert indices to bin
|
||||
return get_bin_from_indices(ijk.data());
|
||||
}
|
||||
|
||||
bool StructuredMesh::intersects(Position& r0, Position r1, int* ijk) const
|
||||
{
|
||||
switch(n_dimension_) {
|
||||
|
|
@ -469,18 +481,6 @@ RegularMesh::RegularMesh(pugi::xml_node node)
|
|||
volume_frac_ = 1.0/xt::prod(shape_)();
|
||||
}
|
||||
|
||||
int RegularMesh::get_bin(Position r) const
|
||||
{
|
||||
// Determine indices
|
||||
std::vector<int> ijk(n_dimension_);
|
||||
bool in_mesh;
|
||||
get_indices(r, ijk.data(), &in_mesh);
|
||||
if (!in_mesh) return -1;
|
||||
|
||||
// Convert indices to bin
|
||||
return get_bin_from_indices(ijk.data());
|
||||
}
|
||||
|
||||
int RegularMesh::get_index_in_direction(double r, int i) const
|
||||
{
|
||||
return std::ceil((r - lower_left_[i]) / width_[i]);
|
||||
|
|
@ -1162,18 +1162,6 @@ void RectilinearMesh::surface_bins_crossed(const Particle& p,
|
|||
}
|
||||
}
|
||||
|
||||
int RectilinearMesh::get_bin(Position r) const
|
||||
{
|
||||
// Determine indices
|
||||
int ijk[3];
|
||||
bool in_mesh;
|
||||
get_indices(r, ijk, &in_mesh);
|
||||
if (!in_mesh) return -1;
|
||||
|
||||
// Convert indices to bin
|
||||
return get_bin_from_indices(ijk);
|
||||
}
|
||||
|
||||
int RectilinearMesh::get_index_in_direction(double r, int i) const
|
||||
{
|
||||
return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue