Dear all,
I am having some confusion regarding the index used in DataOut for a cell vector.
LA::MPI::Vector vec(partitioner->locally_owned_range(), mpi_comm); // cell vector
LA::MPI::Vector gh_vec(
partitioner->locally_owned_range(),
partitioner->ghost_indices(),
mpi_comm
); // ghosted cell vector
I want to visualise this vector so was adding this to DataOut like so:
// do some computations
// write data
Vector<double> temp_vec(gh_vec); // for data output
data_out.add_data_vector(temp_vec, "vector");
However, seeing the result, it looks like there is some mismatch of indices happening. The vector shows wrong values at wrong places. If I instead do
Vector<double> temp_vec(gh_vec); // for data output
for(auto &cell: dof_handler.active_cell_iterators()){
if(!(cell->is_locally_owned())) continue;
temp_vec[cell->index()] = gh_vec[cell->global_active_cell_index()];
}
data_out.add_data_vector(temp_vec, "vector");
... then the output looks as expected. So here I have manually set the entries of the temporary vector using cell->index(), rather than letting the constructor do the job. For 1d meshes both seem to produce the same output.
What is the correct procedure? What kind of cell index does DataOut use internally? Any clarification would be greatly appreciated!
Thanking in anticipation
Vachan