|
[Sponsors] |
November 18, 2009, 10:17 |
C++ solver for Large sparse matrix!
|
#1 |
Senior Member
SinaJ
Join Date: Nov 2009
Posts: 136
Rep Power: 17 |
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: 17 |
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 |
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: 17 |
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: 19 |
Penalty is a bad choice with some preconditioners, or if the system is very ill-conditioned. 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 Newton-type 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: 19 |
||
November 20, 2009, 14:23 |
|
#7 |
New Member
Join Date: May 2009
Posts: 28
Rep Power: 17 |
That was more about C style programming than PETSc. Speaking about PETSc, I particularly don't like the inflationary use of the CHKERR-stuff. 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: 19 |
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:
|
||
|
|
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 15:14 |
problem about direct solver for sparse matrix | ztdep | Main CFD Forum | 0 | August 11, 2006 13:16 |
Aztec - sparse matrix paralell solver | Astrid | Main CFD Forum | 7 | August 3, 2001 13:41 |
solver for linear system with large sparse matrix | Yangang Bao | Main CFD Forum | 1 | October 25, 1999 05:22 |