Dear Masoud,

> As you mentioned, we expect this to be slower than the equivalent code in 
> step-8; however, it is very slower than the same code that I wrote before in 
> Matlab.

A quick question: are you sure that you’re running your problem in release 
mode, rather than debug mode? I had a colleague who adopted this BDB approach 
that you’ve described, and he never mentioned performance issues to the degree 
that you’re seeing here.

Best,
Jean-Paul

> On 20. Oct 2021, at 14:08, Masoud Ahmadi <masoud16...@gmail.com> wrote:
> 
> Dear Prof. Bangerth,
> 
> Thanks for your answer. 
> Indeed, I took the declaration of matrices out of the loop; but still, as I 
> mentioned, the part that is substantially reducing the speed is the product 
> between the matrices. 
> As you mentioned, we expect this to be slower than the equivalent code in 
> step-8; however, it is very slower than the same code that I wrote before in 
> Matlab. 
> My question is, I want to be sure that "FullMatrix" is the most efficient and 
> fast way in dealii to evaluate such like matrix calculations (the products). 
> Or should I be looking for alternatives?
> 
> Best regards
> 
> On Tuesday, 19 October 2021 at 19:24:11 UTC+1 Wolfgang Bangerth wrote:
> 
> Masoud, 
> 
> > Here is a part of the tutorial code for example 8 to calculate stiffness 
> > matrix of an element: 
> > Screenshot 2021-10-15 at 12.48.39.png 
> > 
> > And here is my equivalent code for the same purpose with a matrix-based 
> > viewpoint: 
> > Screenshot 2021-10-15 at 23.12.13.png 
> > 
> > it is based on the following formulation for a 3D elastic problem: 
> > thumbnail_image.png 
> > By "slow", I mean in comparison with the same code in tutorial (example 8). 
> > I 
> > measured the lines of the code, and I am sure the difference is for the 
> > mentioned part of the code. To be more accurate: the operations on 
> > matrices, 
> > as follow in the second image: 
> > B[I].Tmmult(tmpM,D); 
> > tmpM.mmult(BDB,B[J]); 
> 
> You could probably make the code substantially faster already if you moved 
> the 
> declaration of the B, tmpM, and BDB matrices out of the loop over the 
> quadrature points, and simply set them to zero inside the loop. Creating 
> these 
> variables requires allocating memory every time you do one iteration over the 
> quadrature points, which is expensive. 
> 
> But in the end, compare what work you are doing in your loop with what the 
> equivalent code in step-8 is doing, and you shouldn't be surprised by your 
> observation. step-8 only does 2 (and if i==j, then 3) tensor contractions for 
> each index i,j,q. You are allocating and releasing memory, and doing two 
> products between 6x3 and 3x3 matrices, plus a lot of index work. It does not 
> surprise me that this is slow. 
> 
> Best 
> W. 
> 
> -- 
> ------------------------------------------------------------------------ 
> Wolfgang Bangerth email: bang...@colostate.edu 
> <applewebdata://CB167E7A-6D0C-4D32-97EA-A18E8F590477> 
> www: http://www.math.colostate.edu/~bangerth/ 
> <http://www.math.colostate.edu/~bangerth/> 
> 
> 
> -- 
> The deal.II project is located at http://www.dealii.org/ 
> <http://www.dealii.org/>
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en 
> <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 
> <mailto:dealii+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/00c2608c-7489-4538-8bd7-09c989d844c4n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/dealii/00c2608c-7489-4538-8bd7-09c989d844c4n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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/E3BA93D2-831E-453F-9CD6-1818587CC00D%40gmail.com.

Reply via email to