3
$\begingroup$

I'm working on translating a discontinuous Galerkin code from MATLAB to C and I'm at the final point where I need to solve a sparse system. I've taken a course in C before but I'm very rusty and wasn't all that good to begin with.

I've used LAPACK before but was wondering if there are better options out there. My professor uses PetSc but I was looking at the documentation and have no idea how to install it let alone use it. The "tutorial" section on the ANL site is written at a pretty high level already.

Also, for sparse solvers in C, is there a "special way" that the array has to be stored? Or can I just input my arrays as is into the solver and get the solution?

Here's a plot of the matrix structure enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ Unfortunately not. I've uploaded a plot of the matrix structure to the original post $\endgroup$ Commented Nov 19, 2013 at 18:17
  • 3
    $\begingroup$ @hardmath Please stop perpetuating that misconception. The "banded solvers" are for bands that are within a constant of the diagonal, where as PDE bands are a mesh-dependent distance from the diagonal. Using a banded solver for a PDE problem gives much worse performance and asymptotics than multifrontal methods, though (algebraic) multigrid may be better yet. This topic has been covered repeatedly on this site, e.g., scicomp.stackexchange.com/q/866 scicomp.stackexchange.com/a/869 scicomp.stackexchange.com/a/880 . $\endgroup$
    – Jed Brown
    Commented Nov 20, 2013 at 6:24
  • $\begingroup$ PETSc has a MATLAB interface, which may or may not be useful to you, depending on why you're converting the code to C. $\endgroup$ Commented Nov 20, 2013 at 9:45
  • $\begingroup$ @hardmath Yes, and if the OP looks for "banded storage", they'll end up with totally inappropriate methods. The good methods for the OP's problem (a PDE in more than one dimension) do not "take advantage" of banding. $\endgroup$
    – Jed Brown
    Commented Nov 20, 2013 at 15:20
  • 1
    $\begingroup$ @JedBrown: If it suits you, I've deleted my Comments. I wanted to elicit what kind of sparsity user1799323 is working with. Bear in mind the his elegant graphic was posted in response to my Comment. $\endgroup$
    – hardmath
    Commented Nov 20, 2013 at 15:49

1 Answer 1

1
$\begingroup$

A lot depends on whether you're interested in using iterative methods or direct factorization of the matrix to solve the system of equations. You need to be clear on the relative advantages and disadvantages of these approaches.

If you're interested in direct factorization, you might want to look at Tim Davis's SuiteSparse software.

For iterative methods, PETSc is highly recommended.

Either way, LAPACK is a poor choice, since it works only with dense matrices.

$\endgroup$
3
  • 1
    $\begingroup$ Unless you have a reason not to go through installation, I'd recommend PETSc since it can interface to direct solvers as well. $\endgroup$
    – mmirzadeh
    Commented Nov 19, 2013 at 20:01
  • $\begingroup$ Thanks. Does anyone have a suggestion for good video tutorials on how to get PETSc up and running? $\endgroup$ Commented Nov 19, 2013 at 21:39
  • $\begingroup$ Which OS are you using? Your professor might be able to help you with the installation, since he/she has evidently done that before. Getting stuff like PETSc running is overwhelming at first, so don't worry about looking ignorant or asking silly questions. Can't even begin to tell you how much stupid crap I did trying to make it work before I knew what I was doing. $\endgroup$ Commented Nov 20, 2013 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.