Writing outputs of type tensor in cells

23 views
Skip to first unread message

shahab.g...@gmail.com

unread,
Jul 16, 2021, 3:39:46 PM7/16/21
to deal.II User Group
Dear All,

I have a parameter of type Tensor<1, dim> for each active cell in the triangulation. When I write this parameter as output, I face some difficulties:
1, Vectors in deal.II do not accept tensor elements.
2, add_data_vector does not work for std::vectors.
3, I tried using DataComponentInterpretation, but I am really confused in implementing it correctly.

I would appreciate it if you could send me an example of writing an output of type Tensor for each cell. Let's say I have a
std::vector<Tensor<1, dim>> output;
, and in this vector I've stored the output parameter in each cell using  cell->global_active_cell_index().

Best
Shahab

Wolfgang Bangerth

unread,
Jul 19, 2021, 1:23:36 PM7/19/21
to dea...@googlegroups.com
Yes, this doesn't work. Just create Vector<double> objects for each component
of the tensor and put things in there.

(Alternatively, if you like a challenge: Write a class derived from
DataPostprocessorTensor in which you just ignore whatever it gets as output,
and instead proceed to use as output whatever you query from your
std::vector<Tensor<1,dim>> using the cell the evaluate_* function gets as
argument in the input object.)

Best
W.


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

Reply all
Reply to author
Forward
0 new messages