beginner tutorial, example 1: Demonstrates constructing/saving a simple 2x2x2 hex meshThis example creates a 2x2x2 mesh (uniform grid) and writes it out to a VTK file and an H5M file. Each cell is of size 1x1x1 and is axis aligned. This example demonstrates how to manually create a mesh using the unstructured mesh interface. The mesh is then written out to file.
#include <iostream>
{
const unsigned NUMVTX = 27;
const unsigned NUMHEX = 8;
const double vertex_coords[3 * NUMVTX] = {
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,
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,
0, 0, 2, 1, 0, 2, 2, 0, 2, 0, 1, 2, 1, 1, 2, 2, 1, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2 };
std::cout << "Created 27 vertex entities:" << vertex_handles;
moab::EntityHandle conn[NUMHEX][8] = { { 0, 1, 4, 3, 9, 10, 13, 12 }, { 1, 2, 5, 4, 10, 11, 14, 13 },
{ 3, 4, 7, 6, 12, 13, 16, 15 }, { 4, 5, 8, 7, 13, 14, 17, 16 },
{ 9, 10, 13, 12, 18, 19, 22, 21 }, { 10, 11, 14, 13, 19, 20, 23, 22 },
{ 12, 13, 16, 15, 21, 22, 25, 24 }, { 13, 14, 17, 16, 22, 23, 26, 25 } };
for( unsigned i = 0; i < NUMHEX; ++i )
{
for( unsigned j = 0; j < 8; ++j )
{
conn[i][j] = conn[i][j] + first_vertex_handle;
}
}
for( unsigned i = 0; i < NUMHEX; ++i )
{
hexahedron_handles.
insert( element );
}
std::cout << "Created HEX8 entities: " << hexahedron_handles;
return 0;
}