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
2
votes
1answer
26 views

How do I print a PetscBag to a specific file?

I have a PetscBag in my program that I want to write to a filename I have stored as a string. If I want to write to stdout, there is a pre-made PetscViewer macro ...
4
votes
1answer
426 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
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
222 views

Do I need KSPSetOperators after PCSetOperators?

What I did is Create some PC named pc, and PCSetOperators(pc,A,A,..); Create KSP named ksp; KSPSetPC(ksp,pc); After the above process, am I still obliged to KSPSetOperators(ksp,A,A,..), or I can ...
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 ...
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?
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 ...
3
votes
1answer
218 views

What does MatGetOwnershipRange() do for sequential matrices?

I'm writing a petsc code using a sequential matrix type. Since I want it to be easy to parallelize, I put some stuff in the code that is useless now, but will make it easier to parallelize later. One ...
4
votes
1answer
197 views

MatMatMult and KSPSolve for MATMPIDENSE matrices

I'm trying to use MATMPIDENSE matrices to solve a system of type Ax=b, but I have some problems. The KSP documentation says that KSPSolve for dense matrices requires to set a 'gmres' solver and a 'lu' ...
1
vote
1answer
208 views

Error message when trying to get PETSc to draw to an X terminal by passing -mat_view_draw

I've made a matrix, and now I want to draw it on the screen to make a basic check of correctness. The documentation for MatAssemblyEnd() states that I can pass an ...
3
votes
0answers
156 views

Is there an easy way to read a PetscBag into a python dict?

I'm using a PetscBag to store the input parameters of my program. At some point, I'm going to need to use python to plot these parameters against some output parameters, and ...
2
votes
1answer
551 views

Implicitly casting PetscReal to the real part of PetscComplex

The version of Petsc installed on my machine has PetscScalar set to be complex. I am making a matrix which has all real entries. Something like the following code compiles: ...
3
votes
2answers
405 views

Why can't I compile a function using the CHKERRQ macro in PETSc?

I wrote a function to read in the runtime parameters my program takes. This function is in a different file than my main program; the two object files are linked after compilation. When I compile the ...
2
votes
1answer
91 views

What should a PetscBag be used for?

I've been trying to use a PetscBag to read in a number of options I want to pass to a program I'm writing. Before I came across the documentation for PetscBag, I was planning on using a struct and a ...
2
votes
1answer
58 views

Can PetscBags be used with 64 bit versions of petsc?

I was looking at the documentation for PetscBagCreate(), and it says that The size of the A struct must be small enough to fit in a PetscInt; by default ...
1
vote
1answer
57 views

What does PetscBagSetFromOptions() do?

I'm writing a program that uses PETSc and SLEPc, and I was looking for a convienient way to read in options from the command line. The description of ...
4
votes
1answer
600 views

Petsc not compiling c++ files

I'm having a problem where petsc is complaining about the type of PetscScalar (I get a whole bunch of errors from the c++ standard library that revolve around PetscScalar not defined). I believe it ...
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 ...
3
votes
3answers
2k views

How do I read a binary file into PETSc as a matrix?

I created a binary matrix using the following loop in c ...
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 ...
4
votes
2answers
739 views

Outputting a distributed vector in PETSc

I'm working with someone else's code that uses PETSc 3.0.0-p9. They have a vector at the end of the computation that is distributed among a number of different processors, and I want to output that ...
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 ...
2
votes
1answer
1k views

How to measure the overall performance of a PETSc program using the -log_summary flag?

When I run a PETSc example in parallel with the flag "-log_summary", the first two tables of information look something like this: ...
3
votes
1answer
1k views

Problems running a PETSc example in parallel

After configuring and building PETSc, I have successfully been able to run several examples. In particular, I am working with this example. I have been able to run the program using the following ...
2
votes
1answer
6k views

Compiling and running a “hello world” program in PETSc

I'm trying to compile a hello world program using PETSc, based off of this tutorial, slide 33 . How would I compile this? I know that I can't use a simple 'mpicc' command. When running the program, ...
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 ~ ...
23
votes
2answers
10k 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 ...
4
votes
1answer
496 views

PETSc's makefile system can't find MKL

I'm learning PETSc and trying to make the examples written in C. However, when I use the provided makefile, I get the following error: ...
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 (...
7
votes
2answers
218 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,...
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 ...
5
votes
2answers
605 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 ...
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 ...
8
votes
1answer
963 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 ...
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?
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.
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 ...