Particle contact detection

57 views
Skip to first unread message

Shahab Golshan

unread,
Oct 14, 2019, 12:55:23 AM10/14/19
to deal.II User Group
Dear all,
I am writing a code for handling collisions between large numbers of particles.
I need to find all the available classes in dealII, which might be useful.
These classes may include methods to find neighbor particles in the system or calculation of particles' overlap during a collision.
Any information would be appreciated.
Best
Shahab

Luca Heltai

unread,
Oct 14, 2019, 3:07:08 AM10/14/19
to dea...@googlegroups.com
Take a look at the Particles namespace, and at the rtree boost documentation (we wrap rtree from boost into the RTree alias, which is compatible with Point<dim>, BoundingBox<dim> and Segment<dim>).

The tests/boost directory contains some examples that may be useful. 

Luca
--
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 dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/e0a2bf26-e56a-408a-84a7-914b9c7c488a%40googlegroups.com.

Rene Gassmöller

unread,
Oct 15, 2019, 4:53:23 PM10/15/19
to deal.II User Group
Hi Shahab,

Adding to Luca's reply you probably want to look into the `ParticleHandler` class, in particular the `particles_in_cell` function that returns you all particles in a given cell (https://dealii.org/developer/doxygen/deal.II/classParticles_1_1ParticleHandler.html#acaf1232ffce0746baa64122a5c65822e). By looping through the cell's neighbors you can also find all particles in neighbor cells.

Best,
Rene

Shahab Golshan

unread,
Oct 18, 2019, 12:08:44 PM10/18/19
to deal.II User Group
Hi Rene,
Thank you very much for your answer, it was very helpful.
Best,
Shahab

Shahab Golshan

unread,
Oct 25, 2019, 4:09:42 PM10/25/19
to deal.II User Group
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

Rene Gassmoeller

unread,
Oct 25, 2019, 4:42:54 PM10/25/19
to dea...@googlegroups.com

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

--
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 dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/e0ddc6e9-f2ec-495b-9787-8887922d66c2%40googlegroups.com.
-- 
Rene Gassmoeller
https://gassmoeller.github.io/

Shahab Golshan

unread,
Oct 28, 2019, 1:55:48 PM10/28/19
to deal.II User Group
Very helpful. Thank you so much again.
Best,
Shahab
Reply all
Reply to author
Forward
0 new messages