[MOAB-dev] r5080 - MOAB/trunk/tools/dagmc
sjackson at cae.wisc.edu
sjackson at cae.wisc.edu
Wed Aug 3 16:31:49 CDT 2011
Author: sjackson
Date: 2011-08-03 16:31:49 -0500 (Wed, 03 Aug 2011)
New Revision: 5080
Modified:
MOAB/trunk/tools/dagmc/DagMC.cpp
MOAB/trunk/tools/dagmc/DagMC.hpp
MOAB/trunk/tools/dagmc/test_geom.cc
Log:
Add DagMC::test_volume_boundary() to test whether on-surface ray enters or leaves volume
This function allows DagMC client to query whether a ray that originates on
the surface of the volume is entering or leaving that volume. This is useful
in particle tracking when a particle changes direction at a surface and client
code wants to know whether to advance it to the next volume. The function
uses a RayHistory object from ray_fire if available to avoid making any
OBB queries.
Add (simple and primitive) unit tests for this function.
Also add DagMC::RayHistory::size(), returning the number of entries in a history.
This is mostly for debugging purposes, though it may be useful for client code
to know if a history object is empty (size == 0).
Modified: MOAB/trunk/tools/dagmc/DagMC.cpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.cpp 2011-08-03 16:58:41 UTC (rev 5079)
+++ MOAB/trunk/tools/dagmc/DagMC.cpp 2011-08-03 21:31:49 UTC (rev 5080)
@@ -873,6 +873,43 @@
return MB_SUCCESS;
}
+ErrorCode DagMC::test_volume_boundary( const EntityHandle volume, const EntityHandle surface,
+ const double xyz[3], const double uvw[3], int& result,
+ const RayHistory* history )
+{
+ ErrorCode rval;
+ int dir;
+
+ if( history && history->prev_facets.size() ){
+ // the current facet is already available
+ rval = boundary_case( volume, dir, uvw[0], uvw[1], uvw[2], history->prev_facets.back(), surface );
+ if (MB_SUCCESS != rval) return rval;
+ }
+ else{
+ // look up nearest facet
+
+ // Get OBB Tree for surface
+ assert(volume - setOffset < rootSets.size());
+ EntityHandle root = rootSets[volume - setOffset];
+
+ // Get closest triangle on surface
+ const CartVect point(xyz);
+ CartVect nearest;
+ EntityHandle facet_out;
+ rval = obbTree.closest_to_location( point.array(), root, nearest.array(), facet_out );
+ if (MB_SUCCESS != rval) return rval;
+
+ rval = boundary_case( volume, dir, uvw[0], uvw[1], uvw[2], facet_out, surface );
+ if (MB_SUCCESS != rval) return rval;
+
+ }
+
+ result = dir;
+
+ return MB_SUCCESS;
+
+}
+
// use spherical area test to determine inside/outside of a polyhedron.
ErrorCode DagMC::point_in_volume_slow( EntityHandle volume, const double xyz[3], int& result )
{
Modified: MOAB/trunk/tools/dagmc/DagMC.hpp
===================================================================
More information about the moab-dev
mailing list