Skip to content

Commit

Permalink
Merge pull request #718 from gonuke/add_find_volume
Browse files Browse the repository at this point in the history
Add function to expose find_volume in DAGMC
  • Loading branch information
pshriwise committed Aug 16, 2023
2 parents 73ed77b + 46ac3ee commit 8ae0b4c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ v3.2.1
* DagMC methods for creation and removal of the graveyard volume (#714)
* CI build and test now support MacOS (shared build, no pymoab, no Double Down) (#780)
* Added GitHub style citation file (CITATION.cff) (#790)
* exposed the new find_volume() method that is implemented in MOAB GQT (#718)


**Changed:**

Expand Down
9 changes: 9 additions & 0 deletions src/dagmc/DagMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,15 @@ ErrorCode DagMC::point_in_volume_slow(EntityHandle volume, const double xyz[3],
return rval;
}

#if MOAB_VERSION_MAJOR == 5 && MOAB_VERSION_MINOR > 2
// find a which volume contains the current point
ErrorCode DagMC::find_volume(const double xyz[3], EntityHandle& volume,
const double* uvw) {
ErrorCode rval = ray_tracer->find_volume(xyz, volume, uvw);
return rval;
}
#endif

// detemine distance to nearest surface
ErrorCode DagMC::closest_to_location(EntityHandle volume,
const double coords[3], double& result,
Expand Down
4 changes: 4 additions & 0 deletions src/dagmc/DagMC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ class DagMC {

ErrorCode point_in_volume_slow(const EntityHandle volume, const double xyz[3],
int& result);
#if MOAB_VERSION_MAJOR == 5 && MOAB_VERSION_MINOR > 2
ErrorCode find_volume(const double xyz[3], EntityHandle& volume,
const double* uvw = NULL);
#endif

ErrorCode test_volume_boundary(const EntityHandle volume,
const EntityHandle surface,
Expand Down
13 changes: 13 additions & 0 deletions src/dagmc/tests/dagmc_simple_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ TEST_F(DagmcSimpleTest, dagmc_point_in) {
EXPECT_EQ(expect_result, result);
}

#if MOAB_VERSION_MAJOR == 5 && MOAB_VERSION_MINOR > 2
TEST_F(DagmcSimpleTest, dagmc_find_volume) {
int vol_idx = 1;
int vol_dim = 3;
double xyz[3] = {0.0, 0.0, 0.0};
EntityHandle vol_h;
EntityHandle expected_vol_h = DAG->entity_by_index(vol_dim, vol_idx);
ErrorCode rval = DAG->find_volume(xyz, vol_h);
EXPECT_EQ(rval, MB_SUCCESS);
EXPECT_EQ(expected_vol_h, vol_h);
}
#endif

TEST_F(DagmcSimpleTest, dagmc_test_obb_retreval_rayfire) {
// make new dagmc
std::cout << "test_obb_retreval and ray_fire" << std::endl;
Expand Down

0 comments on commit 8ae0b4c

Please sign in to comment.