Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: create large sparse FEM matrix --> out of memory
Date: Mon, 10 Aug 2009 18:00:22 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 25
Message-ID: <h5pn7m$3po$1@fred.mathworks.com>
References: <h5pbe7$nc2$1@fred.mathworks.com> <h5pf1k$qit$1@fred.mathworks.com> <h5pm76$ou1$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1249927222 3896 172.30.248.37 (10 Aug 2009 18:00:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Aug 2009 18:00:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:562204


"A B" <gitsnedbutzi@hotmail.com> wrote in message <h5pm76$ou1$1@fred.mathworks.com>...
> > There is something odd about the description. With a system of 25000 elements and 80e6 non-null entries, that means each of the element has in average 80e6/25e3 = 3200. That doesn't sound right. The average ratio should be about 10 depends on the element type you use, but in no way it could reaches 3200. 
> > 
> > To store " three double vectors of 80e9, you need 80e6*3*8 bytes = 1.9 Gbytes, and the resulting sparse matrix need about 80e6*2*8 = 1.3 Gbytes (i think). The total required memory is 3.2 Gbytes. I'm not surprised it does not fit into you 1.3 Gbytes memory.
> > 
> > The 80e6 non-zeros entries does not sound right to me.
> > 
> > Bruno
> 
> The element type in the example is a 20node hexahedron, with 3degrees of freedom (x,y,z) and since a FE matrix is always square it has 20*3x20*3 =3600 elements.

I see, but many of them must have the same indices. You don't need to list them all and build the stiffness matrix. I bet the final matrix has much less than 80 millions non-zero elements.

You might be able to allocate the matrix and fill it progressively (or by chunk). Might be loop differently when assembling would help.

> 
> as far as i know, some commercial FE packages write to the disk to temporarly store data and also the price of the license depends on how many nodes it can handle. however i dont know how to write such a code that transfers data to the hard disk and i also think it's very hard to make it efficient. however, i'm not sure wether that's really the way it works. just heard it somewhere...

Yes, this is absolutely needed 10 years ago where RAM is limited. For modern computer running on 64-bits OS, I believe writing on disk is no-longer required.

I bet your matrix can be stored entirely in the memory.

Take a look at this FEX, it might help to assemble matrix by chunk. http://www.mathworks.com/matlabcentral/fileexchange/23488

Bruno