Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: create large sparse FEM matrix --> out of memory
Date: Mon, 10 Aug 2009 14:39:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <h5pbe7$nc2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1249915143 23938 172.30.248.37 (10 Aug 2009 14:39:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Aug 2009 14:39:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1337510
Xref: news.mathworks.com comp.soft-sys.matlab:562126


Hi,

I'm writing a FEM application and need to create large sparse matrices.

Unfortunately I run out of memory pretty soon, so I need to know how to write a more memory efficient code in MATLAB.

Here's what I do at the moment to create the stiffness matrix:

I know the number of elements and the size of a single element matrix. I use this information to preallocate the memory for three vectors, storing
*row index
*column index
*value

Then I calculate the element matrices and start filling up those three vectors with the appropriate information and finally K = sparse(row,col,val) for assembling the global matrix.

Now I've got a system with 25 000 elements resulting in a length of about 80million entries for each vector. With 1300MB of free memory MATLAB can't even create the vectors and stops with a "out of memory" error.

Is there a better way both spped and memor-wise?
The one I use is as suggested for a fast creation of the sparse matrix and I also don't think it's to bad memory-wise as the siye scales linear with the number of elements.

Any help is appreciated! Thanks a lot!