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

C++ solver for Large sparse matrix!

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 18, 2009, 10:17
Exclamation C++ solver for Large sparse matrix!
  #1
Member
 
SinaJ
Join Date: Nov 2009
Posts: 34
Rep Power: 7
sina_mech is on a distinguished road
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
sina_mech is offline   Reply With Quote

Old   November 19, 2009, 10:43
Default
  #2
New Member
 
Join Date: May 2009
Posts: 27
Rep Power: 8
walli is on a distinguished road
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.
walli is offline   Reply With Quote

Old   November 20, 2009, 03:52
Default
  #3
New Member
 
Dominic Chandar
Join Date: Mar 2009
Location: Singapore
Posts: 22
Rep Power: 8
dominic is on a distinguished road
Send a message via Skype™ to dominic
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
dominic is offline   Reply With Quote

Old   November 20, 2009, 09:40
Default
  #4
New Member
 
Join Date: May 2009
Posts: 27
Rep Power: 8
walli is on a distinguished road
Quote:
Originally Posted by dominic View Post
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.
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.
walli is offline   Reply With Quote

Old   November 20, 2009, 13:19
Default
  #5
jed
Member
 
Jed Brown
Join Date: Mar 2009
Posts: 56
Rep Power: 10
jed is on a distinguished road
Quote:
Originally Posted by walli View Post
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.
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.
jed is offline   Reply With Quote

Old   November 20, 2009, 13:23
Default
  #6
jed
Member
 
Jed Brown
Join Date: Mar 2009
Posts: 56
Rep Power: 10
jed is on a distinguished road
Quote:
Originally Posted by walli View Post
Even though it is (in my opinion) ugly C code
What do you dislike? Perhaps I can explain why certain things are the way they are.
jed is offline   Reply With Quote

Old   November 20, 2009, 14:23
Default
  #7
New Member
 
Join Date: May 2009
Posts: 27
Rep Power: 8
walli is on a distinguished road
Quote:
Originally Posted by jed View Post
What do you dislike? Perhaps I can explain why certain things are the way they are.
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!
walli is offline   Reply With Quote

Old   November 20, 2009, 14:52
Default
  #8
jed
Member
 
Jed Brown
Join Date: Mar 2009
Posts: 56
Rep Power: 10
jed is on a distinguished road
Quote:
Originally Posted by walli View Post
That was more about C style programming than PETSc.
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:
Speaking about PETSc, I particularly don't like the inflationary use of the CHKERR-stuff.
Yes, I don't even see them anymore. The reason for this (and a couple other macros used within PETSc) is mostly to be able to get full stack traces when something goes wrong, as well as to detect memory corruption and leaks. C++ exceptions have serious interoperability problems and lack the semantics required to get reliable stack traces in parallel, as well as to automatically attach a debugger on the site where the error occurred (even in parallel). You certainly don't have to use these macros, but they really do make debugging easier.
jed is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


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


All times are GMT -4. The time now is 02:33.