Transfer local cell data to global cell vector

27 views
Skip to first unread message

Sumedh Yadav

unread,
Mar 18, 2017, 2:33:55 AM3/18/17
to deal.II User Group
Hello,
I need to do some post-processing on computed solution data (say Vector<double> Solution(dof_handler.n_dofs()) is the solution vector). For post-processing field (say Vector<double> Curvature(triangulation.n_dofs()) is the scalar field to be computed) I decided to have one entry per cell. Once I calculate this entry in 'cell iterator loop' I have to transfer it to global vector Curvature based on some index of the cell. I am just drawing the analogy from what we do during the assembling of system_matrix and/or system_rhs. There we use cell iterator functionality get_dof_indices() to get the global indices of DoFs that are of on the current cell. But I am not able to find analogous method to get an cell-wise index (we can't use cell iterator return value since it is not unsigned int) which can be used to transfer cell data to the global vector Curvature(triangulation.n_dofs()). Please help me to figure it out.
Secondly, I want to use this global vector Curvature(triangulation.n_dofs()) in a DataOut object essentially to add this vector to the object via add_data_vector(Curvature, "curvature") method. I believe (read in another question thread in the group) the DataOut object will not have any problems accepting a vector which has size triangulation.n_dofs() but not dof_handler.n_dofs() since I initialize the DataOut object with dof_handler? I meant that it would judiciously distinguish this vector from other vectors which have size dof_handler.n_dofs() and output it correctly?

Wolfgang Bangerth

unread,
Mar 19, 2017, 2:49:35 PM3/19/17
to dea...@googlegroups.com

> I need to do some post-processing on computed solution data (say
> Vector<double> Solution(dof_handler.n_dofs()) is the solution vector). For
> post-processing field (say Vector<double> Curvature(triangulation.n_dofs()) is
> the scalar field to be computed) I decided to have one entry per cell. Once I
> calculate this entry in 'cell iterator loop' I have to transfer it to global
> vector Curvature based on some index of the cell. I am just drawing the
> analogy from what we do during the assembling of system_matrix and/or
> system_rhs. There we use cell iterator functionality get_dof_indices() to get
> the global indices of DoFs that are of on the current cell. But I am not able
> to find analogous method to get an cell-wise index (we can't use cell iterator
> return value since it is not unsigned int) which can be used to transfer cell
> data to the global vector Curvature(triangulation.n_dofs()). Please help me to
> figure it out.

You can use cell->active_cell_index().


> Secondly, I want to use this global vector Curvature(triangulation.n_dofs())
> in a DataOut object essentially to add this vector to the object via
> add_data_vector(Curvature, "curvature") method. I believe (read in another
> question thread in the group) the DataOut object will not have any problems
> accepting a vector which has size triangulation.n_dofs() but not
> dof_handler.n_dofs() since I initialize the DataOut object with dof_handler? I
> meant that it would judiciously distinguish this vector from other vectors
> which have size dof_handler.n_dofs() and output it correctly?

It can take both kinds of vectors. In your case, rather than converting the
cell-based vector into a DoF-based vector, stick with the former and let
DataOut output this.

Best
W.

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

Sumedh Yadav

unread,
Mar 19, 2017, 11:29:40 PM3/19/17
to deal.II User Group
Thankyou!
that works :)
Reply all
Reply to author
Forward
0 new messages