MOAB: Mesh Oriented datABase  (version 5.5.0)
dagmc_rayfire_test.cpp File Reference
#include <iostream>
#include "moab/Interface.hpp"
#include "TestUtil.hpp"
#include "Internals.hpp"
#include "moab/Core.hpp"
#include "moab/GeomQueryTool.hpp"
#include "DagMC.hpp"
+ Include dependency graph for dagmc_rayfire_test.cpp:

Go to the source code of this file.

Macros

#define IS_BUILDING_MB
 
#define CHKERR(A)
 

Functions

void dagmc_setup_test ()
 
void dagmc_origin_face_rayfire ()
 
void dagmc_outside_face_rayfire ()
 
void dagmc_outside_face_rayfire_orient_exit ()
 
void dagmc_outside_face_rayfire_orient_entrance ()
 
void dagmc_outside_face_rayfire_history_fail ()
 
void dagmc_outside_face_rayfire_history ()
 
int main (int, char **)
 

Variables

DagMC * DAG
 
std::string input_file = TestDir + "unittest/test_geom.h5m"
 
double eps = 1.0e-6
 

Macro Definition Documentation

◆ CHKERR

#define CHKERR (   A)
Value:
do \
{ \
if( MB_SUCCESS != ( A ) ) \
{ \
std::cerr << "Failure (error code " << ( A ) << ") at " __FILE__ ":" << __LINE__ << std::endl; \
return A; \
} \
} while( false )

Definition at line 19 of file dagmc_rayfire_test.cpp.

◆ IS_BUILDING_MB

#define IS_BUILDING_MB

Definition at line 4 of file dagmc_rayfire_test.cpp.

Function Documentation

◆ dagmc_origin_face_rayfire()

void dagmc_origin_face_rayfire ( )

Definition at line 49 of file dagmc_rayfire_test.cpp.

50 {
51  int vol_idx = 1;
52  EntityHandle vol_h = DAG->entity_by_index( 3, vol_idx );
53  double dir[3] = { -1.0, 0.0, 0.0 };
54  double origin[3] = { 0.0, 0.0, 0.0 };
55  double next_surf_dist;
56  EntityHandle next_surf;
57  DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist );
58  double expected_next_surf_dist = 5.0;
59  CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
60 }

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

◆ dagmc_outside_face_rayfire()

void dagmc_outside_face_rayfire ( )

Definition at line 62 of file dagmc_rayfire_test.cpp.

63 {
64  int vol_idx = 1;
65  EntityHandle vol_h = DAG->entity_by_index( 3, vol_idx );
66  double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
67  double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
68  double next_surf_dist;
69  EntityHandle next_surf;
70  DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist );
71  std::cout << next_surf_dist << std::endl;
72  double expected_next_surf_dist = 15.0;
73  CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
74 }

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

◆ dagmc_outside_face_rayfire_history()

void dagmc_outside_face_rayfire_history ( )

Definition at line 134 of file dagmc_rayfire_test.cpp.

135 {
136  DagMC::RayHistory history;
137  int vol_idx = 1;
138  EntityHandle vol_h = DAG->entity_by_index( 3, vol_idx );
139  double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
140  double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
141  double xyz[3];
142  double next_surf_dist;
143  EntityHandle next_surf;
144 
145  history.reset();
146  // first ray fire with history
147  DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
148  std::cout << next_surf << " " << history.size() << std::endl;
149  // second ray fire with history
150 
151  xyz[0] = origin[0] + ( next_surf_dist * dir[0] );
152  xyz[1] = origin[1] + ( next_surf_dist * dir[1] );
153  xyz[2] = origin[2] + ( next_surf_dist * dir[2] );
154 
155  // ray fired execacyl
156 
157  DAG->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
158 
159  DAG->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
160 
161  // using history with this geom, there should be no next surface, i.e. 0
162  EntityHandle ZERO = 0;
163  CHECK_EQUAL( ZERO, next_surf );
164 }

References CHECK_EQUAL, DAG, and origin.

Referenced by main().

◆ dagmc_outside_face_rayfire_history_fail()

void dagmc_outside_face_rayfire_history_fail ( )

Definition at line 106 of file dagmc_rayfire_test.cpp.

107 {
108  DagMC::RayHistory history;
109  int vol_idx = 1;
110  EntityHandle vol_h = DAG->entity_by_index( 3, vol_idx );
111  double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
112  double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
113  double xyz[3];
114  double next_surf_dist;
115  EntityHandle next_surf;
116 
117  history.reset();
118 
119  // ray fired exactly along boundary shared by 2 facets on a single surface,
120  // needs two ray_fires to cross, this is expected and ok
121 
122  // first ray fire with history
123  DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
124  // second ray fire with history
125  DAG->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
126  // this fire should hit graveyard, i.e. next_surf = 0
127  DAG->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
128 
129  // using history with this geom, there should be no next surface, i.e. 0
130  EntityHandle ZERO = 0;
131  CHECK_EQUAL( ZERO, next_surf );
132 }

References CHECK_EQUAL, DAG, and origin.

Referenced by main().

◆ dagmc_outside_face_rayfire_orient_entrance()

void dagmc_outside_face_rayfire_orient_entrance ( )

Definition at line 91 of file dagmc_rayfire_test.cpp.

92 {
93  DagMC::RayHistory history;
94  int vol_idx = 1;
95  EntityHandle vol_h = DAG->entity_by_index( 3, vol_idx );
96  double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
97  double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
98  double next_surf_dist;
99  EntityHandle next_surf;
100  DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0.0, -1 );
101  std::cout << next_surf_dist << std::endl;
102  double expected_next_surf_dist = 5.0;
103  CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
104 }

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

◆ dagmc_outside_face_rayfire_orient_exit()

void dagmc_outside_face_rayfire_orient_exit ( )

Definition at line 76 of file dagmc_rayfire_test.cpp.

77 {
78  DagMC::RayHistory history;
79  int vol_idx = 1;
80  EntityHandle vol_h = DAG->entity_by_index( 3, vol_idx );
81  double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
82  double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
83  double next_surf_dist;
84  EntityHandle next_surf;
85  DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
86  std::cout << next_surf_dist << std::endl;
87  double expected_next_surf_dist = 15.0;
88  CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
89 }

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

◆ dagmc_setup_test()

void dagmc_setup_test ( )

Definition at line 33 of file dagmc_rayfire_test.cpp.

34 {
35  ErrorCode rval = DAG->load_file( input_file.c_str() ); // open the Dag file
36  CHECK_ERR( rval );
37  rval = DAG->init_OBBTree();CHECK_ERR( rval );
38 
39  /*
40  int num_vols = DAG->num_entities(3);
41  EntityHandle vol_h;
42  for (int i = 0; i < num_vols; i++)
43  vol_h = DAG->entity_by_index(3, i);
44  */
45  // EntityHandle volume = 12682136550675316765;
46  // CHECK_EQUAL(volume, vol);
47 }

References CHECK_ERR, DAG, ErrorCode, and input_file.

Referenced by main().

◆ main()

int main ( int  ,
char **   
)

Definition at line 166 of file dagmc_rayfire_test.cpp.

167 {
168  int result = 0;
169 
170  DAG = new DagMC();
171 
172  result += RUN_TEST( dagmc_setup_test ); // setup problem
173  // rays fired along cardinal directions
174  result += RUN_TEST( dagmc_origin_face_rayfire ); // point in centre
176  result += RUN_TEST( dagmc_outside_face_rayfire_orient_exit ); // fire ray from point outside volume
177  // looking for exit intersections
178  result += RUN_TEST( dagmc_outside_face_rayfire_orient_entrance ); // fire ray from point outside volume looking
179  // for entrance intersection
180  result += RUN_TEST( dagmc_outside_face_rayfire_history_fail ); // fire ray from point outside
181  // geometry using ray history
182  result += RUN_TEST( dagmc_outside_face_rayfire_history ); // fire ray from point outside
183  // geometry using ray history
184 
185  delete DAG;
186 
187  return result;
188 }

References DAG, dagmc_origin_face_rayfire(), dagmc_outside_face_rayfire(), dagmc_outside_face_rayfire_history(), dagmc_outside_face_rayfire_history_fail(), dagmc_outside_face_rayfire_orient_entrance(), dagmc_outside_face_rayfire_orient_exit(), dagmc_setup_test(), and RUN_TEST.

Variable Documentation

◆ DAG

◆ eps

◆ input_file

std::string input_file = TestDir + "unittest/test_geom.h5m"

Definition at line 29 of file dagmc_rayfire_test.cpp.

Referenced by dagmc_setup_test().