Wrong vertices at the boundary

24 views
Skip to first unread message

Masoud Ahmadi

unread,
Dec 16, 2021, 7:13:25 AM12/16/21
to deal.II User Group
Hi All,

I'm trying to get the vertices of faces at the boundary; however, something goes wrong.
For example, consider a simple mesh for a square of 4X4 as:

GridGenerator::hyper_cube(triangulation, -1, 1);
triangulation.refine_global(2);

Then, we say:

for (const auto &cell : dof_handler.active_cell_iterators()){
for (const auto &face : cell->face_iterators()){
if (face->at_boundary()){
for (const auto v : face->vertex_indices())
cout<<cell->vertex(v)<<" ";
cout<<endl;
}
}
}

We get the following results (after eliminating the repetitive ones):
-1 -1 -0.5 -1
-0.5 -1 0 -1
-1 -0.5 -0.5 -0.5
0 -1 0.5 -1
0.5 -1 1 -1
0.5 -0.5 1 -0.5
-1 0 -0.5 0
-1 0.5 -0.5 0.5
-0.5 0.5 0 0.5
0.5 0 1 0
0 0.5 0.5 0.5
0.5 0.5 1 0.5

which means, instead of these vertices:
1.png

we are getting these vertices:
2.png

Where did I make a mistake?

Best regards,
Masoud

Praveen C

unread,
Dec 16, 2021, 8:31:13 AM12/16/21
to Deal. II Googlegroup
There is a small error in this code.


On 16-Dec-2021, at 5:43 PM, Masoud Ahmadi <masou...@gmail.com> wrote:

for (const auto &cell : dof_handler.active_cell_iterators()){
for (const auto &face : cell->face_iterators()){
if (face->at_boundary()){
for (const auto v : face->vertex_indices())
cout<<cell->vertex(v)<<" ";
cout<<endl;
}
}
}


cout<<cell->vertex(v)<<" “;

should be

cout<<face->vertex(v)<<" “;

best
praveen



Masoud Ahmadi

unread,
Dec 16, 2021, 11:06:29 AM12/16/21
to deal.II User Group
Thanks Praveen.
It was resolved.
Reply all
Reply to author
Forward
0 new messages