Skip to content

Commit

Permalink
Make creation of spatial trees based on usage for unstructured mesh. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Jan 17, 2024
1 parent 6391606 commit 4fa3fbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/openmc/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Mesh {
virtual ~Mesh() = default;

// Methods
//! Perform any preparation needed to support use in mesh filters
virtual void prepare_for_tallies() {};

//! Update a position to the local coordinates of the mesh
virtual void local_coords(Position& r) const {};
Expand Down Expand Up @@ -664,6 +666,9 @@ class MOABMesh : public UnstructuredMesh {

// Overridden Methods

//! Perform any preparation needed to support use in mesh filters
void prepare_for_tallies() override;

Position sample_element(int32_t bin, uint64_t* seed) const override;

void bins_crossed(Position r0, Position r1, const Direction& u,
Expand Down
7 changes: 7 additions & 0 deletions src/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,13 @@ void MOABMesh::initialize()
}
}
}
}

void MOABMesh::prepare_for_tallies()
{
// if the KDTree has already been constructed, do nothing
if (kdtree_)
return;

// build acceleration data structures
compute_barycentric_data(ehs_);
Expand Down
2 changes: 2 additions & 0 deletions src/tallies/filter_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ std::string MeshFilter::text_label(int bin) const

void MeshFilter::set_mesh(int32_t mesh)
{
// perform any additional perparation for mesh tallies here
mesh_ = mesh;
n_bins_ = model::meshes[mesh_]->n_bins();
model::meshes[mesh_]->prepare_for_tallies();
}

void MeshFilter::set_translation(const Position& translation)
Expand Down

0 comments on commit 4fa3fbc

Please sign in to comment.