CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

how to compute non zero in fem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2008, 02:19
Default 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
  Reply With Quote

Old   September 27, 2008, 07:21
Default 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.
  Reply With Quote

Old   September 27, 2008, 09:48
Default 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
  Reply With Quote

Old   September 27, 2008, 10:25
Default 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().
  Reply With Quote

Old   September 27, 2008, 10:36
Default 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.
  Reply With Quote

Old   September 27, 2008, 10:39
Default 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
  Reply With Quote

Old   September 27, 2008, 11:01
Default 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.
  Reply With Quote

Old   September 27, 2008, 12:27
Default 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 .

  Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


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