← Back to team overview

dolfin team mailing list archive

Re: [Question #97807]: How to Obtain the Coordinates of the Vertices of a Mesh with P2 and Higher Elements

 

On Mon, Jan 18, 2010 at 09:31:15AM -0000, Ted Kord wrote:
> New question #97807 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/97807
>
> Hello
>
> How do I get the vertex coordinates for a mesh with P2 elements? For a P1 mesh, this works fine:
>
> for (VertexIterator vertex(mesh); !vertex.end(); ++vertex) {
> 	 xy = new Array<double>(dim, geometry.x(vertex->index()));
> 	 x0 = (*xy)[0]; x1 = (*xy)[1];
> 	 std::cout << i << "(" << x0 << ", " << x1 << ")" << std::endl;
> 	 ++i;
> }
>
> It doesn't work for a P2 mesh though.
>
> Some parts of my code which depend on knowing the vertex coordinates ultimately fail with the following error (P2 and above only):
>
>          Assertion failed: (V.dofmap().global_dimension() <= x.size()), function Function, file dolfin/function/Function.cpp, line 62.
>
> Could someone please help with this.
>
> Thank you.
>
> Ted

You should check the function tabulate_coordinates in the DofMap class:

  V.dofmap().tabulate_coordinates(...)

This should give you what you need.

For details on what it does, check the UFC manual.

--
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References