This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

DofMap tabulate_coordinates gives strange output

0 votes

Hi,

I am trying to get the coordinates of the DOFs. The following simple code gives me always zero output:
...
x = 0, 0
x = 0, 3.21143e-322
x = 6.90901e-310, 5.08597e-317

Can anyone try it out? I use the stable version of dolfin: dolfin-1.3.0.

Thank you,
Murtazo

main.cpp:

#include <dolfin.h>
#include "P1.h"
using namespace dolfin;

int main()
{
  UnitSquare mesh(5,5);

  P1::FunctionSpace V(mesh);

  const GenericDofMap& dm = *V.dofmap();
  dolfin::la_index ds = dm.max_cell_dimension();

  boost::multi_array<double, 2> coor(boost::extents[ds][2]);
  std::vector<double> vert_coor(3);

  for (CellIterator cell(mesh); !cell.end(); ++cell)
    {
      dm.tabulate_coordinates(coor, vert_coor, *cell);

      for (int i = 0; i < ds; i++)
        info("x = %g, %g", coor[i][0], coor[i][1]);
      info("");
    }

  return 0;
}

P1.ufl:
element = FiniteElement("Lagrange", triangle, 1)

asked Mar 20, 2014 by murtazo FEniCS Novice (320 points)

2 Answers

0 votes

I have to include the following line before tabulating the coordinates:

std::vector<double> vertex_coord;
cell->get_vertex_coordinates(vert_coord);

I am not sure if it is the best way.

answered Mar 21, 2014 by murtazo FEniCS Novice (320 points)
edited Mar 26, 2014 by murtazo
0 votes

You have not filled vert_coor. Moreover, std::vector<double> vert_coor(3) is of the wrong size and and it will be initialised with zeros.

answered Mar 25, 2014 by Garth N. Wells FEniCS Expert (35,930 points)

I have edited my comment. You are right, it seems I had to fill vert_coor. However, I am not sure why do I need to keep it, I understand that UFCCell class is no longer exist and the connectivity of the cell should be updated. Does this way work if I need to get the coordinates of the dofs for higher polynomial degree that follows the Lobatto points?

...