Convert FullMatrix into Tensor

51 views
Skip to first unread message

Lixing Zhu

unread,
Sep 26, 2021, 7:47:16 AM9/26/21
to deal.II User Group
Hi all,

I am implementing a stabilized weak form of a vector-valued problem (e.g., displacement u and pressure p with corresponding weighting functions w and q). One of the stabilization terms takes the form (grad q, \tau grad p), where \tau is actually a tensor. Here \tau is locally determined by solving an element-wise linear system. Therefore I am using a FullMatrix class for \tau.

However, since \tau is involved in the numerical integration, it seems more convenient to convert \tau into a Tensor class.

Is there a quick method to convert a FullMatrix into a Tensor? Or is there a better way to code this workflow? Any suggestion is appreciated. If more info is needed, please let me know also.

Regards,
Lixing

Wolfgang Bangerth

unread,
Sep 26, 2021, 12:12:11 PM9/26/21
to dea...@googlegroups.com
Lixing
I don't think there is an easy way short of just copying elements one by one.

Out of curiosity, what is the equation that defines tau, and why can't you
just write this equation in terms of tensors right away?

Best
W>


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

Lixing Zhu

unread,
Sep 26, 2021, 12:31:06 PM9/26/21
to deal.II User Group
Hi Wolfgang,

Thanks. I think I'll then use FullMatrix::copy_to() then to convert it to a tensor.

I'm working (very slowly) on re-implementing our method on the basis of deal.ii. It is based on the variational multiscale framework where the stabilization tensor \tau is solved by the fine-scale problems. The fine-scale problem is discretized with bubble functions which yield a local (within an element) linear system. I guess this explains my previous threads about bubble function, tensor contraction, and other stuff. I really appreciate the help from you and this community.

Here is our latest work: Zhu, Lixing, and Arif Masud. "Residual-based closure model for density-stratified incompressible turbulent flows." Computer Methods in Applied Mechanics and Engineering 386 (2021): 113931. 

Best regards,
Lixing

Wolfgang Bangerth

unread,
Sep 27, 2021, 3:44:50 PM9/27/21
to dea...@googlegroups.com

> I'm working (very slowly) on re-implementing our method on the basis of
> deal.ii. It is based on the variational multiscale framework where the
> stabilization tensor \tau is solved by the fine-scale problems. The
> fine-scale problem is discretized with bubble functions which yield a
> local (within an element) linear system. I guess this explains my
> previous threads about bubble function, tensor contraction, and other
> stuff. I really appreciate the help from you and this community.

I see. Yes, in that case just copying the elements of the FullMatrix to
a Tensor is the right approach. It should also cost at most a tiny
fraction of the cost you put into computing the elements of the
matrix/tensor, so the only price to pay is that it would be conceptually
*nicer* to not have to do that conversion yourself. But you already
found copy_to().

Best
W.
Reply all
Reply to author
Forward
0 new messages