|
[Sponsors] |
March 13, 2020, 23:33 |
MATLAB problem
|
#1 |
Member
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 8 |
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 |
|
March 13, 2020, 23:53 |
|
#2 |
Super Moderator
|
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. |
|
March 14, 2020, 00:08 |
|
#3 | |
Member
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 8 |
Quote:
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. |
||
March 14, 2020, 00:37 |
|
#4 |
Super Moderator
|
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.
|
|
March 14, 2020, 04:53 |
|
#5 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,855
Rep Power: 73 |
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. |
|
March 15, 2020, 18:00 |
|
#6 | |
Member
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 8 |
Quote:
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 |
||
|
|
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 |