|
[Sponsors] |
September 27, 2008, 02:19 |
how to compute non zero in fem
|
#1 |
Guest
Posts: n/a
|
Dear friends: How to computet the nuber of nonzeros in the fem method for liner triagnualr lelement in 2 d problem regardds
|
|
September 27, 2008, 07:21 |
Re: how to compute non zero in fem
|
#2 |
Guest
Posts: n/a
|
Initialize a vector v to all ones. Iterate over the elements and for each node n, and different node p, add 1/2 to v[n] if p is not on a boundary and add 1 to v[n] if p is on a boundary. The vector now has the number of nonzeros in the each row. (The 1/2 is because every interior neighbor will be counted twice in 2D. In 3D there is an extra step to fix the duplicate counts.)
A similar algorithm can be used in parallel to determine the number of nonzeros for the `diagonal block' and the `off-diagonal block'. Distinguishing these is important for preallocation in parallel. |
|
September 27, 2008, 09:48 |
Re: how to compute non zero in fem
|
#3 |
Guest
Posts: n/a
|
thank you very much for your feedback. it is a great idea. I now working on my FEM code now, and i want to write the global matrix into the CSR (compressed sparse row) format, so as to use the BCGSTAb method. Could you please give me some idea. Regards
|
|
September 27, 2008, 10:25 |
Re: how to compute non zero in fem
|
#4 |
Guest
Posts: n/a
|
Once you know the number of nonzeros per row, a `scan' operation gets you the starting offset for each row. Then you iterate over the elements and actually assemble values. I recommend using a library like PETSc, but it's not difficult to implement yourself if (a) you are sure you only want to use BCGStab and (b) you are sure you know exactly what preconditioner you want to use. If this isn't a purely academic exercise, then you should not sure of either. If you use PETSc (http://mcs.anl.gov/petsc) see MatSeqAIJSetPreallocation() and MatSetValues().
|
|
September 27, 2008, 10:36 |
Re: how to compute non zero in fem
|
#5 |
Guest
Posts: n/a
|
thank you very much dear friends. i am working under windows now, and i now have the solver with BCGSTAB and ilu preconditioner. so the only thing is the matrix in the CSR format. regards.
|
|
September 27, 2008, 10:39 |
Re: how to compute non zero in fem
|
#6 |
Guest
Posts: n/a
|
why did you say "The 1/2 is because every interior neighbor will be counted twice in 2D" , i am sorry that i can not fully agree with you. if a node have 5 elemetn aroud it. then it will be count 5 times, then we will have a value of 5/2.am i right let me know please if i am wrong
|
|
September 27, 2008, 11:01 |
Re: how to compute non zero in fem
|
#7 |
Guest
Posts: n/a
|
It will be counted exactly twice in each row. There are exactly two elements which have both the row-node and the column-node. In 3D you can have several elements which share an edge, hence the extra step.
|
|
September 27, 2008, 12:27 |
Re: how to compute non zero in fem
|
#8 |
Guest
Posts: n/a
|
could you please detail it further. i can not fully understand you .
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
I developed an FEM toolkit in Java: FuturEye | nkliuyueming | Main CFD Forum | 7 | January 29, 2016 14:28 |
How do I compute the normal vector to a surface with FEM | Vasilis | Main CFD Forum | 3 | July 31, 2009 08:59 |
comments on FDM, FEM, FVM, SM, SEM, DSEM, BEM | kenn | Main CFD Forum | 2 | July 18, 2004 19:28 |
FEM (LSFEM vs GLS FEM vs Penalty) for Stokes equ. | Gerhard | Main CFD Forum | 2 | March 10, 2004 12:45 |
FEM or FVM for CFD | Astrid | Main CFD Forum | 18 | December 15, 2000 01:02 |