Dear Matthias,

Thanks so much for your reply.

Your comment and Dr. Bangerth's comment both exactly pointed out the 
problems in my settings on the scalar "Vector<double> 
cell_x(dofs_per_cell)", and the rank-1 tensor "std::vector<Point<dim>> 
x(dofs_per_cell)", which multiply the scalar "fe_values.shape_value(i, 
q_index)" in the expression.

Yes, vertices of each cell form a rank-1 tensor. I just put in the first 
value of the rank-1 tensor, to transform the expression into the scalar 
"cell_x", that perfectly works thru. This is amazing!

Thank you all so much! I will keep up my work.

Best,
Judy
On Tuesday, December 7, 2021 at 1:44:38 PM UTC-5 Matthias Maier wrote:

> Dear Judy,
>
> On Tue, Dec 7, 2021, at 11:45 CST, Judy Lee <reader....@gmail.com> wrote:
>
> > cell_x(i) += fe_values.shape_value(i, q_index) * x(i);
>
> Here, you are multiplying a scalar (fe_values.shape_value(i, q_index))
> and a rank-1 tensor (x(i)), which results in a rank-1 tensor.
>
> The error message says that you cannot store this rank-1 tensor in
> cell_x(i), which is a scalar (vector<double>).
>
> I don't know whether this is what you want to do, but in 1D you can
> simply take the first value of your rank-1 tensor to transform the
> expression into a scalar:
>
> cell_x(i) += fe_values.shape_value(i, q_index) * x(i)[0];
>
> However, this is not a good "dimension independent" approach, meaning
> the moment you try to solve in 2D or 3D you will have to modify your
> code.
>
> Best,
> Matthias
>

-- 
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/69dfc876-4273-4b8d-8a24-009b4492beben%40googlegroups.com.

Reply via email to