|
[Sponsors] |
Storing discretized system into a matrix format for computation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 30, 2021, 19:29 |
Storing discretized system into a matrix format for computation
|
#1 |
Member
ishan
Join Date: Oct 2017
Posts: 78
Rep Power: 9 |
Hello,
I have a question related to how the coefficients from resulting discretized system of equations are stored. I noticed that there are several sparse matrix storage formats such as CSR(compressed sparse row) that are used in linear solver libraries such as lis(https://github.com/anishida/lis) and PETSc. When the coefficients are calculated for the CFD system under study, are the algorithms modified, not Physics-wise but implementation-wise, so that the coefficients are stored in the desired storage format in, lets say N steps? If not, then are the coefficients calculated, stored temporarily and then the coefficients converted into the matrix format? To me this seems like it will increase the memory usage and also will need at least t N+1 steps implementation-wise. I do not have expert-level know-how about about C or C++ but in my opinion this also depends on how the libraries are built. This is something which I wondered about because I am right now using C in my CFD learning process. I want to use existing linear solver libraries for my code and in the code documentation they have mentioned about different storage formats. Based on your experience how is this usually done? |
|
October 31, 2021, 05:22 |
|
#2 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73 |
What do you exactly mean for
"are the algorithms modified, not Physics-wise but implementation-wise"? |
|
October 31, 2021, 05:59 |
|
#3 |
Member
ishan
Join Date: Oct 2017
Posts: 78
Rep Power: 9 |
What I meant by it was that whether we modify lets say, a for loop to store the resulting calculations in a specific variable. This variable can be part of a larger process that is needed to set up the overall system of equations. While the calculation process will be the same, but what will change is how those calculations are implemented while coding.
|
|
October 31, 2021, 06:16 |
|
#4 |
Senior Member
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8 |
First write a solver for dense matrices. Use python/Matlab/octave to do it, so that your maths is correct. Then go to study other sparse matrix solvers. Then write sparse matrix solvers.
I hope you followed this path of learning in your journey. If you don't understand dense matrix solvers, you won't understand sparse matrix solvers. Answering your question : yes the code needs to be modified to work with sparse matrix form, and if you think of the algorithm as the pseudocode instead of the overall steps to take, then obviously the algorithm also changes. I code in C/C++, C doesn't have the benefits of fortran's matrix manipulation, or C++'s OOP based abstraction. But it's simpler than C++ and harder than Fortran. If you're learning and don't care about performance, I would recommend languages like python/Matlab or octave/Julia/Fortran. They're almost similar, but I put the more easy to use languages at the front. Except Fortran, the rest have inbuilt data visualization/plotting system so they are easier for you to use. |
|
October 31, 2021, 06:19 |
|
#5 |
Senior Member
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8 |
Also answering your question : yes, the implementation is often changed for efficiency. For example - No one actually computes A inverse for solving set of linear equations like Ax=b
|
|
October 31, 2021, 11:13 |
|
#6 |
Senior Member
|
If you think a little about it, and realize that you only need those coefficients to actually solve the system, you also understand that there really is no reason to store them in any different way than the one demanded by the linear algebra part (typically csr). Even if you have many of them, they will probably demand all the same structure (I don't know a single one of them that doesn't).
|
|
October 31, 2021, 13:05 |
|
#7 |
Member
ishan
Join Date: Oct 2017
Posts: 78
Rep Power: 9 |
Thanks everyone for your inputs.
|
|
Tags |
solver deveopment |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFX11 + Fortran compiler ? | Mohan | CFX | 20 | March 30, 2011 19:56 |
Need ideas-fuel discharge system | Jan | FLUENT | 1 | October 11, 2006 00:05 |
Need ideas-fuel discharge system | Jan | CFX | 1 | October 9, 2006 09:16 |
Need ideas-fuel discharge system | Jan | Main CFD Forum | 0 | October 9, 2006 05:27 |
solver for linear system with large sparse matrix | Yangang Bao | Main CFD Forum | 1 | October 25, 1999 05:22 |