← Back to team overview

dolfin team mailing list archive

Re: Mesh has no edges until needed by assembly?

 

On Mon, Mar 10, 2008 at 09:37:19AM +0100, Dag Lindbo wrote:
> Hello all!
> 
> A mesh does not have its edges and facets defined when it is 
> constructed?

True.

> A call to mesh.init() is required unless Dirichlet BCs are 
> applied?

mesh.init() creates everything (like all faces incident with edges)
and you most likely won't need everything. To create edges, do

  mesh.init(1);

for faces, do

  mesh.init(2);

for facets, do

  mesh.init(mesh.topology().dim() - 1);

> Can this perhaps be stated a bit clearer in the Programmers 
> Ref?

Yes, many things should be stated clearer in the manual...
I can't say when I'll have time to fix this. Most likely not until
after summer.

-- 
Anders


> The following illustrates the confusion that could otherwise occur:
> 
> int main(void)
> {
>    UnitSquare mesh(32,32);
>    //mesh.init();
> 
>    cout << "Statistics:"    << endl;
>    cout << "\t Vertices:\t" << mesh.numVertices() << endl;
>    cout << "\t Edges:   \t" << mesh.numEdges()    << endl;
>    cout << "\t Faces:   \t" << mesh.numFaces()    << endl;
>    cout << "\t Facets:  \t" << mesh.numFacets()   << endl;
>    cout << "\t Cells:   \t" << mesh.numCells()    << endl;
> 
>    return 0;
> }
> 
> Output (without explicit initialization):
> Statistics:
>           Vertices:      1089
>           Edges:         0
>           Faces:         2048
>           Facets:        0
>           Cells:         2048
> 
>  From the point of view of the user, this is unexpected.
> 
>    Dag
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


References