CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

MATLAB problem

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By praveen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 13, 2020, 23:33
Default MATLAB problem
  #1
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 8
AeroSonic is on a distinguished road
Hi guys,

I have a problem with MATLAB, I am writing a compressible NV solver Using FEM (GLS), everything is fine, but I have a problem with the running time.

the running time for a one-time step ( using 90x30 grid ) is 22 seconds, 19 seconds of them are wasted in one line which is the inverse of the global matrix.

you can find Matlab code analyzer in attachments, I really don't know why this line takes this much time ?!!

I tried different MATLAB Versions ( 15b, 17b ) but it taking more time than the current ( 18b ).

I am going to change the code to FORTRAN soon but currently, I want to know the reason for this problem.

My specs:

1- Ryzen 5 2600.
2- Ram 3000 MHZ 2x8 Gb.
3- SSD
Attached Images
File Type: jpg 12333.JPG (102.9 KB, 10 views)
AeroSonic is offline   Reply With Quote

Old   March 13, 2020, 23:53
Default
  #2
Super Moderator
 
Praveen. C
Join Date: Mar 2009
Location: Bangalore
Posts: 343
Blog Entries: 6
Rep Power: 18
praveen is on a distinguished road
Matlab is slow if you use loops. If you cast everything as matrix-vector operations it can do better.

For CFD, Matlab is not so great, ok for some initial learning, but you soon reach its limitations.

Do you have to assemble your matrices every time step ?

You are using a direct solver and it has to do a LU decomposition every time.

If matrix does not change you can perhaps optimise, perform LU decomposition once,

https://www.mathworks.com/help/matlab/ref/lu.html

and reuse it.
praveen is offline   Reply With Quote

Old   March 14, 2020, 00:08
Default
  #3
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 8
AeroSonic is on a distinguished road
Quote:
Originally Posted by praveen View Post
Matlab is slow if you use loops. If you cast everything as matrix-vector operations it can do better.

For CFD, Matlab is not so great, ok for some initial learning, but you soon reach its limitations.

Do you have to assemble your matrices every time step ?

You are using a direct solver and it has to do a LU decomposition every time.

If matrix does not change you can perhaps optimise, perform LU decomposition once,

https://www.mathworks.com/help/matlab/ref/lu.html

and reuse it.
I am going to learn Fortran soon but.

as this is a compressible viscous and unsteady, yes i am constructing the matrices each time step and they are changing from element to element.

every time step, the code does the inverse line. I am using the mldivide.
AeroSonic is offline   Reply With Quote

Old   March 14, 2020, 00:37
Default
  #4
Super Moderator
 
Praveen. C
Join Date: Mar 2009
Location: Bangalore
Posts: 343
Blog Entries: 6
Rep Power: 18
praveen is on a distinguished road
In your case, most time is taken in solve phase. Your matrix is not that big so the direct solvers should be fine. Maybe this is normal. The solve phase will be the most expensive in such a method.
AeroSonic likes this.
praveen is offline   Reply With Quote

Old   March 14, 2020, 04:53
Default
  #5
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,855
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Could you show a sketch at a couple of time steps of the sparsity of the matrix?
However, in any CFD code a solver for algebric system takes the most part of computational time.
FMDenaro is offline   Reply With Quote

Old   March 15, 2020, 18:00
Default
  #6
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 8
AeroSonic is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
Could you show a sketch at a couple of time steps of the sparsity of the matrix?
However, in any CFD code a solver for algebric system takes the most part of computational time.

It was a problem in matlab, I have an AMD processor and matlab isnt configured for it, someone helped me

https://www.mathworks.com/matlabcent...#answer_401963
AeroSonic is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I am new to Cfd. Please help to develop a MATLAB for this problem Priyanka Konakandla Main CFD Forum 7 April 25, 2016 10:02
Please help me to develop a MATLAB code for this problem Priyanka Konakandla Main CFD Forum 0 April 23, 2016 06:35
Solving almost-degenerate linear problem? jollage Main CFD Forum 1 April 7, 2016 12:13
Gambit - meshing over airfoil wrapping (?) problem JFDC FLUENT 1 July 11, 2011 06:59
Adiabatic and Rotating wall (Convection problem) ParodDav CFX 5 April 29, 2007 20:13


All times are GMT -4. The time now is 05:59.