MOAB: Mesh Oriented datABase  (version 5.4.1)
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.

Defines

#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 = "unittest/test_geom.h5m"
double eps = 1.0e-6

Define Documentation

#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.

#define IS_BUILDING_MB

Definition at line 4 of file dagmc_rayfire_test.cpp.


Function Documentation

Definition at line 49 of file dagmc_rayfire_test.cpp.

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

{
    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 next_surf_dist;
    EntityHandle next_surf;
    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 );
}

Definition at line 62 of file dagmc_rayfire_test.cpp.

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

{
    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 next_surf_dist;
    EntityHandle next_surf;
    DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist );
    std::cout << next_surf_dist << std::endl;
    double expected_next_surf_dist = 15.0;
    CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}

Definition at line 134 of file dagmc_rayfire_test.cpp.

References CHECK_EQUAL, DAG, and origin.

Referenced by main().

{
    DagMC::RayHistory history;
    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;

    history.reset();
    // first ray fire with history
    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

    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] );

    // ray fired execacyl

    DAG->ray_fire( vol_h, 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;
    CHECK_EQUAL( ZERO, next_surf );
}

Definition at line 106 of file dagmc_rayfire_test.cpp.

References CHECK_EQUAL, DAG, and origin.

Referenced by main().

{
    DagMC::RayHistory history;
    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;

    history.reset();

    // ray fired exactly along boundary shared by 2 facets on a single surface,
    // needs two ray_fires to cross, this is expected and ok

    // first ray fire with history
    DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
    // second ray fire with history
    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
    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;
    CHECK_EQUAL( ZERO, next_surf );
}

Definition at line 91 of file dagmc_rayfire_test.cpp.

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

{
    DagMC::RayHistory history;
    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 next_surf_dist;
    EntityHandle next_surf;
    DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0.0, -1 );
    std::cout << next_surf_dist << std::endl;
    double expected_next_surf_dist = 5.0;
    CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}

Definition at line 76 of file dagmc_rayfire_test.cpp.

References CHECK_REAL_EQUAL, DAG, eps, and origin.

Referenced by main().

{
    DagMC::RayHistory history;
    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 next_surf_dist;
    EntityHandle next_surf;
    DAG->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
    std::cout << next_surf_dist << std::endl;
    double expected_next_surf_dist = 15.0;
    CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}
void dagmc_setup_test ( )

Definition at line 33 of file dagmc_rayfire_test.cpp.

References CHECK_ERR, DAG, ErrorCode, and input_file.

{
    ErrorCode rval = DAG->load_file( input_file.c_str() );  // open the Dag file
    CHECK_ERR( rval );
    rval = DAG->init_OBBTree();CHECK_ERR( rval );

    /*
    int num_vols = DAG->num_entities(3);
    EntityHandle vol_h;
    for (int i = 0; i < num_vols; i++)
      vol_h = DAG->entity_by_index(3, i);
    */
    // EntityHandle volume = 12682136550675316765;
    // CHECK_EQUAL(volume, vol);
}
int main ( int  ,
char **   
)

Definition at line 166 of file dagmc_rayfire_test.cpp.

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.

{
    int result = 0;

    DAG = new DagMC();

    result += RUN_TEST( dagmc_setup_test );  // setup problem
    // rays fired along cardinal directions
    result += RUN_TEST( dagmc_origin_face_rayfire );  // point in centre
    result += RUN_TEST( dagmc_outside_face_rayfire );
    result += RUN_TEST( dagmc_outside_face_rayfire_orient_exit );      // fire ray from point outside volume
                                                                       // looking for exit intersections
    result += RUN_TEST( dagmc_outside_face_rayfire_orient_entrance );  // fire ray from point outside volume looking
                                                                       // for entrance intersection
    result += RUN_TEST( dagmc_outside_face_rayfire_history_fail );     // fire ray from point outside
                                                                       // geometry using ray history
    result += RUN_TEST( dagmc_outside_face_rayfire_history );          // fire ray from point outside
                                                                       // geometry using ray history

    delete DAG;

    return result;
}

Variable Documentation

DagMC* DAG

Definition at line 17 of file dagmc_rayfire_test.cpp.

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

Definition at line 29 of file dagmc_rayfire_test.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines