CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Sparse matrix (http://www.cfd-online.com/Forums/openfoam-solving/60473-sparse-matrix.html)

hemph September 21, 2005 03:38

Hi, Is there support for spa
 
Hi,
Is there support for sparse matrices in OpenFOAM? From what I can tell, Matrix.C constructs only a full matrix, which would require too much of memory in this case.

Best
Rasmus H

hjasak September 21, 2005 04:01

Sorry to be rude but, well, ob
 
Sorry to be rude but, well, obviously! If all the matrices were full you could not solve more that several thousand cells. :-)

The class you want is lduMatrix:

OpenFOAM-1.2/src/OpenFOAM/matrices/lduMatrix/lduMatrix.H

Enjoy,

Hrv

hemph September 21, 2005 04:11

http://www.cfd-online.com/Open
 
http://www.cfd-online.com/OpenFOAM_D...part/happy.gif
Thanks! I was looking at the wrong place.

hemph September 27, 2005 14:14

After looking at the lduMatrix
 
After looking at the lduMatrix class I am afraid I have some further questions about sparse matrices!

What I want/need to to is to use a sparse matrix format for storage of information, not for solving equations. What I thus would need is the possibility to, in pseudocode, do

sparseMatrix<bool>(large number,large number) A

A(500,5022) = 1;
and, for instance
A(500,5022) = 0;
to delete the element;

and to hopefully do the same for other objects, i.e. sparseMatrix<vector> etc.

Does these type of structures exist in OpenFOAM, or is this something I need to look into creating?

Thanks for your time!
Rasmus

hjasak September 27, 2005 16:21

Aha. There's several related
 
Aha. There's several related issues, (e.g. what do you meand by "delete an element") etc. but, the short answer is no: there isn't a ready-to-use container class of this sort for you.

However, it is easy to make one yourself: make a Map of Maps and re-do the access operators. A Map will allow you to do

myEntry<bool>(large number) A;

A(5022) = true; (equivalent in Map syntax)

without excessive memory, and a 2-D equivalent should do what you need. If you're not hapy with a hashed version of Map in FOAM, you could have a go at using the STL version. This is implemented as a balanced binary tree and you still need to do the 2-D wrapping yourself.

Good luck,

Hrv

hemph September 27, 2005 16:57

Maps you say! I started buil
 
Maps you say!
I started building my own sparse class using linked lists, but I am concerned about the cost involved in searching the, possible very large, unordered indexing vectors. I will look into Maps as soon as possible.

Thanks for all help!
rasmus


All times are GMT -4. The time now is 20:45.