# how to compute non zero in fem

 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 27, 2008, 01:19 how to compute non zero in fem #1 ztdep 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, 06:21 Re: how to compute non zero in fem #2 Jed 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, 08:48 Re: how to compute non zero in fem #3 ztdep 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, 09:25 Re: how to compute non zero in fem #4 Jed 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, 09:36 Re: how to compute non zero in fem #5 ztdep 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, 09:39 Re: how to compute non zero in fem #6 ztdep 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, 10:01 Re: how to compute non zero in fem #7 Jed 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, 11:27 Re: how to compute non zero in fem #8 ztdep Guest   Posts: n/a could you please detail it further. i can not fully understand you .

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post nkliuyueming Main CFD Forum 7 January 29, 2016 14:28 Vasilis Main CFD Forum 3 July 31, 2009 07:59 kenn Main CFD Forum 2 July 18, 2004 18:28 Gerhard Main CFD Forum 2 March 10, 2004 12:45 Astrid Main CFD Forum 18 December 15, 2000 01:02

All times are GMT -4. The time now is 10:40.