[MOAB-dev] commit/MOAB: gonuke: Remove reliance on hard coded 64-bit entity handle. Some refactor of point_in_volume tests.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Mar 27 06:41:39 CDT 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/6882b5129a3a/
Changeset: 6882b5129a3a
Branch: master
User: gonuke
Date: 2014-03-27 12:40:41
Summary: Remove reliance on hard coded 64-bit entity handle. Some refactor of point_in_volume tests.
Affected #: 3 files
diff --git a/test/dagmc/dagmc_pointinvol_test.cpp b/test/dagmc/dagmc_pointinvol_test.cpp
index a540b63..47ee7c1 100644
--- a/test/dagmc/dagmc_pointinvol_test.cpp
+++ b/test/dagmc/dagmc_pointinvol_test.cpp
@@ -36,33 +36,42 @@ void dagmc_setup_test()
int num_vols = DAG->num_entities(3);
EntityHandle vol;
- EntityHandle volume = 12682136550675316765;
for ( int i = 0 ; i < num_vols ; i++ )
{
vol = DAG->entity_by_index(3,i);
}
- CHECK_EQUAL(volume,vol);
+ //EntityHandle volume = 12682136550675316765;
+ //CHECK_EQUAL(volume,vol);
}
void dagmc_point_in()
{
int result = 0;
+ int expected_result=1;
double xyz[3]={0.0,0.0,0.0};
- EntityHandle volume = 12682136550675316765;
- ErrorCode rval = DAG->point_in_volume(volume,xyz,result);
- CHECK_EQUAL(1,result);
+ int vol_idx=1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
+ ErrorCode rval = DAG->point_in_volume(vol_h,xyz,result);
+ CHECK_ERR(rval);
+ CHECK_EQUAL(expected_result,result);
}
-void dagmc_point_in_vol_1()
+int dagmc_point_in_vol_dir(double origin[3],double dir[3],int vol_idx)
{
int result = 0;
- EntityHandle volume = 12682136550675316765;
- double dir[3]={-1.0,0.0,0.0};
- double origin[3]={0.0,0.0,0.0};
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
+
+ // normalise the vector
+ double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
+
+ dir[0]=dir[0]/sqrt(dir_norm);
+ dir[1]=dir[1]/sqrt(dir_norm);
+ dir[2]=dir[2]/sqrt(dir_norm);
+
+ ErrorCode rval = DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist);
xyz[0]=origin[0]+(next_surf_dist*dir[0]);
xyz[1]=origin[1]+(next_surf_dist*dir[1]);
@@ -70,359 +79,179 @@ void dagmc_point_in_vol_1()
std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
- rval = DAG->point_in_volume(volume,xyz,result,dir);
+ rval = DAG->point_in_volume(vol_h,xyz,result,dir);
CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ return result;
+}
+
+void dagmc_point_in_vol_1()
+{
+ double dir[3]={ -1.0,0.0,0.0};
+ double origin[3]={0.0,0.0,0.0};
+ int vol_idx=1;
+ int expected_result=1;
+
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
+ CHECK_EQUAL(expected_result,result);
+
}
void dagmc_point_in_vol_2()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ 1.0,0.0,0.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_in_vol_3()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ 0.0,-1.0,0.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_in_vol_4()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ 0.0,1.0,0.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
+
+ CHECK_EQUAL(expected_result,result);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
}
void dagmc_point_in_vol_5()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ 0.0,0.0,-1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_in_vol_6()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ 0.0,0.0,1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
+
+ CHECK_EQUAL(expected_result,result);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
}
void dagmc_point_on_corner_1()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ 1.0,1.0,1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
-
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
-
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_2()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result=1;
+ int vol_idx=1;
double dir[3]={ -1.0,1.0,1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
-
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
-
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_3()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result = 1;
+ int vol_idx=1;
double dir[3]={ 1.0,1.0,-1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
-
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
-
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
-
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_4()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result = 1;
+ int vol_idx=1;
double dir[3]={ -1.0,1.0,-1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
-
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
-
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_5()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result = 1;
+ int vol_idx=1;
double dir[3]={ 1.0,-1.0,1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
-
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
-
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_6()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result = 1;
+ int vol_idx=1;
double dir[3]={ -1.0,-1.0,1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
-
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
-
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
-
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_7()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result = 1;
+ int vol_idx=1;
double dir[3]={ 1.0,-1.0,-1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
-
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
-
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
void dagmc_point_on_corner_8()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int expected_result = 1;
+ int vol_idx=1;
double dir[3]={ -1.0,-1.0,-1.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
- double next_surf_dist;
- EntityHandle next_surf;
-
- // normalise the vector
- double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);
- dir[0]=dir[0]/sqrt(dir_norm);
- dir[1]=dir[1]/sqrt(dir_norm);
- dir[2]=dir[2]/sqrt(dir_norm);
+ int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
-
- xyz[0]=origin[0]+(next_surf_dist*dir[0]);
- xyz[1]=origin[1]+(next_surf_dist*dir[1]);
- xyz[2]=origin[2]+(next_surf_dist*dir[2]);
-
- std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
-
- rval = DAG->point_in_volume(volume,xyz,result,dir);
- CHECK_ERR(rval);
- CHECK_EQUAL(1,result);
+ CHECK_EQUAL(expected_result,result);
}
int main(int /* argc */, char** /* argv */)
diff --git a/test/dagmc/dagmc_rayfire_test.cpp b/test/dagmc/dagmc_rayfire_test.cpp
index 28c81dd..57aa625 100644
--- a/test/dagmc/dagmc_rayfire_test.cpp
+++ b/test/dagmc/dagmc_rayfire_test.cpp
@@ -36,77 +36,77 @@ void dagmc_setup_test()
CHECK_ERR(rval);
int num_vols = DAG->num_entities(3);
- EntityHandle vol;
- EntityHandle volume = 12682136550675316765;
+ EntityHandle vol_h;
for ( int i = 0 ; i < num_vols ; i++ )
{
- vol = DAG->entity_by_index(3,i);
+ vol_h = DAG->entity_by_index(3,i);
}
- CHECK_EQUAL(volume,vol);
+ // EntityHandle volume = 12682136550675316765;
+ // CHECK_EQUAL(volume,vol);
}
void dagmc_origin_face_rayfire()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int vol_idx = 1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double dir[3]={-1.0,0.0,0.0};
double origin[3]={0.0,0.0,0.0};
- double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
- CHECK_REAL_EQUAL(5.0,next_surf_dist,eps);
+ DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist);
+ double expected_next_surf_dist=5.0;
+ CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);
}
void dagmc_outside_face_rayfire()
{
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int vol_idx = 1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double dir[3]={1.0,0.0,0.0}; // ray along x direction
double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0
- double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist);
+ DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist);
std::cout << next_surf_dist << std::endl;
- CHECK_REAL_EQUAL(15.0,next_surf_dist,eps);
+ double expected_next_surf_dist=15.0;
+ CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);
}
void dagmc_outside_face_rayfire_orient_exit()
{
DagMC::RayHistory history;
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int vol_idx = 1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double dir[3]={1.0,0.0,0.0}; // ray along x direction
double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0
- double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0,1);
std::cout << next_surf_dist << std::endl;
- CHECK_REAL_EQUAL(15.0,next_surf_dist,eps);
+ double expected_next_surf_dist=15.0;
+ CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);
}
void dagmc_outside_face_rayfire_orient_entrance()
{
DagMC::RayHistory history;
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int vol_idx = 1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double dir[3]={1.0,0.0,0.0}; // ray along x direction
double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0
- double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist,&history,0.0,-1);
+ DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0.0,-1);
std::cout << next_surf_dist << std::endl;
- CHECK_REAL_EQUAL(5.0,next_surf_dist,eps);
+ double expected_next_surf_dist=5.0;
+ CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);
}
void dagmc_outside_face_rayfire_history_fail()
{
DagMC::RayHistory history;
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int vol_idx = 1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double dir[3]={1.0,0.0,0.0}; // ray along x direction
double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0
double xyz[3];
@@ -116,14 +116,14 @@ void dagmc_outside_face_rayfire_history_fail()
history.reset();
// ray fired exactly along boundary shared by 2 facets on a single surface,
- // needs to ray_fires to cross, this is expected and ok
+ // needs two ray_fires to cross, this is expected and ok
// first ray fire with history
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0,1);
// second ray fire with history
- rval = DAG->ray_fire(volume,xyz,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);
// this fire should hit graveyard, i.e. next_surf = 0
- rval = DAG->ray_fire(volume,xyz,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);
// using history with this geom, there should be no next surface, i.e. 0
EntityHandle ZERO = 0;
@@ -133,8 +133,8 @@ void dagmc_outside_face_rayfire_history_fail()
void dagmc_outside_face_rayfire_history()
{
DagMC::RayHistory history;
- int result = 0;
- EntityHandle volume = 12682136550675316765;
+ int vol_idx = 1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
double dir[3]={1.0,0.0,0.0}; // ray along x direction
double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0
double xyz[3];
@@ -143,7 +143,7 @@ void dagmc_outside_face_rayfire_history()
history.reset();
// first ray fire with history
- ErrorCode rval = DAG->ray_fire(volume,origin,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0,1);
std::cout << next_surf << " " << history.size() << std::endl;
// second ray fire with history
@@ -153,9 +153,9 @@ void dagmc_outside_face_rayfire_history()
// ray fired execacyl
- rval = DAG->ray_fire(volume,xyz,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);
- rval = DAG->ray_fire(volume,xyz,dir,next_surf,next_surf_dist,&history,0,1);
+ DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);
// using history with this geom, there should be no next surface, i.e. 0
diff --git a/test/dagmc/dagmc_simple_test.cpp b/test/dagmc/dagmc_simple_test.cpp
index 3a0c925..bf253f6 100644
--- a/test/dagmc/dagmc_simple_test.cpp
+++ b/test/dagmc/dagmc_simple_test.cpp
@@ -41,73 +41,84 @@ void dagmc_build_obb()
void dagmc_num_vols()
{
+ int expect_num_vols=2;
int num_vols = DAG->num_entities(3);
- CHECK_EQUAL(2,num_vols);
+ CHECK_EQUAL(expect_num_vols,num_vols);
}
void dagmc_entity_handle()
{
int num_vols = DAG->num_entities(3);
- EntityHandle vol;
- EntityHandle volume = 12682136550675316765;
+ EntityHandle vol_h;
for ( int i = 0 ; i < num_vols ; i++ )
{
- vol = DAG->entity_by_index(3,i);
+ vol_h = DAG->entity_by_index(3,i);
}
- CHECK_EQUAL(volume,vol);
+ //EntityHandle expect_vol_h = 12682136550675316765;
+ //CHECK_EQUAL(expect_vol_h,vol_h);
}
void dagmc_point_in()
{
int result = 0;
+ int expect_result=1;
+ int vol_idx=1;
double xyz[3]={0.0,0.0,0.0};
- EntityHandle volume = 12682136550675316765;
- ErrorCode rval = DAG->point_in_volume(volume,xyz,result);
- CHECK_EQUAL(1,result);
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
+ ErrorCode rval = DAG->point_in_volume(vol_h,xyz,result);
+ CHECK_EQUAL(expect_result,result);
}
void dagmc_rayfire()
{
const double eps = 1e-6; // epsilon for test, faceting tol?
+ int vol_idx=1;
// note model is cube of side 10, centred at 0,0,0, so ray fire along
// any unit direction should be exactly 5.0
double xyz[3]={0.0,0.0,0.0};
double dir[3]={0.0,0.0,1.0};
EntityHandle next_surf;
double next_surf_dist;
- EntityHandle volume = 12682136550675316765;
+ double expect_next_surf_dist=5.0;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
- ErrorCode rval = DAG->ray_fire(volume,xyz,dir,next_surf,next_surf_dist);
- CHECK_REAL_EQUAL(5.0,next_surf_dist,eps);
+ ErrorCode rval = DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist);
+ CHECK_REAL_EQUAL(expect_next_surf_dist,next_surf_dist,eps);
}
void dagmc_closest_to()
{
const double eps = 1e-6; // epsilon for test, faceting tol?
+ int vol_idx=1;
// note model is cube of side 10, centred at 0,0,0, so ray fire along
// any unit direction should be exactly 5.0
double xyz[3]={-6.0,0.0,0.0};
double distance; // distance from point to nearest surface
- EntityHandle volume = 12682136550675316765;
+ double expect_distance=1.0;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
- ErrorCode rval = DAG->closest_to_location(volume,xyz,distance);
+ ErrorCode rval = DAG->closest_to_location(vol_h,xyz,distance);
// distance should be 1.0 cm
- CHECK_REAL_EQUAL(1.0,distance,eps);
+ CHECK_REAL_EQUAL(expect_distance,distance,eps);
}
void dagmc_test_boundary()
{
- EntityHandle volume = 12682136550675316765;
- EntityHandle surf = 12682136550675316759;
+ int vol_idx=1;
+ EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);
+ int surf_idx=1;
+ EntityHandle surf_h = DAG->entity_by_index(2,surf_idx);
+
double xyz[3]={0.0,0.0,5.0};
double dir[3]={0.0,0.0,1.0};
int result;
-
- ErrorCode rval = DAG->test_volume_boundary(volume,surf,xyz,dir,result);
+ int expect_result=0;
+
+ ErrorCode rval = DAG->test_volume_boundary(vol_h,surf_h,xyz,dir,result);
// check ray leaving volume
- CHECK_EQUAL(0,result);
+ CHECK_EQUAL(expect_result,result);
}
int main(int /* argc */, char** /* argv */)
@@ -116,7 +127,7 @@ int main(int /* argc */, char** /* argv */)
result += RUN_TEST( dagmc_load_file ); // test ray fire
result += RUN_TEST( dagmc_build_obb ); // build the obb
result += RUN_TEST( dagmc_num_vols ); // make sure the num of vols correct
- result += RUN_TEST( dagmc_entity_handle); // check the entity handle correct
+ // result += RUN_TEST( dagmc_entity_handle); // check the entity handle correct
result += RUN_TEST( dagmc_point_in); // check entity by point
result += RUN_TEST( dagmc_rayfire ) ; // ensure ray fire distance is correct
result += RUN_TEST( dagmc_closest_to ); // check the distance to surface nearest point
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the moab-dev
mailing list