← Back to team overview

dolfin team mailing list archive

Re: Benchmarks for new mesh library

 

Ola, here's a special trick just for you. To iterate over all cells
and for each cell get the array of vertices, just do the following:

    // Get connectivity cells - vertices
    MeshConnectivity& connectivity = mesh.data.topology(mesh.dim(), 0);

    // Iterate over cells
    for (unsigned int c = 0; c < mesh.numCells(); c++)
    {
        unsigned int* vertices = connectivity(c);
        unsigned int num_vertices = connectivity.size(c);
    }

If you also now that the connectivity is stored as a contiguous array
(which it is), you can get the entire connectivity array in just one line:

    unsigned int* vertices = mesh.data.topology(mesh.dim(), 0)(0);

/Anders

On Sun, Jun 18, 2006 at 12:31:34AM +0200, Ola Skavhaug wrote:
> Anders Logg skrev den 17/06-2006 følgende:
> > Will be interesting to see. I haven't implemented the computation of
> > boundaries yet, so maybe you won't be able to run all tests.
> > 
> > I'll add boundaries in a day or two.
> > 
> > /Anders
>  
> Very promising! For the solver for the electrical activity in the heart,
> boundary conditions are not implemented explicitly; homogeneous Neumann is the
> natural choice. I'll have a go at preparing the mesh for use in PyCC early
> next week; we need to extend the interface slightly to fit our requirements,
> i.e., iterate over the vertices and cells to construct the simple NumPy arrays
> that we use.
> 
> Ola
> > On Sat, Jun 17, 2006 at 03:18:29PM +0200, kent-and@xxxxxxxxx wrote:
> > > 
> > > Nice!!
> > > 
> > > When I come back I will run the PyCC tests. With these speedups we
> > > probably need to re-evaluate the efficiency of matrix making in PyCC :-)
> > > 
> > > I will post you the results.
> > > 
> > > Kent
> > > 
> > > > Here are some results from a simple benchmark of the new mesh library:
> > > >
> > > > Test                                  | Old mesh  New Mesh
> > > > -------------------------------------------------------------- Reading
> > > > and initializing 1000 times   |  0.90 s    0.21 s Refining mesh
> > > > uniformly 8 times       |  27.2 s    2.14 s Iterating over connectivity
> > > > 100 times |  18.2 s    1.86 s Memory usage                          |
> > > > 281 MB     43 MB
> > > >
> > > > Initial mesh: 8 vertices and 2 cells Final mesh:   263169 vertices and
> > > > 524288 cells
> > > >
> > > > The speedup is around a factor 10. :-)
> > > >
> > > > The memory usage has also been reduced. It's now at a minimum (give or
> > > > take a few bytes).
> > > >
> > > > /Anders
> > > >
> > > >
> > > 
> > > 
> > > 
> > 
> 



References