Your first grid

This example creates a grid handle and manually adds vertices and cells. h-refinement can be applied through adapt flag on the first cell. 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
12
Grid* grid = new Grid();
grid->addVertex({ {0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0} }); 

grid->addCell( {0, 1, 2, 3} ) ; 

for (auto i =0; i<3; ++i) {
   grid->listCell[0]->adapt = {1, 1}; 
   grid->adapt(); 
   grid->writeVTK("myFirstGrid_"); 
}
  
delete(grid); 

Above code produces the following result:

My first grid
My first grid
Tags: tutorials