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

best way to assign a MeshValueCollection to the mesh.domains()?

0 votes

I'm using the dolfin 1.4.0 C++ interface, and wanted to assign a MeshValueCollection that I have stored in a file to a mesh. I was hoping to do it in a manner similar to the way that Johan mentions in this question from a while back. The data I have loaded like this:

Mesh mesh("structure.xml.gz");
MeshValueCollection<size_t> cell_mvc(mesh, "structure_cellids_sparse.xml.gz");
MeshValueCollection<size_t> facet_mvc(mesh, "structure_facetids_sparse.xml.gz");

I would like to be able to assign the information to mesh.domains() like this:

mesh.domains().markers(3) = cell_mvc;
mesh.domains().markers(2) = facet_mvc;

This obviously won't work ... but I was hoping that there was something obvious that I missed. Right now, I was trying to get it to work like this:

std::map<std::pair<size_t, size_t>, size_t>& cell_map = cell_mvc.values();
std::map<std::pair<size_t, size_t>, size_t>::iterator it;
for (it = cell_map.begin(); it != cell_map.end(); ++it) {
  mesh.domains().set_marker(*it, 3);
}

This also won't work because the MeshValueCollection iterator returns items that look like a std::map with a key that is a std::pair of cell index and local entity index, and the "set_marker" method seems to want a global entity index as a key. This gives me the feeling that I am going about this the wrong way, so I was hoping that someone could shine some light on the best way to handle this?

I liked keeping the data and the mesh together in one file, like the "Aneurysm" datafile, but if this doesn't work well with parallelization I could easily be talked out of it.

asked Nov 5, 2014 by timm FEniCS User (2,100 points)
...