# Looping through particles that make up the vertices of the Delaunay triangulation and updating their positions

5 messages
Open this post in threaded view
|

## Looping through particles that make up the vertices of the Delaunay triangulation and updating their positions

 Dear all, I am writing a code in which particles moves in 2D (with periodic boundary conditions) and (will, later) interact with their neighbors in a Delaunay triangulation. I thus need to move all my particles at every time step and to update the corresponding Delaunay graph efficiently. Each particle thus corresponds to one vertex of the triangulation. At every time step, I need to loop through the particles. I thus tried to use a loop over the vertices, move the corresponding particle, and then update the triangulation. A simple loop would look like that: for(Vertex_iterator it = T1.vertices_begin();  it != T1.vertices_end(); ++it){            // New position              double New_x = it->point().x()+2.3;            double New_y = it->point().y()+2.3;            Point New_point = Point(New_x, New_y);            T1.move_point(it, New_point); } (T1 is the already defined triangulation). However, because moving the point changes the order of the triangulation, I am not looping through all vertices, and sometimes ends up going twice through the same vertex (which has moved) and not through other particles/vertices. My question is thus: Is there a way to access directly the vertices so that I would loop through all vertices/particles exactly once ? I have added labels to my vertices using info() : for(int i=0;iinfo()=i; } But then I do not know how to loop (efficiently!) over the values "i" and the corresponding vertices. Thanks for your help ! Best, Julien -- Sent from: http://cgal-discuss.949826.n4.nabble.com/-- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|

## Re: Looping through particles that make up the vertices of the Delaunay triangulation and updating their positions

 HI, Julian. One solution might be maintaining a set(for ex. std::set) of vertex handles and run through this set when you are updating positions. > On Apr 10, 2020, at 18:56, Julien T. <[hidden email]> wrote: > > Dear all, > > I am writing a code in which particles moves in 2D (with periodic boundary > conditions) and (will, later) interact with their neighbors in a Delaunay > triangulation. I thus need to move all my particles at every time step and > to update the corresponding Delaunay graph efficiently. Each particle thus > corresponds to one vertex of the triangulation. > > At every time step, I need to loop through the particles. I thus tried to > use a loop over the vertices, move the corresponding particle, and then > update the triangulation. A simple loop would look like that: > > for(Vertex_iterator it = T1.vertices_begin();  it != T1.vertices_end(); > ++it){ > >           // New position   >           double New_x = it->point().x()+2.3; >           double New_y = it->point().y()+2.3; > >           Point New_point = Point(New_x, New_y); >           T1.move_point(it, New_point); > } > > (T1 is the already defined triangulation). However, because moving the point > changes the order of the triangulation, I am not looping through all > vertices, and sometimes ends up going twice through the same vertex (which > has moved) and not through other particles/vertices. > > My question is thus: Is there a way to access directly the vertices so that > I would loop through all vertices/particles exactly once ? I have added > labels to my vertices using info() : > > for(int i=0;i     vh = T1.insert(Point((i%Nx)*d, (i/Nx)*d)); >     vh->info()=i; > } > > But then I do not know how to loop (efficiently!) over the values "i" and > the corresponding vertices. > > Thanks for your help ! > > Best, > > Julien > > > > > -- > Sent from: http://cgal-discuss.949826.n4.nabble.com/> > -- > You are currently subscribed to cgal-discuss. > To unsubscribe or access the archives, go to > https://sympa.inria.fr/sympa/info/cgal-discuss> > -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|

## Re: Looping through particles that make up the vertices of the Delaunay triangulation and updating their positions

 *Sorry, Julien, auto correction. -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss