|
MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include "TestUtil.hpp"#include "moab/Core.hpp"#include "MBTagConventions.hpp"#include "ReadIDEAS.hpp"#include "moab/Range.hpp"#include <cmath>#include <algorithm>
Include dependency graph for ideas_test.cpp:Go to the source code of this file.
Defines | |
| #define | IS_BUILDING_MB |
Functions | |
| void | read_file (Interface &moab, const char *input_file) |
| void | test_read_nodes () |
| void | test_read_tets () |
| void | test_read_hexes () |
| void | test_read_material_set () |
| void | test_read_physical_set () |
| int | main () |
Variables | |
| static const char | example [] = "test.unv" |
| #define IS_BUILDING_MB |
Definition at line 4 of file ideas_test.cpp.
| int main | ( | ) |
Definition at line 25 of file ideas_test.cpp.
References RUN_TEST, test_read_hexes(), test_read_material_set(), test_read_nodes(), test_read_physical_set(), and test_read_tets().
{
int result = 0;
result += RUN_TEST( test_read_nodes );
result += RUN_TEST( test_read_tets );
result += RUN_TEST( test_read_hexes );
result += RUN_TEST( test_read_material_set );
result += RUN_TEST( test_read_physical_set );
return result;
}
| void test_read_hexes | ( | ) |
Definition at line 236 of file ideas_test.cpp.
References CHECK_ARRAYS_EQUAL, CHECK_EQUAL, CHECK_ERR, ErrorCode, example, moab::Interface::get_connectivity(), moab::Interface::get_entities_by_type(), moab::Interface::globalId_tag(), MBHEX, read_file(), and moab::Interface::tag_get_data().
Referenced by main().
{
ErrorCode rval;
Core moab;
Interface& mb = moab;
read_file( moab, example );
std::vector< EntityHandle > hexes;
rval = mb.get_entities_by_type( 0, MBHEX, hexes );CHECK_ERR( rval );
CHECK_EQUAL( (size_t)2, hexes.size() );
Tag id_tag = mb.globalId_tag();
std::vector< int > ids( hexes.size() );
rval = mb.tag_get_data( id_tag, &hexes[0], hexes.size(), &ids[0] );CHECK_ERR( rval );
int vtx_ids[8];
const EntityHandle* conn;
int len;
const int conn1[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
int pos = 0, offset = 1;
// Element id 1 is a hex
CHECK_EQUAL( pos + offset, ids[pos] );
rval = mb.get_connectivity( hexes[pos], conn, len );CHECK_ERR( rval );
CHECK_EQUAL( 8, len );
rval = mb.tag_get_data( id_tag, conn, len, vtx_ids );CHECK_ERR( rval );
CHECK_ARRAYS_EQUAL( conn1, 8, vtx_ids, len );
const int conn2[] = { 2, 9, 10, 3, 6, 11, 12, 7 };
++pos;
// Element id 2 is a hex
CHECK_EQUAL( pos + offset, ids[pos] );
rval = mb.get_connectivity( hexes[pos], conn, len );CHECK_ERR( rval );
CHECK_EQUAL( 8, len );
rval = mb.tag_get_data( id_tag, conn, len, vtx_ids );CHECK_ERR( rval );
CHECK_ARRAYS_EQUAL( conn2, 8, vtx_ids, len );
}
| void test_read_material_set | ( | ) |
| void test_read_nodes | ( | ) |
| void test_read_physical_set | ( | ) |
Definition at line 302 of file ideas_test.cpp.
References CHECK_EQUAL, CHECK_ERR, ErrorCode, example, moab::Range::front(), moab::Interface::get_entities_by_handle(), moab::Interface::get_entities_by_type(), moab::Interface::get_entities_by_type_and_tag(), MB_TYPE_INTEGER, MBENTITYSET, MBTET, PHYS_PROP_TABLE_TAG, read_file(), moab::Range::size(), and moab::Interface::tag_get_handle().
Referenced by main().
{
ErrorCode rval;
Core moab;
Interface& mb = moab;
read_file( moab, example );
Tag phys_tag;
rval = mb.tag_get_handle( PHYS_PROP_TABLE_TAG, 1, MB_TYPE_INTEGER, phys_tag );CHECK_ERR( rval );
Range phys_set;
const int phys_set_id = 4;
const void* const phys_set_id_val[] = { &phys_set_id };
rval = mb.get_entities_by_type_and_tag( 0, MBENTITYSET, &phys_tag, phys_set_id_val, 1, phys_set );CHECK_ERR( rval );
CHECK_EQUAL( 1, (int)phys_set.size() );
std::vector< EntityHandle > tets, contents;
rval = mb.get_entities_by_type( 0, MBTET, tets );CHECK_ERR( rval );
rval = mb.get_entities_by_handle( phys_set.front(), contents );CHECK_ERR( rval );
std::sort( tets.begin(), tets.end() );
std::sort( contents.begin(), contents.end() );
CHECK_EQUAL( tets, contents );
}
| void test_read_tets | ( | ) |
Definition at line 191 of file ideas_test.cpp.
References CHECK_ARRAYS_EQUAL, CHECK_EQUAL, CHECK_ERR, ErrorCode, example, moab::Interface::get_connectivity(), moab::Interface::get_entities_by_type(), moab::Interface::globalId_tag(), MBTET, read_file(), swap(), and moab::Interface::tag_get_data().
Referenced by main().
{
ErrorCode rval;
Core moab;
Interface& mb = moab;
read_file( moab, example );
std::vector< EntityHandle > tets;
rval = mb.get_entities_by_type( 0, MBTET, tets );CHECK_ERR( rval );
CHECK_EQUAL( (size_t)2, tets.size() );
Tag id_tag = mb.globalId_tag();
std::vector< int > ids( tets.size() );
rval = mb.tag_get_data( id_tag, &tets[0], tets.size(), &ids[0] );CHECK_ERR( rval );
if( ids[0] != 3 )
{
std::swap( ids[0], ids[1] );
std::swap( tets[0], tets[1] );
}
int vtx_ids[4];
const EntityHandle* conn;
int len;
// The first tet has id=3
const int conn1[] = { 13, 14, 15, 16 };
int pos = 0, offset = 3;
CHECK_EQUAL( pos + offset, ids[pos] );
rval = mb.get_connectivity( tets[pos], conn, len );CHECK_ERR( rval );
CHECK_EQUAL( 4, len );
rval = mb.tag_get_data( id_tag, conn, len, vtx_ids );CHECK_ERR( rval );
CHECK_ARRAYS_EQUAL( conn1, 4, vtx_ids, len );
// The second tet has id=4
const int conn2[] = { 13, 17, 14, 16 };
++pos;
CHECK_EQUAL( pos + offset, ids[pos] );
rval = mb.get_connectivity( tets[pos], conn, len );CHECK_ERR( rval );
CHECK_EQUAL( 4, len );
rval = mb.tag_get_data( id_tag, conn, len, vtx_ids );CHECK_ERR( rval );
CHECK_ARRAYS_EQUAL( conn2, 4, vtx_ids, len );
}
const char example[] = "test.unv" [static] |
Definition at line 15 of file ideas_test.cpp.