This example creates two grids; one formed by quads, named as volgrid; and the other formed by line strings, named as surf. volgrid is formed by a an automated block generation utility in 2D, called Block2, while surf is generated by manually adding vertices and cells. The output is written in VTK format to be visualized in additional software, i.e. Paraview.

1
2
3
4
5
6
7
8
9
10
11
 Block2* volgrid = new Block2({0,0,0}, {1,1,0}, 10, 10); 
 Grid* surf = new Grid(); 

 surf->addVertex( { {0.5,0.4}, {0.6,0.5}, {0.5,0.6}, {0.4,0.5} } ); 
 surf->addCell( { {0,1}, {1,2}, {2,3}, {3,0} } ); 

 volgrid->writeVTK("vol"); 
 surf->writeVTK("surf"); 

 delete(volgrid); 
 delete(surf); 

Above code produces the following result:

My first grid
My first grid
Tags: tutorials