Questions tagged [petsc]

PETSc is an open source suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations.

Filter by
Sorted by
Tagged with
24
votes
5answers
6k views

What are the main differences between PETSc and Trilinos?

As far as I can tell, the two big generic US Department of Energy computational science software frameworks are PETSc and Trilinos. They seem similar at first glance, beyond differences in language (...
24
votes
2answers
11k views

Why is my iterative linear solver not converging?

What can go wrong when using preconditoned Krylov methods from KSP (PETSc's linear solver package) to solve a sparse linear system such as those obtained by discretizing and linearizing partial ...
22
votes
1answer
11k views

Why is Newton's method not converging?

I am using PETSc's nonlinear solver package SNES to solve a system of nonlinear equations obtained by discretizing a partial differential equation. How can I determine why the solver is not converging ...
17
votes
2answers
1k views

Which libraries have good high-level support for multigrid?

I'm planning to use multigrid to calulate some eigenvalues and vectors, and I noticed PETSc has high-level support for multigrid. The PETSc documentation says that this part of PETSc should not be ...
15
votes
1answer
3k views

How can I estimate the condition number of a large sparse matrix using PETSc?

I have a PETSc Mat and would like to estimate its condition number.
14
votes
3answers
1k views

Why is my parallel solver slower than my sequential solver?

I was playing around with PETSc and noticed that when I run my program with more than one process via MPI it seems to run even slower! How can I check to see what is going on?
14
votes
2answers
2k views

How useful is PETSc for Dense Matrices?

Wherever I have seen, PETSc tutorial/documents etc. say that it is useful for linear algebra and usually specifies that sparse systems will benefit. What about dense matrices? I am concerned about ...
13
votes
4answers
3k views

Any recommendations for unit-testing frameworks compatible with code/libraries that use MPI?

Usually, I write serial code, and when I do, I write unit tests with some xUnit-style testing framework (MATLAB xUnit, PyUnit/nose, or Google's C++ testing framework). Based on a cursory Google ...
13
votes
5answers
2k views

Calculation of the sparsity structure for finite element matrices

Question: What methods are available to accurately and efficiently calculate the sparsity structure of a finite element matrix? Info: I'm working on a Poisson Pressure Equation solver, using Galerkin'...
12
votes
3answers
2k views

Sparse linear solver for many right-hand sides

I need to solve the same sparse linear system (300x300 to 1000x1000) with many right hand sides (300 to 1000). In addition to this first problem, I would also like to solve different systems, but with ...
12
votes
2answers
2k views

Which preconditioners (and solver) in PETSc for indefinite symmetric systems should I use?

My system is a symmetric FE problem with lagrange multipliers (e.g. incompressible Stokes' flow): \begin{pmatrix}A & B^T \\ B & C\end{pmatrix} where $C = 0$ is the typical case (I have even ...
11
votes
2answers
2k views

Efficiency of using petsc4py vs. c/c++/fortran

How much slower is petsc4py vs c/c++/fortran? I realize it will depend significantly on the code being executed, but what about something simple like a matrix-vector product?
11
votes
2answers
5k views

How to work with function pointers in Fortran in scientific programs

Here is a typical usage of function pointers in C. I would like to do something similar in Fortran. I have some ideas, but I would like to know if there is some canonical way to do so. The function ...
10
votes
1answer
1k views

Solving a simple Ax=b system in parallel with PETSc

I am new to the PETSc package. I have a ~4000x4000 matrix A in matrix-market format and I want to get PETSc to solve this using multiple processors. I know how to solve the system on a single ...
10
votes
3answers
2k views

Thrust for GPU programming

I'm very new to GPGPU programming so please forgive me if the question is not particularly appropriate. From what I understand GPU programming is a very intricate piece of engineering work when ...
10
votes
1answer
740 views

Does PETSc ever make use of LAPACK libraries for sparse matrix math?

Does compiling PETSc with an external BLAS/LAPACK library significantly affect performance on sparse matrices, or does it only use those libraries for dense matrix math?
9
votes
3answers
1k views

Are there any “light-weight” FEM packages around?

Basically, FEM seems to be a problem that is pretty much "solved". There are numerous powerful frameworks existing, like Trilinos, PETSc, FEniCS, Libmesh or MOOSE. One thing they have in common: They ...
9
votes
4answers
1k views

What is a robust, iterative solver for large 3-d linear-elastic problems?

I'm diving into the fascinating world of finite element analysis and would like to solve a large thermo-mechanical problem (only thermal $\rightarrow$ mechanical, no feedback). For the mechanical ...
9
votes
1answer
1k views

preconditioner for a matrix-free method to solve Ax=b

I need to solve Ax=b, but I realize that even if it is sparse, storing the matrix coefficients of my problem will take too much memory. So now I'm considering using a matrix-free method, because the ...
8
votes
1answer
970 views

How can I compute the Schur complement in PETSc?

How can I compute the Schur complement: $$ S = K_{bb} - K_{ba} K_{aa}^{-1} K_{ab} $$ where $$ K=\begin{pmatrix} K_{aa} & K_{ab} \\ K_{ba} & K_{bb} \end{pmatrix} $$ (in some ordering) is a ...
8
votes
1answer
2k views

How to get sparse complex matrices from my code to PETSc efficiently

What is the most efficient way to get a complex sparse matrix from my Fortran code to PETSc? I understand that this is problem dependent, so I tried to give as many relevant details as possible below. ...
8
votes
1answer
338 views

Is the sparsity pattern of a linear system important for iterative (KSP) solvers?

Pretty much the question. Given a general sparse, non-symmetric (both numerically and structurally) matrix, how important is the sparsity pattern (i.e. row/column permutation of matrix/vector) for ...
8
votes
2answers
1k views

How do I compute the parallel overhead of a parallel code run on a single processor when no sequential code is available?

I'm profiling the performance of PETSc's linear solvers. As I understand it, $$\text{speedup}=\frac{\text{Sequential Time}}{\text{Parallel Time}}.$$ I know that running the parallel code on one ...
8
votes
1answer
540 views

Using algebraic multigrid for preconditioning convection-diffusion operators

I implemented a Navier Stokes based on FEM discretization and PETSc for solving the linear system of equations. To create an efficient solution procedure, I follow the paper "Efficient preconditioning ...
8
votes
1answer
880 views

Solving a large non-hermitian generalised eigenvalue problem from a linear stability analysis using SLEPc

I have a generalised matrix problem: $A x = \lambda B x$ from a spectral method on a linear stability analysis problem. My matrix B is diagonal and positive semi-definite. A is non-hermitian and ...
7
votes
2answers
287 views

Comparing various implementations/software packages for large-scale finite element simulations

I currently use FEniCS and Deal.II to solve various FEM problems. I am also writing my own implementation of these problems by directly implementing the data structures, routines, and solvers within ...
7
votes
2answers
221 views

How can I tell which options PETSc was compiled with?

I'm working on a machine with a version of PETSc compiled by someone else. Is there a straightforward way to find out which options were used at compile time from the installation itself? For example,...
6
votes
2answers
616 views

Is it possible to dynamically resize a sparse matrix in the Petsc library?

This may be a Petsc newbie question, but... I'm using Petsc to solve a large sparse linear system. The initial creation of the matrix is fairly slow, which I'm given to understand is largely due to ...
6
votes
3answers
393 views

Preconditioner for finding the smallest eigenpairs of a large, but structured, matrix

I'm trying to find the eigenvector corresponding to the second smallest eigenvalue of a large $(4,000,000 \times 4,000,000)$ matrix $L$. $L$ is a graph Laplacian, with the following structure: $L = D -...
6
votes
1answer
412 views

Reference BLAS/LAPACK from NETLIB is twice as fast as MKL for complex numbers

I'm solving the Helmholtz equation using PETSc. I found with the PETSc configure option --download-f-blas-lapack my program runs twice as fast over running it with ...
6
votes
1answer
2k views

MPI-based Implementations of FFT

In a numerical computation, I am required to take a multi-dimensional FFT on a distributed-memory cluster. The data is currently distributed using a distributed array in PETSc (DMDA). I initial ...
6
votes
1answer
102 views

How do you change the desired accuracy of a TS object in PETSc?

I'm currently getting very long propagation times when attempting to use the Time Stepping propagators in Petsc 3.2, and in the interest of speeding things up, I'm curious how I can reduce the ...
6
votes
1answer
210 views

Advice on solving a coupled physics problem

I am taking a shot at solving a coupled physics problem. I have this matrix formed: $\mathbf{J}=\begin{bmatrix} \mathbf{A} & \mathbf{B}\\ \mathbf{C} & \mathbf{D} \end{bmatrix}$ where $\...
5
votes
2answers
1k views

Computing matrix exponential with PETSc/SLEPc

My question is basically the best way to compute the matrix exponential in parallel. I've got a sequential code written in Python (https://github.com/hadsed/AdiaQC) and I need to extend it to run in a ...
5
votes
2answers
391 views

PetSc vs Sundials for serial numerical computations?

I am currently working on a physics problem that turns into a non-linear boundary value problem. I need an efficient numerical solver that I could run on my laptop with i5 dual core CPU. I am ...
5
votes
1answer
190 views

What is the difference between MATSEQMAIJ and MATSEQAIJ in PETSc?

What is the difference between MATSEQMAIJ and MATSEQAIJ in PETSc? Also, where can I find more information on each of the MatTypes? I went to the MatType documentation, but it didn't have anything but ...
5
votes
1answer
119 views

Can Variational Inequalities handle non-symmetric matrices?

I am trying to enforce the discrete maximum principle (i.e., ensuring non-negative concentrations) for diffusion-type problems that have an anisotropic diffusivity tensor (e.g., tensor dispersion from ...
5
votes
2answers
118 views

Odd accuracy barrier in C/PETSc regarding finite elements

I’m implementing a finite element code (translating from a working MATLAB version, so I have results to compare to) and for some odd reason, some of my computations are only accurate to around 6 ...
5
votes
1answer
158 views

Is there a way to inspect the graph of a sparse matrix with PETSc?

I am currently trying to code the CA-CG method within the PETSc framework. A mandatory step in this process is the implementation of the "matrix powers kernel" algorithm for a generic sparse matrix. ...
5
votes
1answer
794 views

Basic questions regarding slepc4py/petsc4py

I am brand new to slepc4py and petsc4py (and SLEPc and PETSc in general), and I have a few basic questions. I apologize if these have been answered somewhere - I've looked around for a while and haven'...
4
votes
2answers
121 views

Installing only a portion of PETSc

I want to incorporate matrix solver into my program. Is it possible to separate out any library of matrix solver from PETSc? I am working in C language. It will be very helpful if I get any library ...
4
votes
3answers
313 views

Overlapping communication and computation in PETSc and/or Trilinos?

I am just learning about these packages, so forgive me if this is a trivial/silly question. Our group is working re-developing our code from the ground up using modern software practices. Currently ...
4
votes
3answers
1k views

CPU benchmarks for numerical kernels

CPU benchmarks available online mostly focus on desktop apps/games and rarely on serial/parallel numerical kernels, specially sparse ones (e.g., MatMult). Some benchmarks like NAS/SciMark exists but ...
4
votes
2answers
3k views

Developing finite volume (FVM) code in C . General advice

I need to develop a FVM code in C (The multiscale FVM method for heterogeneous media). I know that: Only uniform rectangular grids will be considered (2d now, later 3d) Sparse systems will be large ...
4
votes
2answers
1k views

How should I build a 2D 5-point stencil Laplacian matrix in parallel?

I'm making a simple eigenvalue solver with SLEPc, using a 5-point stencil and the finite difference method. I want to be able to assemble the matrix in parallel. My first thought was just to use <...
4
votes
1answer
340 views

PETSc input format for linear solvers

I’m going through some considerable effort to translate one of my codes from MATLAB. It’s a type of finite element code and I haven’t implemented the solver yet but comparing CPU times for simply ...
4
votes
2answers
1k views

Solve a linear system with BiCGStab instead of GMRES in PETSC

Below a piece of code is shown to solve a linear system. ...
4
votes
1answer
429 views

When is MatGetArray/VecGetArray useful?

In petsc, there are already SetValues(Local) methods. But when does one need GetArray methods? A related question: to copy a portion of a Mat/Vec to part of another Mat/Vec, it is usually suggested ...
4
votes
1answer
2k views

How to run a PETSc example?

I just installed the PETSc library. This is what I did from the home directory ~ ...
4
votes
2answers
513 views

What is the basic requirement to understand the PETSc library?

I want to use the PETSc library to do some numerical work on finite element and parallel computing, but I wonder what I should know first to use these libraries. Could you give me some guiding ...