# \#petsc

**URL:** https://fenicsproject.discourse.group/tag/petsc/34.md

[Latest](https://fenicsproject.discourse.group/latest.md) · [Categories](https://fenicsproject.discourse.group/categories.md) · [Tags](https://fenicsproject.discourse.group/tags.md)

---

## [Cumulative failures after many MPC construction + SLEPc solve cycles in one process (dolfinx\_mpc 0.8.0, DOLFINx 0.8.0, complex PETSc)](https://fenicsproject.discourse.group/t/cumulative-failures-after-many-mpc-construction-slepc-solve-cycles-in-one-process-dolfinx-mpc-0-8-0-dolfinx-0-8-0-complex-petsc/19670)

<div class="topic-metadata">

**Author:** [@Kashf13\_Kashf](https://fenicsproject.discourse.group/u/Kashf13_Kashf)\
**Replies:** 1\
**Last updated:** [April 24, 2026, 12:53pm UTC](https://fenicsproject.discourse.group/t/cumulative-failures-after-many-mpc-construction-slepc-solve-cycles-in-one-process-dolfinx-mpc-0-8-0-dolfinx-0-8-0-complex-petsc/19670 "2026-04-24T12:53:24Z")

</div>

I’m computing elastic Bloch band structures using dolfinx\_mpc.MultiPointConstraint for periodic boundary conditions. Each k-point builds an MPC with the appropriate Bloch phase, assembles K and M, and solves a generalize…

---

## [FFCX compiler files size limit with petsc.assemble\_matrix](https://fenicsproject.discourse.group/t/ffcx-compiler-files-size-limit-with-petsc-assemble-matrix/19654)

<div class="topic-metadata">

**Author:** [@mariom121](https://fenicsproject.discourse.group/u/mariom121)\
**Replies:** 11\
**Last updated:** [April 17, 2026, 2:52pm UTC](https://fenicsproject.discourse.group/t/ffcx-compiler-files-size-limit-with-petsc-assemble-matrix/19654 "2026-04-17T14:52:21Z")

</div>

Dear Fenics community: 'm building a fenicsx / dolfinx code for a physical equation built with sympy, which is very intrincate. The physics of the equation are fine but I need to emulate spectral methods and thus I need …

---

## [Canonical way to apply PETSc matrix to fem.Function vector](https://fenicsproject.discourse.group/t/canonical-way-to-apply-petsc-matrix-to-fem-function-vector/17924)

<div class="topic-metadata">

**Author:** [@lucasmyers97](https://fenicsproject.discourse.group/u/lucasmyers97)\
**Replies:** 1\
**Last updated:** [July 8, 2025, 11:53pm UTC](https://fenicsproject.discourse.group/t/canonical-way-to-apply-petsc-matrix-to-fem-function-vector/17924 "2025-07-08T23:53:11Z")

</div>

I have an explicit time evolution scheme that I would like to iterate by applying a bilinear form to a solution vector (repeatedly). From the elasticity tutorial it appears that one may assemble a PETSc matrix A from a b…

---

## [Improving Parallel Scalability of Linear Elasticity Code in FEniCSx](https://fenicsproject.discourse.group/t/improving-parallel-scalability-of-linear-elasticity-code-in-fenicsx/17862)

<div class="topic-metadata">

**Author:** [@Dan](https://fenicsproject.discourse.group/u/Dan)\
**Replies:** 2\
**Last updated:** [July 2, 2025, 4:54am UTC](https://fenicsproject.discourse.group/t/improving-parallel-scalability-of-linear-elasticity-code-in-fenicsx/17862 "2025-07-02T04:54:20Z")

</div>

I’m trying to study the parallel scalability of a 3D linear elasticity problem. I’m observing poor scalability when increasing the number of cores. I tried to use a direct solver (solving approx. 1M nDOF) as well an iter…

---

## [Linear solver difference in demo-stokes](https://fenicsproject.discourse.group/t/linear-solver-difference-in-demo-stokes/17702)

<div class="topic-metadata">

**Author:** [@tweng](https://fenicsproject.discourse.group/u/tweng)\
**Replies:** 4\
**Last updated:** [June 4, 2025, 7:14pm UTC](https://fenicsproject.discourse.group/t/linear-solver-difference-in-demo-stokes/17702 "2025-06-04T19:14:03Z")

</div>

Hello FEniCS community, I’m still quite new to FEniCS, and this post is more about conceptual questions. Upon adapting and reproducing the demo code (Stokes equations using Taylor-Hood elements — DOLFINx 0.10.0.0 docume…

---

## [Solving a PDE with unknown parameters (eigenvalues)](https://fenicsproject.discourse.group/t/solving-a-pde-with-unknown-parameters-eigenvalues/17650)

<div class="topic-metadata">

**Author:** [@mariom121](https://fenicsproject.discourse.group/u/mariom121)\
**Replies:** 0\
**Last updated:** [May 22, 2025, 3:48pm UTC](https://fenicsproject.discourse.group/t/solving-a-pde-with-unknown-parameters-eigenvalues/17650 "2025-05-22T15:48:25Z")

</div>

Dear Fenics users, I am trying to obtain the spectrum of eigenvalues ω for Regge-Wheeler’s equation (Wikipedia: Regge, Wheeler and Zerilli equations) with Neumann boundary conditions: where but the task is provin…

---

## [Troubles setting up PETSc options with dolfinx 0.9.0](https://fenicsproject.discourse.group/t/troubles-setting-up-petsc-options-with-dolfinx-0-9-0/17506)

<div class="topic-metadata">

**Author:** [@TheauC](https://fenicsproject.discourse.group/u/TheauC)\
**Replies:** 0\
**Last updated:** [April 25, 2025, 1:38pm UTC](https://fenicsproject.discourse.group/t/troubles-setting-up-petsc-options-with-dolfinx-0-9-0/17506 "2025-04-25T13:38:25Z")

</div>

Hi all, I’m having trouble migrating a DolfinX v0.6.0 code to DolfinX v0.9.0 (nonlinear NS solver with Schur complement as preconditioning). This MWE runs under fenics-dolfinx 0.6.0 with petsc4py/petsc 3.19.6 (the cond…

---

## [Module petsc4py not found on Anaconda](https://fenicsproject.discourse.group/t/module-petsc4py-not-found-on-anaconda/17315)

<div class="topic-metadata">

**Author:** [@Inuwashi](https://fenicsproject.discourse.group/u/Inuwashi)\
**Replies:** 1\
**Last updated:** [March 26, 2025, 4:08pm UTC](https://fenicsproject.discourse.group/t/module-petsc4py-not-found-on-anaconda/17315 "2025-03-26T16:08:56Z")

</div>

Hello, I’m posting here because I’m having an issue with the petsc4py module. I’m trying to solve the heat equation, and to create the variational form, I need to use dolfinx.fem.petsc.LinearProblem. However, the petsc …

---

## [Create a complex petsc matrix from a dolfinx.cpp.fem.Form\_float64](https://fenicsproject.discourse.group/t/create-a-complex-petsc-matrix-from-a-dolfinx-cpp-fem-form-float64/17081)

<div class="topic-metadata">

**Author:** [@jsagg931](https://fenicsproject.discourse.group/u/jsagg931)\
**Replies:** 1\
**Last updated:** [February 25, 2025, 8:08pm UTC](https://fenicsproject.discourse.group/t/create-a-complex-petsc-matrix-from-a-dolfinx-cpp-fem-form-float64/17081 "2025-02-25T20:08:02Z")

</div>

Dear community, I am using a complex build of PETSc and I would like to compute the complex PETSc matrix associated to a real bilinear form of type dolfinx.cpp.fem.Form\_float64. The reason behind this it is because the…

---

## [AttributeError when using dolfinx.fem.petsc.LinearProblem](https://fenicsproject.discourse.group/t/attributeerror-when-using-dolfinx-fem-petsc-linearproblem/16769)

<div class="topic-metadata">

**Author:** [@danixala5](https://fenicsproject.discourse.group/u/danixala5)\
**Replies:** 1\
**Last updated:** [January 16, 2025, 3:29pm UTC](https://fenicsproject.discourse.group/t/attributeerror-when-using-dolfinx-fem-petsc-linearproblem/16769 "2025-01-16T15:29:17Z")

</div>

Hi! I am new to FEniCSx and before jumping into my more complex real problem, I was using a toy model when I run into an error using one of the solvers. I am using the version fenics-dolfinx 0.9.0 and fenics-ufl 2024.2.0…

---

## [Gmres residual explodes after 1 iter (transport problem, anisotropic mesh)](https://fenicsproject.discourse.group/t/gmres-residual-explodes-after-1-iter-transport-problem-anisotropic-mesh/16737)

<div class="topic-metadata">

**Author:** [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Replies:** 1\
**Last updated:** [January 14, 2025, 5:08pm UTC](https://fenicsproject.discourse.group/t/gmres-residual-explodes-after-1-iter-transport-problem-anisotropic-mesh/16737 "2025-01-14T17:08:21Z")

</div>

I came across a FEM matrix, that causes GMRES to produce a residual of 10^{58} after a single iteration, after which it terminates. The matrix arises when discretising the transport/wave-like problem \\begin{cases} \\di…

---

## [Segmentation violation while assembling matrices](https://fenicsproject.discourse.group/t/segmentation-violation-while-assembling-matrices/16346)

<div class="topic-metadata">

**Author:** [@davidbhatt](https://fenicsproject.discourse.group/u/davidbhatt)\
**Replies:** 6\
**Last updated:** [December 9, 2024, 8:26pm UTC](https://fenicsproject.discourse.group/t/segmentation-violation-while-assembling-matrices/16346 "2024-12-09T20:26:53Z")

</div>

Hello Everyone, I am trying to solve eigenvalue problem J u=Lambda\*u where J is Jacobian of nonlinear convective diffusive reactive equations. My code is as follows: import basix.ufl import dolfinx.fem import dolfinx…

---

## [Getting error in Newton solver by adding elasticity terms in Cahn hilliard equation](https://fenicsproject.discourse.group/t/getting-error-in-newton-solver-by-adding-elasticity-terms-in-cahn-hilliard-equation/16104)

<div class="topic-metadata">

**Author:** [@ishank\_2210](https://fenicsproject.discourse.group/u/ishank_2210)\
**Replies:** 9\
**Last updated:** [October 25, 2024, 1:34pm UTC](https://fenicsproject.discourse.group/t/getting-error-in-newton-solver-by-adding-elasticity-terms-in-cahn-hilliard-equation/16104 "2024-10-25T13:34:48Z")

</div>

Hello all, I am trying to incorporate elasticity terms in the chemical potential equation. I have added term3 and term4 in code provided below in the Cahn Hilliard expression. If I remove term3 and term4, solver is worki…

---

## [Use local installation of MPI/PETSc?](https://fenicsproject.discourse.group/t/use-local-installation-of-mpi-petsc/15937)

<div class="topic-metadata">

**Author:** [@fesolutions](https://fenicsproject.discourse.group/u/fesolutions)\
**Replies:** 2\
**Last updated:** [September 30, 2024, 5:58pm UTC](https://fenicsproject.discourse.group/t/use-local-installation-of-mpi-petsc/15937 "2024-09-30T17:58:58Z")

</div>

I have a sneaking suspicion that the conda-forge versions of mpi/petsc are not as fast as my locally installed OpenMPI and PETSc version. I have some evidence of this, as I used the osu\_bw.py bandwidth test (see MVAPICH …

---

## [Build 64bit petsc and dolfinx v0.8.0](https://fenicsproject.discourse.group/t/build-64bit-petsc-and-dolfinx-v0-8-0/15794)

<div class="topic-metadata">

**Author:** [@zsmb](https://fenicsproject.discourse.group/u/zsmb)\
**Replies:** 2\
**Last updated:** [September 13, 2024, 2:25pm UTC](https://fenicsproject.discourse.group/t/build-64bit-petsc-and-dolfinx-v0-8-0/15794 "2024-09-13T14:25:15Z")

</div>

I’m tring to build dolfinx v0.8.0 with 64bit petsc inside docker, but facing some problems. I follow this post (64-bit integer PETSc build in Dolfin-x - #6 by dokken) and modified some commands. docker run -ti dolfinx/…

---

## [Conversion from MatrixCSR to PETSc matrix](https://fenicsproject.discourse.group/t/conversion-from-matrixcsr-to-petsc-matrix/15729)

<div class="topic-metadata">

**Author:** [@astronot21](https://fenicsproject.discourse.group/u/astronot21)\
**Replies:** 3\
**Last updated:** [September 12, 2024, 5:45pm UTC](https://fenicsproject.discourse.group/t/conversion-from-matrixcsr-to-petsc-matrix/15729 "2024-09-12T17:45:57Z")

</div>

I am trying to write a Python script to solve a particular heat equation. The issue at the moment seems to be that the PETSc solver seems to require a PETSc matrix, whereas the fem.assemble\_matrix function produces a Mat…

---

## [Save and load the LU factorization results of a PETSc KSP direct solver](https://fenicsproject.discourse.group/t/save-and-load-the-lu-factorization-results-of-a-petsc-ksp-direct-solver/15675)

<div class="topic-metadata">

**Author:** [@Libinatos](https://fenicsproject.discourse.group/u/Libinatos)\
**Replies:** 1\
**Last updated:** [August 29, 2024, 5:23pm UTC](https://fenicsproject.discourse.group/t/save-and-load-the-lu-factorization-results-of-a-petsc-ksp-direct-solver/15675 "2024-08-29T17:23:18Z")

</div>

Hello everyone, I’m wondering if there is any way to save the LU factorization results of a PETSc KSP direct solver (i.e., only using the LU preconditioner) and load it somewhere else to create a direct solver to avoid …

---

## [A PETSc TS module question](https://fenicsproject.discourse.group/t/a-petsc-ts-module-question/15235)

<div class="topic-metadata">

**Author:** [@Smith\_Jack](https://fenicsproject.discourse.group/u/Smith_Jack)\
**Replies:** 1\
**Last updated:** [July 12, 2024, 7:27am UTC](https://fenicsproject.discourse.group/t/a-petsc-ts-module-question/15235 "2024-07-12T07:27:56Z")

</div>

I know this question is not related to fenics, but I really have NO way to get any help :sweat\_smile: … I tried to convert a C code of PETsc to python version, but the python code cannot converge. I have checked many ti…

---

## [Solving 3D Stokes problem is slower on dolfinx than dolfin](https://fenicsproject.discourse.group/t/solving-3d-stokes-problem-is-slower-on-dolfinx-than-dolfin/15154)

<div class="topic-metadata">

**Author:** [@Lingyue\_Shen](https://fenicsproject.discourse.group/u/Lingyue_Shen)\
**Replies:** 6\
**Last updated:** [July 8, 2024, 3:25am UTC](https://fenicsproject.discourse.group/t/solving-3d-stokes-problem-is-slower-on-dolfinx-than-dolfin/15154 "2024-07-08T03:25:42Z")

</div>

Hi, I am trying to solve a 3D stokes problem using P1-P1 mixed element with a pressure stabilisation. Mumps direct solver is used. Here is the demo of the code: import os os.environ\['OMP\_NUM\_THREADS'\] = '1' from mpi4py…

---

## [Fem.petsc not found in complex-mode](https://fenicsproject.discourse.group/t/fem-petsc-not-found-in-complex-mode/13869)

<div class="topic-metadata">

**Author:** [@Jesus\_Vellojin](https://fenicsproject.discourse.group/u/Jesus_Vellojin)\
**Replies:** 5\
**Last updated:** [June 15, 2024, 4:15pm UTC](https://fenicsproject.discourse.group/t/fem-petsc-not-found-in-complex-mode/13869 "2024-06-15T16:15:23Z")

</div>

Dear FEniCS community. I’m facing an AttributeError error when trying to run a code with complex-mode in Dolfinx v0.7.3 Docker image. The code below import dolfinx import ufl import basix from mpi4py import MPI msh =…

---

## [How to get PETSc in complex mode](https://fenicsproject.discourse.group/t/how-to-get-petsc-in-complex-mode/14271)

<div class="topic-metadata">

**Author:** [@Maki](https://fenicsproject.discourse.group/u/Maki)\
**Replies:** 2\
**Last updated:** [April 16, 2024, 2:22pm UTC](https://fenicsproject.discourse.group/t/how-to-get-petsc-in-complex-mode/14271 "2024-04-16T14:22:28Z")

</div>

Greetings everyone, I am fairly new to FenicsX and I am trying to solve the Helmholtz equation using PETSc.LinearProblem, therefore I need to switch PETSC to complex mode. Sorry if this post is redundant but I cannot f…

---

## [Doldinx / Petsc using more cores than allocated via "mpirun -n XX"](https://fenicsproject.discourse.group/t/doldinx-petsc-using-more-cores-than-allocated-via-mpirun-n-xx/13931)

<div class="topic-metadata">

**Author:** [@fluid](https://fenicsproject.discourse.group/u/fluid)\
**Replies:** 3\
**Last updated:** [March 16, 2024, 1:18pm UTC](https://fenicsproject.discourse.group/t/doldinx-petsc-using-more-cores-than-allocated-via-mpirun-n-xx/13931 "2024-03-16T13:18:44Z")

</div>

I have installed dolfinx via conda and run it from terminal doing: mpirun -n 20 python3 filename.py Inside the script, I set: import os os.environ\['MKL\_NUM\_THREADS'\] = '1' os.environ\['NUMEXPR\_NUM\_THREADS'\] = '1' os…

---

## [Parallel computation TAO solver](https://fenicsproject.discourse.group/t/parallel-computation-tao-solver/12768)

<div class="topic-metadata">

**Author:** [@federicosold](https://fenicsproject.discourse.group/u/federicosold)\
**Replies:** 4\
**Last updated:** [January 22, 2024, 11:23am UTC](https://fenicsproject.discourse.group/t/parallel-computation-tao-solver/12768 "2024-01-22T11:23:09Z")

</div>

Hello, I have developed some code that uses PETSc TAO optimization solver with box constraints. When I run the code on a single processor, the code works as expected. When I run on more than one processor, the code it…
