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

Storing discretized system into a matrix format for computation

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ishan_ae

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 30, 2021, 18:29
Default Storing discretized system into a matrix format for computation
  #1
Member
 
ishan
Join Date: Oct 2017
Posts: 77
Rep Power: 8
ishan_ae is on a distinguished road
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?
aerosayan likes this.
ishan_ae is offline   Reply With Quote

Old   October 31, 2021, 04:22
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,776
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
What do you exactly mean for

"are the algorithms modified, not Physics-wise but implementation-wise"?
FMDenaro is offline   Reply With Quote

Old   October 31, 2021, 04:59
Default
  #3
Member
 
ishan
Join Date: Oct 2017
Posts: 77
Rep Power: 8
ishan_ae is on a distinguished road
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.
ishan_ae is offline   Reply With Quote

Old   October 31, 2021, 05:16
Default
  #4
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
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.
aerosayan is offline   Reply With Quote

Old   October 31, 2021, 05:19
Default
  #5
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
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
aerosayan is offline   Reply With Quote

Old   October 31, 2021, 10:13
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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).
sbaffini is offline   Reply With Quote

Old   October 31, 2021, 12:05
Default
  #7
Member
 
ishan
Join Date: Oct 2017
Posts: 77
Rep Power: 8
ishan_ae is on a distinguished road
Thanks everyone for your inputs.
ishan_ae is offline   Reply With Quote

Reply

Tags
solver deveopment


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
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
Need ideas-fuel discharge system Jan FLUENT 1 October 10, 2006 23:05
Need ideas-fuel discharge system Jan CFX 1 October 9, 2006 08:16
Need ideas-fuel discharge system Jan Main CFD Forum 0 October 9, 2006 04:27
solver for linear system with large sparse matrix Yangang Bao Main CFD Forum 1 October 25, 1999 04:22


All times are GMT -4. The time now is 17:15.