
[Sponsors] 
November 18, 2009, 10:17 
C++ solver for Large sparse matrix!

#1 
Member
SinaJ
Join Date: Nov 2009
Posts: 50
Rep Power: 8 
Hi
I have a large sparse matrix (generated by Poisson Equation in my own C++ Code). I'm looking for a EASY TO EMBED AND USE, fast Sparse solver, witch can receive matrix of elements in sparse modes (to use lesser memory), and solve it by any of common fast methods (like Gmres, Bicgstab and ...). I'll appreciate if anyone can help me GoodLuck 

November 19, 2009, 10:43 

#2 
New Member
Join Date: May 2009
Posts: 28
Rep Power: 9 
Consider using PETSc for your code! Even though it is (in my opinion) ugly C code, one can fairly easy write a rudimentary C++ interface if needed. It is really fast, tested and provides a big variety of solvers and preconditioners. Another possibility would be mtl4, which is written in C++, fast, but unfortunately still in alpha development stage. But why do you want to use GMRES, BiCGSTAB and so on? You system is symmetric and positive definite, so use a (preconditioned) CG solver for this.


November 20, 2009, 03:52 

#3 
New Member

I would use PETSc for this. Moreover, application of boundary conditions, and/or sources can disrupt the symmetry of the matrix. Thats why probably you cannot use CG.
Dominic 

November 20, 2009, 09:40 

#4 
New Member
Join Date: May 2009
Posts: 28
Rep Power: 9 
Sure, that's true. But this clearly depends on the way you incorporate the BC's. A way to do this symmetrically would be e.g. a penalty method.


November 20, 2009, 13:19 

#5 
Member
Jed Brown
Join Date: Mar 2009
Posts: 56
Rep Power: 11 
Penalty is a bad choice with some preconditioners, or if the system is very illconditioned. The best way is to remove the Dirichlet degrees of freedom, either explicitly, or by making both] the row and column equal to the identity (with appropriate modification of the right hand side). This is easy to do, especially when using Newtontype iteration, but people still manage to write code in a way that makes this hard. Note that many good preconditioners are nonsymmetric sometimes enough better than the symmetric alternatives to justify using a nonsymmetric Krylov method.


November 20, 2009, 13:23 

#6 
Member
Jed Brown
Join Date: Mar 2009
Posts: 56
Rep Power: 11 

November 20, 2009, 14:23 

#7 
New Member
Join Date: May 2009
Posts: 28
Rep Power: 9 
That was more about C style programming than PETSc. Speaking about PETSc, I particularly don't like the inflationary use of the CHKERRstuff. But don't get me wrong! It is a great library and it does its job very good!


November 20, 2009, 14:52 

#8  
Member
Jed Brown
Join Date: Mar 2009
Posts: 56
Rep Power: 11 
Note that while it is written in C, it is very much object oriented. PETSc objects use a variant of the delagator/pimpl pattern, but see object creation is (by default) managed by an inversion of control known as dependency injection. You might have heard of this in the context of frameworks like Spring. This has the advantage that your code never makes explicit reference to the implementation of your objects, just the interface that they implement. With this design, it is natural that every object has a plugin architecture. That is, you can compile a preconditioner and custom matrix format to a shared library send it to someone else who does not have source for anything, and they can select your preconditioner at run time just like the ones distributed with PETSc.
Quote:


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Working directory via command line  Luiz  CFX  4  March 6, 2011 21:02 
free C code for large sparse matrix linear solver  ztdep  Main CFD Forum  7  May 24, 2007 14:14 
problem about direct solver for sparse matrix  ztdep  Main CFD Forum  0  August 11, 2006 12:16 
Aztec  sparse matrix paralell solver  Astrid  Main CFD Forum  7  August 3, 2001 12:41 
solver for linear system with large sparse matrix  Yangang Bao  Main CFD Forum  1  October 25, 1999 04:22 