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.
151
questions
5
votes
2answers
508 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 ...
2
votes
1answer
406 views
PETSc: Blocking matrices using MatCreateSeqBAIJ and MatSetValuesBlocked
I am a little confused with PETSc's documentation for MatSetValuesBlocked. The code below works fine for matrices when I choose small block sizes, but I get errors ...
1
vote
1answer
212 views
The alternative to using PETSc's SNES solvers in parallel without using the DMDA methods
I am using the PETSc libraries, in particular using the SNES solver package to solve a nonlinear matrix equation. Is there a way of parallelising the solution to this problem problem without using ...
1
vote
0answers
111 views
PETSc - difference between PetscNew and PetscMalloc
I wonder what is the difference between both functions.
In C++, the difference between new and malloc is easier: new allocates memory by calling the constructor.
What about PETSc ? In the example, ...
1
vote
1answer
97 views
PETCs - How should one initialize PetscRandom?
The documentation of PETSc shows an example of usage:
...
0
votes
1answer
103 views
PETSc - how computing a random number between 0 and 1?
In PETSc, I need to generate a random number between 1 and 0.
With the include cstdlib, the classical trick is:
...
2
votes
0answers
174 views
Is it worth switching to timesteppers provided by PETSc if I can't write down a Jacobian for my problem? Case study with “the amoeba” toy problem
I am considering using petsc4py instead of scipy.integrate.odeint (which is a wrapper for Fortran solvers) for a problem ...
3
votes
1answer
721 views
Why is MPI/PETSc only showing 1 processor even though it works for helloworld?
I am a beginner with Unix and MPI. For the serial program, I run the program by typing make in /directory/buildagain and then <...
5
votes
1answer
139 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 ...
2
votes
0answers
171 views
preconditioned Uzawa method with Petsc
I am trying to improve the resolution of a Stokes problem (P2/P1 on unstructured mesh) defined by the matrix $M$:
$M=
\begin{pmatrix}
A_u & 0 & B_u \\
0 & A_v & B_v\\
B_u^T & B_v^...
3
votes
1answer
331 views
Sparse matrix vector product using PETSC
I am trying to do a simple parallel sparse matrix vector multiplications using PETSC. My sparse matrix is a simple tridiagonal laplacian matrix, which is distributed over multiple processors using ...
5
votes
0answers
283 views
Is it possible to predict the null space of a structure from contributing elements null spaces?
I am trying to solve an almost incompressible problem with heterogeneous properties by domain decomposition. Solution with CG converges slowly or divergerces completely. My problem becomes ill-...
2
votes
0answers
585 views
Jacobian-Free Newton-Krylov vs explicitly forming jacobian in DG
For a given discontinuous galerkin (DG) implementation for Navier-Stokes, targeting 10,000 to 1,000,000 4th order cells in 3D, I'm using PETSc's suite of linear/non-linear solvers on the back-end. It ...
1
vote
1answer
154 views
Choosing hardware to use with PETSc
I would like to know more on choosing hardware to get the maximum price/performance when using the PETSc library (and various third-party preconditionners)
I am currently working on a 2 cpu (2*E5-...
2
votes
1answer
360 views
Construct a preconditioner for the linear system $Ax = b$ from a different matrix
When I use PETSc to solve my linear systems, I always use the subroutine
PetscErrorCode KSPSetOperators(KSP ksp,Mat Amat,Mat Pmat)
where ...
14
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 ...
1
vote
0answers
464 views
Get a single value from a global Vec in petsc [closed]
I don't understand the concept with local and global vec's in petsc when it come to DMDAVecGetArray and VecGetValues. I'm creating some DMDA Vec in parallel which works well. Now I want to access ...
1
vote
1answer
129 views
Parallel Monte Carlo simulation using PETSc
I am trying to do Monte Carlo simulation for a large problem which requires eigensolution of a matrix for each sample. The matrix itself is quite large so much so that I want the eigensolution itself ...
1
vote
1answer
102 views
Efficiently swap vectors in PETSC
The PETSC function VecSwap after a few layers of abstraction calls the BLAS primitive swap, which essentially copies data around (unless I am missing something).
...
0
votes
1answer
1k views
Domain Decomposition with PETSc
Does anyone have any experience on Domain Decomposition using PETSc library? I have used PETSc for creating my vectors and matrix within my C++ code. I also used KSP to solve the linear system.
I ...
4
votes
1answer
567 views
PETSc or Trilinos for GPU?
I have to choose between the PETSc and Trilinos libraries for a project that involves the solution of non-linear systems of equations.
From their web sites they both mention support for GPUs, ...
3
votes
0answers
246 views
Method with low memory requirement for large-scale eigenvalue problem
I am working on the flow stability problem. In this work the main complication is solving generalized eigenvalue problem for a large scale Non-Hermitian matrix. I need only one eigenvalue (most left ...
0
votes
1answer
147 views
Writing a 3D array from Petsc
I am trying to do something fairly simple somehow I have made it hard.
Is there an example of how to send a 3D array to a binary file?
5
votes
1answer
509 views
Applying Dirichlet b.c. to the Eigenvalue-Problem
If you use a FEM (on the variational formulation), you can discretize some continuous eigenvalue problem, $$L u = \lambda u \ \ \text{on} \ \Omega,$$
into some discrete, generalized eigenvalue problem,...
3
votes
1answer
345 views
Finite Elements Weak Formulation generalization
I am struggling with an equation that represents the Weak form of Galerkin method:
$ \phi^{T}F(\textbf{u})\sim \int_{\Omega}^{ } \phi.f_{0}(\mathit{u},\nabla \mathit{u}) + \nabla\phi:f_{1}(\mathit{u},...
8
votes
1answer
953 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 ...
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'...
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
...
3
votes
0answers
88 views
PETSc: KSP gives strange discontinuity at the edge between MPI processes [closed]
I'm using PETSc's SNES linesearch (NEWTONLS) to solve a system of nonlinear PDEs. SNES+KSP successfully solved a test problem of the same type before without any trouble.
However, with my current ...
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 ...
2
votes
0answers
144 views
How to reduce RAM requirement in PETSC and SLEPCreading large binary matrices [closed]
I have two 50000 x 50000 binary matrices A and B for solving A*x=lambda*B*x eigenvalue problem. These matrices are sparse. I am trying to solve using PETSC and SLEPC. My memory requirement shoots off ...
5
votes
2answers
122 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 ...
4
votes
1answer
177 views
Using PAPI in PETSc code
I am trying to count the number of cache misses, total cycles, etc. per iteration of a for loop inside MatMult_SeqSBAIJ_2() . I'...
1
vote
1answer
106 views
How to allocate memory for successive iterative solutions with potentially different non-zero structure?
Background
I am solving the unsteady heat equation in 3D using an alternating direction implicit (ADI) method. This means that I am solving three different tridiagonal systems within a single timestep ...
4
votes
1answer
369 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 ...
3
votes
1answer
299 views
Sparse linear solvers in C?
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'...
2
votes
2answers
761 views
mpi retrieve a variable value from process with known rank to process that made an mpi_something call
I have a need to get a variable value from another process rank of which I know. This happens in context of a parallel solver of a "A x = b" equation, for which process with rank 0 knows matrix A, and ...
4
votes
1answer
265 views
Is PETSc's DMDA relying on undefined behavior?
I was looking at the documentation for DMDAVecGetArray and was surprised that it could create a plain ordinary C array whose indices somehow ranged from, say, istart...
6
votes
3answers
465 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 -...
5
votes
2answers
2k views
Solve a linear system with BiCGStab instead of GMRES in PETSC
Below a piece of code is shown to solve a linear system.
...
2
votes
0answers
107 views
PETSc KSP Tutorial ex7 Output [closed]
I am learning PETSc following the tutorials of the distribution (version 3.4.1). My question is about the KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); (line 216) of ex7.c (KSP tutorial).
It teaches how to ...
5
votes
1answer
887 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'...
2
votes
1answer
484 views
PETSc Krylov Subspace and nullspace
How is the nullspace correction implemented in the PETSc conjugate gradient solver? I searched the source code and documentation, but could not find references on the actual implementation.
For ...
6
votes
1answer
214 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 $\...
3
votes
2answers
307 views
Is there MPI_Star instead of MPI_Win (window) for MPI_Get?
In FEM applications, each processor needs only data from neighboring processors, which gives a stencil or star pattern of communication. In MPI_Win for MPI_Get, one needs to setup a group of ...
4
votes
2answers
630 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 ...
4
votes
2answers
123 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 ...
6
votes
1answer
429 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 ...
13
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 ...
2
votes
1answer
897 views
Creating a local vector in a parallel PETSC program
In one of my PETSc programs, I need a processor to access values from another processor.
So in the PETSc FAQ's this issue has been briefly addressed here.
To create a local vector, I tried this
<...