Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling Large Stiffness Matrix

Status
Not open for further replies.

ctmfab

Mechanical
Oct 1, 2002
21
Does any know how to handle very large arrays or matrices in VB6.0. I get a memory error when using arrays that are of several thousand terms. (ie 3000x3000). This is for math calculations for stiffness matrix of steel structures.

I have seen suggestions to use an array of arrays. In other words each row of the matrix would have an array. This seems to be a good idea, but I don't know how to create additional arrays at runtime since the actual size of the matrix is unknown at design time.

Any ideas appreciated.
 
Replies continue below

Recommended for you

Either an array of arrays as suggested or if all else fails you can write the array to the HD... might slow things down a tad, thought... I haven't had to use that since early DOS stuff.

I use Delphi, and it's pretty easy to create an array of arrays, and I used to do it in VB4... before I migrated... shouldn't be too difficult in VB, though.
 
I would use FORTRAN. I also wrote a routine in BASIC to do matrix inversion and othe functions. Of course BASIC is almost extinct these days.
 
I have nor used VB, but with Pascal and/or C, C++, there is a technique to generate somthing similar to dynamic memory or you can use linking list of pointer technique in C/C++ to generate new element in the matrix, this is just another way to manage element in order of the language.
I believe you can find this also in VB.
Good luck.
 
If you matrix is symmetric (which it probably is) and if it has plenty of zeros, you might consider storing only one half (upper triangle for example) as a vector and ommit non-zero elements (skyline). There are solvers around for this approach, but they were mainly written in fortran. Also, this might add a little to your execution time. If you decide to go for this option, it might be worth considering adding a routine to optimize element/node numbering.

If you are programming an FE program, using a frontal solver might help you to avoid large matrices problem since you do not need to forma a global stffness matrix- see Hinton and Owen Finite Element Programming for example.
 
For a 3000 by 3000 matrix... you are talking about 9 million array elements. If you are using single precicion floating point math... You'll need 36 MB of memory just to hold your data. Of course... for a matrix of that size... single precision math is likely going to blow up in your face. You need double precision ( 8 byte ). I'm not sure what that data type is called in VB. So... now you're talking about 72 MB just to hold your stiffness matrix values. You'll then need more memory to solve your problem. And... don't forget about memory to load your executable code and to run Windows itself. I'm not sure what limits VB is putting on your arrays. Look in your VB documentation. It should be able to accept your values... though you should probably be using some type of dynamically allocated arrays.

I'd recommend that you don't try to code an "array of arrays". If VB won't let you do the array size you need, then... VB is not the language you should be using. As others have already suggested... it is highly likely that you don't actually need a matrix that large. You really don't want to store and solve ALL elements of your matrix if the overwhelming majority of your elements are zero. Of course... the techniques for solving these matrix equations is well beyond the scope of this forum. Frontal solvers are great!!! However... implementing them is anything but simple. Look for information on Band and Skyline and Envelope storage and solver methods.

Last... but last... If you DO have to solve equations with so many terms... I HIGHLY suggest you use something other than VB. Even if you can get VB to solve your equations... you will be waiting forever plus some. Even for simple string manipulation algorithms ( where VB is supposed to be worthy ), I've found that simple Fortran code will run considerably faster. For numerical computations... the timings will be incredibly different. I personally recommend Fortran. Of course... C and C++ would be other common choices.

If you're using VB for it's GUI capabilities... that's fine. Write a VB front and back end with a Fortran DLL to do your actual number crunching. Of course... before you do any of these things... I suggest you do a little research to see if you actually need to work with such large matrices. ( hint: if you are inverting your matrices... you are doing way too much work ).

Dan ;-)
 
Thanks for the input from everyone. The start of this little project is to create a parametric modeler to model smaller geometries in 2D. This way I can model up to about 500 nodes even if no improvement is made to the solution algorithm. However, this would be incredibly slow so I won't waste my time with simple inversion.

I agree with most of the comments above, especially regarding solving ALL 3000 equations. I am only using the top half of the matrix, and plan to implement the Skyline method and solve by Cholesky factorization. Also, since it will be parametric, I can optimize the node order any way I like without much difficulty. However, most of the Skyline examples I have seen use LU factorization.

Is Cholesky OK or should I stick with LU? Everything seems to indicate that Cholesky is fastest.
 
Stick with Cholesky. It's stable and pretty easy to implement. All you really need is the simple Cholesky method ( which is essentially LU factorization ). If you implement a skyline system... you're code will probably run quite fast ( I have several codes of my own implementing Cholesky with skyline methods ). A banded method is often acceptable also. It's not quite as good as skyline, but.... it's easier and faster to code.

Good Luck,
Dan :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor