MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include "TestUtil.hpp"
#include "moab/Core.hpp"
#include "MBTagConventions.hpp"
#include "moab/Range.hpp"
#include <cmath>
#include <algorithm>
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_prisms () |
void | test_read_hexes () |
void | test_read_material_set1 () |
void | test_read_material_set2 () |
int | main () |
Variables | |
static const char | example [] = "test.nas" |
#define IS_BUILDING_MB |
Definition at line 4 of file nastran_test.cpp.
int main | ( | ) |
Definition at line 25 of file nastran_test.cpp.
References RUN_TEST, test_read_hexes(), test_read_material_set1(), test_read_material_set2(), test_read_nodes(), test_read_prisms(), and test_read_tets().
{ int result = 0; result += RUN_TEST( test_read_nodes ); result += RUN_TEST( test_read_tets ); result += RUN_TEST( test_read_prisms ); result += RUN_TEST( test_read_hexes ); result += RUN_TEST( test_read_material_set1 ); result += RUN_TEST( test_read_material_set2 ); return result; }
void test_read_hexes | ( | ) |
void test_read_material_set1 | ( | ) |
Definition at line 321 of file nastran_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(), MATERIAL_SET_TAG_NAME, MB_TYPE_INTEGER, MBENTITYSET, MBTET, 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 mat_tag; rval = mb.tag_get_handle( MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, mat_tag );CHECK_ERR( rval ); Range mat_set_one; const int one = 1; const void* const one_val[] = { &one }; rval = mb.get_entities_by_type_and_tag( 0, MBENTITYSET, &mat_tag, one_val, 1, mat_set_one );CHECK_ERR( rval ); CHECK_EQUAL( 1, (int)mat_set_one.size() ); std::vector< EntityHandle > tets, contents; rval = mb.get_entities_by_type( 0, MBTET, tets );CHECK_ERR( rval ); rval = mb.get_entities_by_handle( mat_set_one.front(), contents );CHECK_ERR( rval ); std::sort( tets.begin(), tets.end() ); std::sort( contents.begin(), contents.end() ); CHECK_EQUAL( tets, contents ); }
void test_read_material_set2 | ( | ) |
Definition at line 346 of file nastran_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(), MATERIAL_SET_TAG_NAME, MB_TYPE_INTEGER, MBENTITYSET, MBPRISM, 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 mat_tag; rval = mb.tag_get_handle( MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, mat_tag );CHECK_ERR( rval ); Range mat_set_two; const int two = 2; const void* const two_val[] = { &two }; rval = mb.get_entities_by_type_and_tag( 0, MBENTITYSET, &mat_tag, two_val, 1, mat_set_two );CHECK_ERR( rval ); CHECK_EQUAL( 1, (int)mat_set_two.size() ); std::vector< EntityHandle > prisms, contents; rval = mb.get_entities_by_type( 0, MBPRISM, prisms );CHECK_ERR( rval ); rval = mb.get_entities_by_handle( mat_set_two.front(), contents );CHECK_ERR( rval ); std::sort( prisms.begin(), prisms.end() ); std::sort( contents.begin(), contents.end() ); CHECK_EQUAL( prisms, contents ); }
void test_read_nodes | ( | ) |
void test_read_prisms | ( | ) |
Definition at line 245 of file nastran_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(), MBPRISM, 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 > prisms; rval = mb.get_entities_by_type( 0, MBPRISM, prisms );CHECK_ERR( rval ); CHECK_EQUAL( (size_t)2, prisms.size() ); Tag id_tag = mb.globalId_tag(); std::vector< int > ids( prisms.size() ); rval = mb.tag_get_data( id_tag, &prisms[0], prisms.size(), &ids[0] );CHECK_ERR( rval ); if( ids[0] != 3 ) { std::swap( ids[0], ids[1] ); std::swap( prisms[0], prisms[1] ); } int vtx_ids[6]; const EntityHandle* conn; int len; const int conn1[] = { 2, 3, 4, 5, 6, 7 }; int pos = 0; // Element ids 1 and 2 are the two tet elements. // Element ids 3 and 4 are the two prism elements. CHECK_EQUAL( pos + 3, ids[pos] ); rval = mb.get_connectivity( prisms[pos], conn, len );CHECK_ERR( rval ); CHECK_EQUAL( 6, len ); rval = mb.tag_get_data( id_tag, conn, len, vtx_ids );CHECK_ERR( rval ); CHECK_ARRAYS_EQUAL( conn1, 6, vtx_ids, len ); const int conn2[] = { 5, 6, 7, 8, 9, 10 }; ++pos; CHECK_EQUAL( pos + 3, ids[pos] ); rval = mb.get_connectivity( prisms[pos], conn, len );CHECK_ERR( rval ); CHECK_EQUAL( 6, len ); rval = mb.tag_get_data( id_tag, conn, len, vtx_ids );CHECK_ERR( rval ); CHECK_ARRAYS_EQUAL( conn2, 6, vtx_ids, len ); }
void test_read_tets | ( | ) |
const char example[] = "test.nas" [static] |
Definition at line 14 of file nastran_test.cpp.