Hi, I’m trying to get a local to global mapping for particular cells with dofmap->cell_dofs(). I followed tutorial and did the following way.
ArrayView<const dolfin::la_index> cell_dofs = dofmap->cell_dofs(cell_id);
However I got the following error;
error: conversion from ‘Eigen::Map<const Eigen::Array<int, -1, 1> >’ to non-scalar type ‘dolfin::ArrayView<const int>’ requested
I looked at the source file DofMap.h, and the returned data is
/// Local-to-global mapping of dofs on a cell
///
/// @param cell_index (std::size_t)
/// The cell index.
///
/// @return ArrayView<const dolfin::la_index>
Eigen::Map<const Eigen::Array<dolfin::la_index, Eigen::Dynamic, 1>>
cell_dofs(std::size_t cell_index) const
{
const std::size_t index = cell_index*_cell_dimension;
dolfin_assert(index + _cell_dimension <= _dofmap.size());
return Eigen::Map<const Eigen::Array<dolfin::la_index, Eigen::Dynamic, 1>>(&_dofmap[index], _cell_dimension);
}
I’m not familiar with Eigen::Map, but I see what return is an Eigen::Map, but in the comment says it returned ArrayView. Is this some updated comment and document or ArrayView is suppose to be compatible with Eigen::Map?
I also found a previous change log. It seems like it used to be returned with an ArrayView?
And This is no error, if I use Eigen::Map type in the code. But I am not sure how to work with return Eigen::Map, is there anyway I can access the elements in the Map object just like how I access an array?
P.S. Went to read about Eigen’s documentation, I’m currently ok to work with Eigen::Map. I guess it is just outdated documentation.
Regards