Beginners question for manually constructed grids

29 views
Skip to first unread message

felixhag...@gmail.com

unread,
May 9, 2016, 9:26:26 AM5/9/16
to deal.II User Group

Hello everybody,

first of all, sorry for my bad English.

I have a very simple question. I want to construct my own grids. In the process, i stumbled upon this problem: I wanted to have two adjacent cells in two dimenson, one very "wide" and one very "large", so that i can do some testing with anisotropic refinement. So i made by following the (very nice) tutorials this very simple grid:

void adapt_grid_spiel()
{
    Triangulation<2> triangulation;
    static const Point<2> vertices_1[] = {
        Point<2> (0,0),
        Point<2> (10,0),
        Point<2> (12,0),
        Point<2> (13,18),
        Point<2> (10,2),
        Point<2> (0,2)
    };
    const unsigned int n_vertices = sizeof(vertices_1) / sizeof(vertices_1[0]);
    const std::vector<Point<2>> vertices (&vertices_1[0],&vertices_1[n_vertices]);
    static const int cell_vertices[][GeometryInfo<2>::vertices_per_cell] =
    {
            {0,5,4,1},{1,2,3,4}
    };
    std::vector<CellData<2>> cells(2, CellData<2>());
    for (unsigned int i=0; i<2; ++i)
    {
        for(unsigned int j =0;j<GeometryInfo<2>::vertices_per_cell; ++j)
        cells[i].vertices[j] = cell_vertices[i][j];
    }
    triangulation.create_triangulation(vertices,cells,SubCellData());


    std::ofstream out ("grid-3.eps");
    GridOut grid_out;
    grid_out.write_eps (triangulation, out);
    std::cout << "Grid written to grid-3.eps.\n";

}

If i run this, i get the following picture. In every other grid, i created manually by selecting vertices and cells, i had no crossing faces (lines). I can't find my mistake.

I would be very glad, if somebody could help me. :)

With kind regards,
Felix Hagemann

felixhag...@gmail.com

unread,
May 9, 2016, 9:37:23 AM5/9/16
to deal.II User Group
PS: By re-arranging the vertices like


static const int cell_vertices[][GeometryInfo<2>::vertices_per_cell] =
    {
            {0,5,1,4},{1,4,2,3}
    };

i got the right result. But why? :)

Bruno Turcksin

unread,
May 9, 2016, 9:39:48 AM5/9/16
to deal.II User Group
Felix,

you cannot order the cell the way you want. Deal.II expects a given order. See https://dealii.org/developer/doxygen/deal.II/structGeometryInfo.html

Best,

Bruno

felixhag...@gmail.com

unread,
May 10, 2016, 1:53:28 AM5/10/16
to deal.II User Group
Thank you very much. :-)

I was searching for "that" page, but unable to find it myself.
Reply all
Reply to author
Forward
0 new messages