Using DataOut for a vector of cell data

219 views
Skip to first unread message

Tristan Schlögl

unread,
Feb 22, 2016, 11:32:16 AM2/22/16
to deal.II User Group
Hi,

I'm computing electric field vectors (dim=3) at Gauss points QGauss<3>(2) within FE_Q<3>(1) elements and I'd like to visualise the electric field in ParaView. My first attempt was to take the average over all Gauss points such that I get one electric field vector per cell. If I store the electric field components in different global vectors for each space dimension, I can add them to the output via
data_out.add_data_vector(output_E_x, "E_field_x");
data_out.add_data_vector(output_E_y, "E_field_y");
...
This is working, however, in ParaView I can then access the values only as scalar values and not as vectors. Hence, I cannot display the magnitude or visualise the electric field as a Glyph with arrows.

My next try was to add the cell data as vector values with a global electric field vector containing all components for all cells and do something like
std::vector< DataComponentInterpretation::DataComponentInterpretation >
electric_field_interpretation
(3, DataComponentInterpretation::component_is_part_of_vector);
std::vector< std::string > electric_field_solution_names (3, "E_field");
data_out.add_data_vector ( output_E_vec, electric_field_solution_names,
   DataOut<3>::type_cell_data,
   electric_field_interpretation  );
Unfortunately, this is not working. An ExcDimensionMismatch is thrown saying add_data_vector() expects a vector of the size n=n_active_cells() but in my case it is 3*n.

Is it in general not possible to have vector valued cell data, or am I doing something wrong here?


As an alternative, is it correct that I can create several FE_DGQ<3>(1) elements for each component of my field vectors, create a new dof handler for output, then use compute_projection_from_quadrature_points_matrix() to project the Gauss point components onto support points and output them? Is there anything easier?

Tristan

Praveen C

unread,
Feb 22, 2016, 11:41:21 AM2/22/16
to Deal.II Googlegroup
Hi Tristan

I havent used Paraview for some time since I now prefer Visit.

In Visit you can take dim scalar fields and define a vector field. You can then draw glyph with arrows. Use Controls -> Expressions.

I am sure such things should be possible in Paraview also.

Best
praveen

--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wolfgang Bangerth

unread,
Feb 22, 2016, 12:01:43 PM2/22/16
to dea...@googlegroups.com
On 02/22/2016 10:32 AM, Tristan Schlögl wrote:
>
> Is it in general not possible to have vector valued cell data, or am I
> doing something wrong here?

Yes, I think that may be true.


> As an alternative, is it correct that I can create several FE_DGQ<3>(1)
> elements for each component of my field vectors, create a new dof
> handler for output, then
> use compute_projection_from_quadrature_points_matrix() to project the
> Gauss point components onto support points and output them? Is there
> anything easier?

This is one way. You probably want a FE_DGQ<3>(0) instead, i.e.,
piecewise constants.

Alternatively, you can achieve what you are trying by defining a
DataPostprocessor (and, more specifically, a class derived from
DataPostprocessorVector) that simply computes the same value for each
output point on a cell.

Best
W.


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

Jean-Paul Pelteret

unread,
Feb 23, 2016, 12:22:01 AM2/23/16
to deal.II User Group
Yes, this is possible in Paraview using the calculator. The expression would be something like
=E_field_x*iHat + E_field_y*jHat + E_field_z*kHat
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscribe@googlegroups.com.

Tristan Schlögl

unread,
Feb 29, 2016, 9:19:09 AM2/29/16
to deal.II User Group
I used the DataPostprocessor class so far for simple output quantities that can be directly derived from solution variables. However, now I need to access the cell iterator for the material_id member and also other quantities that are only temporarily evaluated during assembly but not saved.

I think I almost finished the implementation via discontinuous Galerkin elements, however I need some help with the last step. Let's assume I want to output two discontinuous vector fields for visualisation/postprocessing. I evaluate these vector fields in the Gauss points during assembly and save them with a void* cell->user_pointer() to a user structure.

To handle the actual output, I create a FESystem<3>(FE_DGQ<3>(1), 3, FE_DGQ<3>(1), 3) for the two vector fields and an associated new dof_handler for output as well as a global vector fem_output of the size of the total number of dofs of the new dof_handler. I use FETools::compute_projection_from_quadrature_points_matrix() to create a projection matrix for scalar quantities from Gauss points to support points of the cell. Then I use FETools::compute_projection_from_quadrature_points() for each of my fields to evaluate the projection for tensor valued data. I end up having a std::vector of Tensor<1, 3, double> for each of my fields.

To illustrate that point, I now have two field vectors at each vertex of the cell and the components of these vectors directly correspond to entries of my fem_output variable that I can forward to the DataOut class. But how exactly can I transfer the field vectors to the right positions in fem_output? I first tried cell->vertex_dof_index() to get the dof index for each component (0,1,2 field1; 3,4,5 field 2), however there seem to be no dofs associated with the vertices. I assume this is due to the discontinuous elements.

Tristan
Reply all
Reply to author
Forward
0 new messages