Hi Shahab,

I think this problem does not come from the vertex_to_cell_map but from the way you try to use it to find the neighbors. After calling vertex_to_cell_map you do not need to call GridTools::find_active_cell_around_point, because you already now the cells a vertex belongs to. Try the following modified code instead:

*********************
int iter3=0;
const auto v_to_c   = GridTools::vertex_to_cell_map(tr);

for (Triangulation<3>::active_cell_iterator cell = tr.begin_active(); cell != tr.end(); ++cell)
    {
        for (unsigned int v = 0; v < GeometryInfo<3>::vertices_per_cell; ++v)
        {
             for (const auto &neighbor: v_to_c[cell->vertex_index(v)])
                std::cout<<"a neighbor of " << cell->id() <<"is : " << neighbor->id()<<std::endl;
        }
                    iter3++;
    }
**********************************

You will notice that some cells appear more than once. That is because they are vertex neigbors to the current cell for more than one vertex. If you need to remove duplication you can collect the neighbors of the current cell in a std::set, which removes all duplications.

Hope that helps,

Best,

Rene


On 10/25/19 1:09 PM, Shahab Golshan wrote:
Hi Rene,
I have a problem in finding the list neighbor cells. This is the code I wrote:
*********************
int iter3=0;
for (Triangulation<3>::active_cell_iterator cell = tr.begin_active(); cell != tr.end(); ++cell)
    {
        for (unsigned int v = 0; v < GeometryInfo<3>::vertices_per_cell; ++v)
        {
                auto v_to_c   = GridTools::vertex_to_cell_map(tr);
                auto v_to_c_d = GridTools::vertex_to_cell_centers_directions(tr, v_to_c);                 auto c_and_p = GridTools::find_active_cell_around_point( mappinggg, tr, cell->vertex(v), v_to_c, v_to_c_d);
                auto pcell = c_and_p.first;
                std::cout<<"a neighbor of " << cell->id() <<"is : " << pcell->id()<<std::endl;
        }
                    iter3++;
    }
**********************************
The problem is when I print the neighbors of each cell in the terminal, in the neighbors list for each cell only the cells with smaller ids comparing to the main cell are illustrated. For instance: for the neighbors of cell 0_3:765 only the cells: 0_3:742, 0_3:743, 0_3:760, 0_3:761, 0_3:746, 0_3:747 and 0_3:744 are shown.
Do you have any idea about the reason?

Best
Shahab
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/U49iAg--i8M/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/e0ddc6e9-f2ec-495b-9787-8887922d66c2%40googlegroups.com <https://groups.google.com/d/msgid/dealii/e0ddc6e9-f2ec-495b-9787-8887922d66c2%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Rene Gassmoeller
https://gassmoeller.github.io/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/d27b8414-9a8f-2b20-8963-7c1cbdc78163%40mailbox.org.

Reply via email to