Dear all,

I am having some confusion regarding the index used in DataOut for a cell 
vector.

I have created a distributed vector for storing cell data using 
p::d::Triangulation::global_active_cell_index_partitioner() 
<https://www.dealii.org/current/doxygen/deal.II/classparallel_1_1TriangulationBase.html#abe6d84acdf8908f48fb236e2c2d47a17>.
 
I am accessing the elements using cell->global_active_cell_index() 
<https://www.dealii.org/current/doxygen/deal.II/classCellAccessor.html#a13e7c4a89332133d5ce71a1a5aa8f64f>
.

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

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/34324c0d-bdff-4fdd-8265-f0a09c409923n%40googlegroups.com.

Reply via email to