Re: [deal.II] Unexpected data output with cell data vector

2021-07-09 Thread vachan potluri
>
> You want to use cell->active_cell_index() as the index into the vector. The
> vector should have
>triangulation.n_active_cells()
> as its size. This corresponds to the *local* number of active cells,
> including
> ghost and artificial cells (for which vector entries are then just
> ignored). I
> think step-47 shows this (whether in parallel or not doesn't matter in this
> regard).


Thank you, that clarifies my doubts.

On Sat, 10 Jul 2021 at 08:58, Wolfgang Bangerth 
wrote:

> On 7/7/21 12:08 AM, vachanpo...@gmail.com wrote:
> >
> > Vector temp_vec(gh_vec); // for data output
> > for(auto : 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!
>
> You want to use cell->active_cell_index() as the index into the vector.
> The
> vector should have
>triangulation.n_active_cells()
> as its size. This corresponds to the *local* number of active cells,
> including
> ghost and artificial cells (for which vector entries are then just
> ignored). I
> think step-47 shows this (whether in parallel or not doesn't matter in
> this
> regard).
>
> Best
>   W.
>
> --
> 
> Wolfgang Bangerth  email: bange...@colostate.edu
> www: http://www.math.colostate.edu/~bangerth/
>
> --
> 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/fafa93e0-9da2-cf5b-b0f9-8bbfd4e1e75c%40colostate.edu
> .
>

-- 
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/CALAVa_yNWj-50gR9End--K%3DYuAaQSbrdTXxL%2BR69jkPbbdY2wA%40mail.gmail.com.


Re: [deal.II] Unexpected data output with cell data vector

2021-07-09 Thread Wolfgang Bangerth

On 7/7/21 12:08 AM, vachanpo...@gmail.com wrote:


Vector temp_vec(gh_vec); // for data output
for(auto : 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!


You want to use cell->active_cell_index() as the index into the vector. The 
vector should have

  triangulation.n_active_cells()
as its size. This corresponds to the *local* number of active cells, including 
ghost and artificial cells (for which vector entries are then just ignored). I 
think step-47 shows this (whether in parallel or not doesn't matter in this 
regard).


Best
 W.

--

Wolfgang Bangerth  email: bange...@colostate.edu
   www: http://www.math.colostate.edu/~bangerth/

--
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/fafa93e0-9da2-cf5b-b0f9-8bbfd4e1e75c%40colostate.edu.


[deal.II] Unexpected data output with cell data vector

2021-07-07 Thread vachanpo...@gmail.com
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() 
.
 
I am accessing the elements using cell->global_active_cell_index() 

.

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 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 temp_vec(gh_vec); // for data output
for(auto : 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.