"Babak" <b.*******@gmail.com> skrev i en meddelelse

news:11********************@e56g2000cwe.googlegrou ps.com...

Hello everyone,

I'm working on some Finite Elements(FE) codes in C and now I

encountered some problems in assembly stage. The main idea is

that a

large number of 3 by 3 elemental stiffness matrices are

calculated and

then they should mapped to specific elements in a very big and

sparse

global stiffness matrix. I think the preferred storage format

for the

sparse matrix is Compresses Row Storage (CRS) format because it

is

compatible with many different sparse solver packages. Now the

problem

is that I have no idea how to update and assemble "ia"

(pointers to the

begining of each row), "ja" (column indices) and "a" (nonzero

values)

arrays as each local stiffness matrix is calculated in the

loop. Is it

I don't know about finite element, but I am trying to make a

finite difference program work using something like:

for(i=2, count = 0, no = 0 ; i< nx; i++) {

for(j=2; j< ny; j++) {

if(unknowns[i][j] == 1) {

no++;

pfvector_a[++count] = koeffB[no];

pivector_j[count] = (i-2)*(nx-2) + (j-1);

/* middle cell */

pivector_i[count] = no;

}

if(unknowns[i][j-1] == 1) {

pfvector_a[++count] = koeffA[no];

pivector_j[count] = (i-2)*(nx-2) + (j-2);

/* left */

}

if(unknowns[i][j+1] == 1) {

pfvector_a[++count] = koeffC[no];

pivector_j[count] = (i-2)*(nx-2) + (j);

/* right */

}

if(unknowns[i-1][j] == 1) {

pfvector_a[++count] = koeffE[no];

pivector_j[count] = (i-3)*(nx-2) + (j-1);

/* row up */

}

if(unknowns[i+1][j] == 1) {

pfvector_a[++count] = koeffD[no];

pivector_j[count] = (i-1)*(nx-2) + (j-1);

/* row down */

}

}

}

That is a 2D problem so for each unknown equation in the matrix I

have to look left, right, up and down in order to take boundary

effects in consideration (my first and last cell doesn't have as

many coefficients as the interior cells - actually that applies

to all cells on the domain boundaries). In my code my mesh is

defined from (1,1) to (nx, ny) - or is it (ny, nx)? It's not

completely finished yet.....

Using this method, I have a 2D array called unknowns which allows

me to do calculation on arbitrarily shapes (circle, triangle, L

or T-shaped or even more random if I like) - the routine takes

care of inserting the correct coefficients so if we're standing

on the left top boundary ofcourse there's no coefficient above

and to the left for that equation...

However, I must also say that my code doesn't work at the

moment.... Don't know if there's anything I forgot to include,

since this is also my first time working with such a solver that

requires this format (am trying to make a conjugated gradient

solver work)....

You're saying that this format with "ia" (pointers to the

begining of each row), "ja" (column indices) and "a" is called

Compressed Row Storage (CRS) format ? I didn't knew that, so if

you make any progress I would be interested in seeing how you

solve the problem - (you can also mail me, just remove the .spam

and spam. before and after the @).

Best regards / Med venlig hilsen

Martin Jørgensen

--

---------------------------------------------------------------------------

Home of Martin Jørgensen -

http://www.martinjoergensen.dk