5 #if defined( __MINGW32__ )
45 if(
rank == 0 ) std::cout <<
"Success";
47 std::cout <<
"Success";
53 std::cout <<
"Failure";
62 Range verts, edges, faces, cells;
68 std::vector< EntityHandle > adjents;
69 Range mbents, ahfents;
74 std::vector< EntityHandle > ents, conn;
82 ents.push_back( *it );
94 ents.push_back( *it );
98 int nvF = conn.size();
110 ents.push_back( *it );
113 int nvF = conn.size();
130 std::sort( adjents.begin(), adjents.end() );
131 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
133 if( ahfents.
size() != mbents.
size() )
135 std::cout <<
"ahf results = " << std::endl;
137 std::cout <<
"native results = " << std::endl;
142 mbents =
subtract( mbents, ahfents );
143 if( ahfents.
size() != mbents.
size() )
163 std::sort( adjents.begin(), adjents.end() );
164 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
165 mbents =
subtract( mbents, ahfents );
181 std::sort( adjents.begin(), adjents.end() );
182 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
183 mbents =
subtract( mbents, ahfents );
198 std::sort( adjents.begin(), adjents.end() );
199 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
200 mbents =
subtract( mbents, ahfents );
214 std::sort( adjents.begin(), adjents.end() );
215 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
216 mbents =
subtract( mbents, ahfents );
230 std::sort( adjents.begin(), adjents.end() );
231 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
232 mbents =
subtract( mbents, ahfents );
249 if( adjents.size() != mbents.
size() )
258 std::sort( adjents.begin(), adjents.end() );
259 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
260 mbents =
subtract( mbents, ahfents );
274 std::sort( adjents.begin(), adjents.end() );
275 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
276 mbents =
subtract( mbents, ahfents );
291 std::sort( adjents.begin(), adjents.end() );
292 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
293 mbents =
subtract( mbents, ahfents );
307 std::sort( adjents.begin(), adjents.end() );
308 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
309 mbents =
subtract( mbents, ahfents );
323 std::sort( adjents.begin(), adjents.end() );
324 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
325 mbents =
subtract( mbents, ahfents );
340 std::sort( adjents.begin(), adjents.end() );
341 std::copy( adjents.begin(), adjents.end(),
range_inserter( ahfents ) );
342 mbents =
subtract( mbents, ahfents );
355 const int num_levels,
363 int dim[3] = { 1, 2, 3 };
368 std::stringstream file;
370 file <<
"MESH_LEVEL_0.h5m";
372 file <<
"MESH_LEVEL_0.vtk";
374 std::string str = file.str();
375 const char* output_file = str.c_str();
384 std::cout <<
"Creating a hm object" << std::endl;
387 Range averts, aedges, afaces, acells;
403 init_ents[0] = averts;
404 init_ents[1] = aedges;
405 init_ents[2] = afaces;
406 init_ents[3] = acells;
416 std::vector< EntityHandle > set;
418 std::cout <<
"Starting hierarchy generation" << std::endl;
422 std::cout <<
"Finished hierarchy generation in " << uref.
timeall.
tm_total <<
" secs" << std::endl;
426 std::cout <<
"Time taken for refinement " << uref.
timeall.
tm_refine <<
" secs" << std::endl;
427 std::cout <<
"Time taken for resolving shared interface " << uref.
timeall.
tm_resolve <<
" secs" << std::endl;
433 std::cout << std::endl;
434 std::cout <<
"Mesh size for level 0 :: inverts = " << init_ents[0].
size() <<
", inedges = " << init_ents[1].
size()
435 <<
", infaces = " << init_ents[2].
size() <<
", incells = " << init_ents[3].
size() << std::endl;
438 for(
int i = 0; i < 4; i++ )
439 prev_ents[i] = init_ents[i];
442 for(
int l = 0; l < num_levels; l++ )
448 for(
int k = 0; k < 4; k++ )
451 if( ents[0].empty() || all_ents.
empty() ) std::cout <<
"Something is not right" << std::endl;
453 std::cout << std::endl;
454 std::cout <<
"Mesh size for level " << l + 1 <<
" :: nverts = " << ents[0].
size()
455 <<
", nedges = " << ents[1].
size() <<
", nfaces = " << ents[2].
size()
456 <<
", ncells = " << ents[3].
size() << std::endl;
460 for(
int type = 1; type < 3; type++ )
463 if( !ents[type + 1].empty() )
466 for(
int p = 0; p <= l; p++ )
468 for(
int d = 0; d <
dim[type]; d++ )
469 factor *= level_degrees[p];
471 int expected_nents = factor * init_ents[type + 1].
size();
480 for(
int type = 1; type < 3; type++ )
482 if( !prev_ents[type + 1].empty() )
484 for(
Range::iterator e = prev_ents[type + 1].begin(); e != prev_ents[type + 1].
end(); e++ )
486 std::vector< EntityHandle >
children;
488 for(
int i = 0; i < (int)
children.size(); i++ )
492 assert( parent == *e );
498 for(
int i = 0; i < 4; i++ )
499 prev_ents[i] = ents[i];
534 std::stringstream file;
537 file <<
"MESH_LEVEL_" << l + 1 <<
".h5m";
539 file <<
"MESH_LEVEL_" << l + 1 <<
".vtk";
541 std::string str = file.str();
542 const char* output_file = str.c_str();
552 for(
int type = 1; type < 3; type++ )
554 if( !init_ents[type + 1].empty() )
556 for(
Range::iterator e = init_ents[type + 1].begin(); e != init_ents[type + 1].
end(); e++ )
558 std::vector< EntityHandle >
children;
560 for(
int i = 0; i < (int)
children.size(); i++ )
564 assert( parent == *e );
588 const double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
589 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
591 const int conn[] = { 0, 1 };
592 const size_t num_elems =
sizeof( conn ) /
sizeof( conn[0] ) / 2;
594 std::cout <<
"Specify verts and ents" << std::endl;
597 for(
size_t i = 0; i < num_vtx; ++i )
602 std::cout <<
"Created vertices" << std::endl;
604 for(
size_t i = 0; i < num_elems; ++i )
607 c[0] = verts[conn[0]];
608 c[1] = verts[conn[1]];
613 std::cout <<
"Created ents" << std::endl;
615 else if( type ==
MBTRI )
617 const double coords[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0 };
618 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
620 const int conn[] = { 0, 1, 2 };
621 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 3;
624 for(
size_t i = 0; i < num_vtx; ++i )
630 for(
size_t i = 0; i < num_elems; ++i )
633 for(
int j = 0; j < 3; j++ )
634 c[j] = verts[conn[3 * i + j]];
641 const double coords[] = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0 };
642 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
644 const int conn[] = { 0, 1, 2, 3 };
645 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 3;
648 for(
size_t i = 0; i < num_vtx; ++i )
653 for(
size_t i = 0; i < num_elems; ++i )
656 for(
int j = 0; j < 4; j++ )
657 c[j] = verts[conn[j]];
662 else if( type ==
MBTET )
664 const double coords[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 };
666 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
668 const int conn[] = { 0, 1, 2, 3 };
669 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 4;
672 for(
size_t i = 0; i < num_vtx; ++i )
677 for(
size_t i = 0; i < num_elems; ++i )
680 for(
int j = 0; j < 4; j++ )
681 c[j] = verts[conn[j]];
686 else if( type ==
MBHEX )
688 const double coords[] = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1 };
689 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
691 const int conn[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
692 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 8;
695 for(
size_t i = 0; i < num_vtx; ++i )
700 for(
size_t i = 0; i < num_elems; ++i )
703 for(
int j = 0; j < 8; j++ )
704 c[j] = verts[conn[j]];
717 const double coords[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, -1, 0 };
718 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
720 const int conn[] = { 1, 0, 0, 3, 2, 0, 0, 4 };
721 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 2;
724 for(
size_t i = 0; i < num_vtx; ++i )
729 for(
size_t i = 0; i < num_elems; ++i )
732 c[0] = verts[conn[2 * i]];
733 c[1] = verts[conn[2 * i + 1]];
738 else if( type ==
MBTRI )
740 const double coords[] = { 0, 0, 0, 1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 0, 0, 1 };
742 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
744 const int conn[] = { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 1, 0, 5, 3, 0, 2, 5, 0, 4, 5, 0, 5, 1 };
746 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 3;
749 for(
size_t i = 0; i < num_vtx; ++i )
754 for(
size_t i = 0; i < num_elems; ++i )
757 for(
int j = 0; j < 3; j++ )
758 c[j] = verts[conn[3 * i + j]];
765 const double coords[] = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, -1, 1, 0, -1, 0, 0,
766 -1, -1, 0, 0, -1, 0, 1, -1, 0, 0, 1, 1, 0, 0, 1, 0, -1, 1 };
768 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
770 const int conn[] = { 0, 1, 2, 3, 0, 3, 4, 5, 7, 8, 1, 0, 6, 7, 0, 5, 0, 3, 9, 10, 0, 10, 11, 7 };
772 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 4;
775 for(
size_t i = 0; i < num_vtx; ++i )
780 for(
size_t i = 0; i < num_elems; ++i )
783 for(
int j = 0; j < 4; j++ )
784 c[j] = verts[conn[4 * i + j]];
789 else if( type ==
MBTET )
791 const double coords[] = { 0, -1, 0, 0, 2, 0, 1, 0, 0, -0.5, 0, 0, 0, 0, 1, 0, 0, -2 };
793 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
795 const int conn[] = { 0, 2, 1, 4, 3, 0, 1, 4, 5, 2, 1, 0, 5, 0, 1, 3 };
797 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 4;
800 for(
size_t i = 0; i < num_vtx; ++i )
805 for(
size_t i = 0; i < num_elems; ++i )
808 for(
int j = 0; j < 4; j++ )
809 c[j] = verts[conn[4 * i + j]];
814 else if( type ==
MBHEX )
816 const double coords[] = { 0, -1, 0, 1, -1, 0, 1, 1, 0, 0, 1, 0, -1, 1, 0, -1, -1, 0,
817 0, -1, 1, 1, -1, 1, 1, 1, 1, 0, 1, 1, -1, 1, 1, -1, -1, 1,
818 0, -1, -1, 1, -1, -1, 1, 1, -1, 0, 1, -1, -1, 1, -1, -1, -1, -1 };
819 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
821 const int conn[] = { 0, 1, 2, 3, 6, 7, 8, 9, 5, 0, 3, 4, 11, 6, 9, 10,
822 12, 13, 14, 15, 0, 1, 2, 3, 17, 12, 15, 16, 5, 0, 3, 4 };
823 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 8;
826 for(
size_t i = 0; i < num_vtx; ++i )
831 for(
size_t i = 0; i < num_elems; ++i )
834 for(
int j = 0; j < 8; j++ )
835 c[j] = verts[conn[8 * i + j]];
848 const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0,
849 4, 1, 0, 3, 1, 0, 2, 1, 0, 1, 1, 0, 0, 1, 0 };
850 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
852 const int conn[] = { 1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0 };
853 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 2;
856 for(
size_t i = 0; i < num_vtx; ++i )
861 for(
size_t i = 0; i < num_elems; ++i )
864 c[0] = verts[conn[2 * i]];
865 c[1] = verts[conn[2 * i + 1]];
870 else if( type ==
MBTRI )
872 const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 2.5, 1, 0, 1.5, 1, 0, 0.5, 1,
873 0, -0.5, 1, 0, -0.5, -1, 0, 0.5, -1, 0, 1.5, -1, 0, 2.5, -1, 0 };
875 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
877 const int conn[] = { 0, 5, 6, 0, 1, 5, 1, 4, 5, 1, 2, 4, 2, 3, 4,
878 7, 8, 0, 8, 1, 0, 8, 9, 1, 9, 2, 1, 9, 10, 2 };
880 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 3;
883 for(
size_t i = 0; i < num_vtx; ++i )
888 for(
size_t i = 0; i < num_elems; ++i )
891 for(
int j = 0; j < 3; j++ )
892 c[j] = verts[conn[3 * i + j]];
899 const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0,
900 3, 1, 0, 4, 1, 0, 5, 1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0, 3, 2, 0, 4, 2, 0, 5, 2, 0 };
902 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
904 const int conn[] = { 0, 1, 7, 6, 1, 2, 8, 7, 2, 3, 9, 8, 3, 4, 10, 9, 4, 5, 11, 10,
905 6, 7, 13, 12, 7, 8, 14, 13, 8, 9, 15, 14, 9, 10, 16, 15, 10, 11, 17, 16 };
907 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 4;
910 for(
size_t i = 0; i < num_vtx; ++i )
915 for(
size_t i = 0; i < num_elems; ++i )
918 for(
int j = 0; j < 4; j++ )
919 c[j] = verts[conn[4 * i + j]];
924 else if( type ==
MBTET )
926 const double coords[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1 };
928 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
930 const int conn[] = { 0, 1, 2, 5, 3, 0, 2, 5, 4, 1, 0, 5, 4, 0, 3, 5 };
932 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 4;
935 for(
size_t i = 0; i < num_vtx; ++i )
940 for(
size_t i = 0; i < num_elems; ++i )
943 for(
int j = 0; j < 4; j++ )
944 c[j] = verts[conn[4 * i + j]];
949 else if( type ==
MBHEX )
951 const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0,
952 0, 0, 1, 1, 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 0, 2, 1, 1, 2, 1, 2, 2, 1 };
953 const size_t num_vtx =
sizeof( coords ) /
sizeof(
double ) / 3;
955 const int conn[] = { 0, 1, 4, 3, 9, 10, 13, 12, 1, 2, 5, 4, 10, 11, 14, 13,
956 3, 4, 7, 6, 12, 13, 16, 15, 4, 5, 8, 7, 13, 14, 17, 16 };
957 const size_t num_elems =
sizeof( conn ) /
sizeof(
int ) / 8;
960 for(
size_t i = 0; i < num_vtx; ++i )
965 for(
size_t i = 0; i < num_elems; ++i )
968 for(
int j = 0; j < 8; j++ )
969 c[j] = verts[conn[8 * i + j]];
988 std::cout <<
"Entity created successfully" << std::endl;
990 else if( mesh_type == 2 )
994 std::cout <<
"Small mesh created successfully" << std::endl;
996 else if( mesh_type == 3 )
1000 std::cout <<
"Small simple mesh created successfully" << std::endl;
1013 std::cout <<
"Testing EDGE" << std::endl;
1014 EntityType type =
MBEDGE;
1016 std::cout <<
"Testing single entity" << std::endl;
1017 int deg[3] = { 2, 3, 5 };
1018 int len =
sizeof( deg ) /
sizeof(
int );
1021 std::cout << std::endl;
1022 std::cout <<
"Testing a small mesh" << std::endl;
1025 std::cout << std::endl;
1026 std::cout <<
"Testing a small simple mesh" << std::endl;
1027 int degree[4] = { 5, 5, 2, 2 };
1028 len =
sizeof( degree ) /
sizeof(
int );
1038 std::cout <<
"Testing TRI" << std::endl;
1039 EntityType type =
MBTRI;
1041 std::cout <<
"Testing single entity" << std::endl;
1042 int deg[3] = { 2, 3, 5 };
1043 int len =
sizeof( deg ) /
sizeof(
int );
1046 std::cout << std::endl;
1047 std::cout <<
"Testing a small mesh" << std::endl;
1050 std::cout << std::endl;
1051 std::cout <<
"Testing a small simple mesh" << std::endl;
1052 int degree[2] = { 5, 2 };
1053 int length =
sizeof( degree ) /
sizeof(
int );
1056 std::cout << std::endl;
1057 std::cout <<
"Testing QUAD" << std::endl;
1060 std::cout <<
"Testing single entity" << std::endl;
1063 std::cout << std::endl;
1064 std::cout <<
"Testing a small mesh" << std::endl;
1067 std::cout << std::endl;
1068 std::cout <<
"Testing a small simple mesh" << std::endl;
1078 std::cout <<
"Testing TET" << std::endl;
1079 EntityType type =
MBTET;
1080 int deg[2] = { 2, 3 };
1081 int len =
sizeof( deg ) /
sizeof(
int );
1083 std::cout <<
"Testing single entity" << std::endl;
1086 std::cout << std::endl;
1087 std::cout <<
"Testing a small mesh" << std::endl;
1090 std::cout << std::endl;
1091 std::cout <<
"Testing a small simple mesh" << std::endl;
1092 int degree[4] = { 2, 2, 2, 2 };
1093 int length =
sizeof( degree ) /
sizeof(
int );
1096 std::cout << std::endl;
1097 std::cout <<
"Testing HEX" << std::endl;
1100 std::cout <<
"Testing single entity" << std::endl;
1103 std::cout << std::endl;
1104 std::cout <<
"Testing a small mesh" << std::endl;
1107 std::cout << std::endl;
1108 std::cout <<
"Testing a small simple mesh" << std::endl;
1124 #ifdef MOAB_HAVE_MPI
1135 read_options =
"PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS";
1140 std::set< unsigned int > shprocs;
1142 std::cout <<
"#sprocs = " << shprocs.size() << std::endl;
1145 else if( procs == 1 )
1149 #ifdef MOAB_HAVE_MPI
1161 #ifdef MOAB_HAVE_MPI
1162 MPI_Init( &argc, &argv );
1184 else if( argc == 2 )
1188 int len =
sizeof( deg ) /
sizeof(
int );
1194 #ifdef MOAB_HAVE_MPI