# Linear Algebra

**URL:** https://fenicsproject.discourse.group/c/linear-algebra/9.md

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

---

## [About the Linear Algebra category](https://fenicsproject.discourse.group/t/about-the-linear-algebra-category/31)

<div class="topic-metadata">

**Author:** [@chris](https://fenicsproject.discourse.group/u/chris)\
**Replies:** 0

</div>

All questions and discussions about solving matrix problems Assembling forms into matrices Block systems Preconditioning Direct and Iterative Solvers

---

## [Does parallelization help mumps?](https://fenicsproject.discourse.group/t/does-parallelization-help-mumps/19328)

<div class="topic-metadata">

**Author:** [@Matheus-Janczkowski](https://fenicsproject.discourse.group/u/Matheus-Janczkowski)\
**Replies:** 3\
**Last updated:** [January 13, 2026, 4:42pm UTC](https://fenicsproject.discourse.group/t/does-parallelization-help-mumps/19328 "2026-01-13T16:42:01Z")

</div>

I’m working with hyperelasticity in dolfin. Is there any benefit in using parallelization tools commonly used in fenics examples if I use mumps as linear solver? Is not mumps supposed to be already parallel?

---

## [Difference between a Newton solver and a linear solver for a linear problem.](https://fenicsproject.discourse.group/t/difference-between-a-newton-solver-and-a-linear-solver-for-a-linear-problem/19343)

<div class="topic-metadata">

**Author:** [@ctain](https://fenicsproject.discourse.group/u/ctain)\
**Replies:** 1\
**Last updated:** [January 12, 2026, 6:32pm UTC](https://fenicsproject.discourse.group/t/difference-between-a-newton-solver-and-a-linear-solver-for-a-linear-problem/19343 "2026-01-12T18:32:02Z")

</div>

Hi, My question is: is there a difference between a linear problem solved with LinearProblem() and the same linear problem solved with NonlinearProblem()? If I pass petsc\_options = {"ksp\_type": "preonly", …

---

## [Scaling of condition number in 1D, 2D, and 3D](https://fenicsproject.discourse.group/t/scaling-of-condition-number-in-1d-2d-and-3d/18462)

<div class="topic-metadata">

**Author:** [@Haydel\_Collins](https://fenicsproject.discourse.group/u/Haydel_Collins)\
**Replies:** 6\
**Last updated:** [December 15, 2025, 8:56pm UTC](https://fenicsproject.discourse.group/t/scaling-of-condition-number-in-1d-2d-and-3d/18462 "2025-12-15T20:56:26Z")

</div>

My understanding is that the condition number (for stiffness matrix of poisson) should scale like h^-2. Here is a MWE, more or less from the demos, where I run this for a few levels of refinement using nx = \[10,20,40,80…

---

## [Solving a rank-deficient curl curl matrix](https://fenicsproject.discourse.group/t/solving-a-rank-deficient-curl-curl-matrix/18423)

<div class="topic-metadata">

**Author:** [@young](https://fenicsproject.discourse.group/u/young)\
**Replies:** 7\
**Last updated:** [November 30, 2025, 11:26pm UTC](https://fenicsproject.discourse.group/t/solving-a-rank-deficient-curl-curl-matrix/18423 "2025-11-30T23:26:30Z")

</div>

Hello everyone I am trying to solve the curl curl equation for a given current density j\_expr with homogeneous essential boundary bonditions. My formulation is that adopting Lagrange multipliers grad(p) for p in CG(1) f…

---

## [Inserting several vectors into assembled global matrix equation](https://fenicsproject.discourse.group/t/inserting-several-vectors-into-assembled-global-matrix-equation/18275)

<div class="topic-metadata">

**Author:** [@BillS](https://fenicsproject.discourse.group/u/BillS)\
**Replies:** 8\
**Last updated:** [November 28, 2025, 11:48am UTC](https://fenicsproject.discourse.group/t/inserting-several-vectors-into-assembled-global-matrix-equation/18275 "2025-11-28T11:48:15Z")

</div>

I am not having a lot of luck with the Sherman Morrison approach, so I decided to take a look at an alternative approach. I would like to construct a block matrix equation of the following form \\left\\lbrack\\begin{array…

---

## [Using Sherman Morrison formula for generating rank-1 boundary operator with Fenicsx and PETSc](https://fenicsproject.discourse.group/t/using-sherman-morrison-formula-for-generating-rank-1-boundary-operator-with-fenicsx-and-petsc/18267)

<div class="topic-metadata">

**Author:** [@BillS](https://fenicsproject.discourse.group/u/BillS)\
**Replies:** 1\
**Last updated:** [October 16, 2025, 1:10pm UTC](https://fenicsproject.discourse.group/t/using-sherman-morrison-formula-for-generating-rank-1-boundary-operator-with-fenicsx-and-petsc/18267 "2025-10-16T13:10:51Z")

</div>

Good day all, I finally have got around to looking at modeling a generalized waveguide port boundary condition. Starting with the simplest case of a single mode, I am trying to implement the scattered port wave operato…

---

## [Generate an inner product between RHS vector and solution vector in Dolfinx 0.9.0](https://fenicsproject.discourse.group/t/generate-an-inner-product-between-rhs-vector-and-solution-vector-in-dolfinx-0-9-0/18250)

<div class="topic-metadata">

**Author:** [@BillS](https://fenicsproject.discourse.group/u/BillS)\
**Replies:** 4\
**Last updated:** [October 6, 2025, 4:15pm UTC](https://fenicsproject.discourse.group/t/generate-an-inner-product-between-rhs-vector-and-solution-vector-in-dolfinx-0-9-0/18250 "2025-10-06T16:15:29Z")

</div>

Hello all, A question about doing an inner product on RHS and solution vectors: How do I do this, taking into account the scattering of vector components across processes? Code is below. Pertinent code block is at the …

---

## [Memory management with petsc4py](https://fenicsproject.discourse.group/t/memory-management-with-petsc4py/18199)

<div class="topic-metadata">

**Author:** [@plugged](https://fenicsproject.discourse.group/u/plugged)\
**Replies:** 2\
**Last updated:** [September 10, 2025, 9:05am UTC](https://fenicsproject.discourse.group/t/memory-management-with-petsc4py/18199 "2025-09-10T09:05:11Z")

</div>

Hi everyone, I am having a problem with freeing up memory in legacy fenics. As discussed here, with newer versions of petsc4py one should call the destroy method of the objects in order to free up memory ( garbage colle…

---

## [Obtaining nested Jacobian matrix from nonlinear residual and fieldsplit preconditioning](https://fenicsproject.discourse.group/t/obtaining-nested-jacobian-matrix-from-nonlinear-residual-and-fieldsplit-preconditioning/18092)

<div class="topic-metadata">

**Author:** [@JLorenteMacias](https://fenicsproject.discourse.group/u/JLorenteMacias)\
**Replies:** 12\
**Last updated:** [August 14, 2025, 12:32pm UTC](https://fenicsproject.discourse.group/t/obtaining-nested-jacobian-matrix-from-nonlinear-residual-and-fieldsplit-preconditioning/18092 "2025-08-14T12:32:11Z")

</div>

Hi all, I have a nonlinear multiphysics problem and my goal is to build a good preconditioner to solve the problem efficiently. I have some ideas on how to do it, but I struggle a bit with the implementation. I’m going…

---

## [Interpolation matrix with non matching meshes](https://fenicsproject.discourse.group/t/interpolation-matrix-with-non-matching-meshes/12204)

<div class="topic-metadata">

**Author:** [@bay\_swiss](https://fenicsproject.discourse.group/u/bay_swiss)\
**Replies:** 24\
**Last updated:** [April 17, 2025, 1:22am UTC](https://fenicsproject.discourse.group/t/interpolation-matrix-with-non-matching-meshes/12204 "2025-04-17T01:22:19Z")

</div>

Hello guys! Since it is possible to interpolate one function defined on a function space into another one defined on another function space (from a non matching mesh), like so: V\_1 = dolfinx.fem.FunctionSpace(msh\_1, ("…

---

## [Matrix free petsc solver with multigrid (MG or GAMG) preconditioner](https://fenicsproject.discourse.group/t/matrix-free-petsc-solver-with-multigrid-mg-or-gamg-preconditioner/13569)

<div class="topic-metadata">

**Author:** [@mbookwala](https://fenicsproject.discourse.group/u/mbookwala)\
**Replies:** 1\
**Last updated:** [February 25, 2025, 10:32am UTC](https://fenicsproject.discourse.group/t/matrix-free-petsc-solver-with-multigrid-mg-or-gamg-preconditioner/13569 "2025-02-25T10:32:09Z")

</div>

Hi. I want to use petsc MG or GAMG preconditioner in conjunction with matrix free approach given here. So in line 346, I want solver.getPC().setType(PETSc.PC.Type.GAMG) instead of solver.getPC().setType(PETSc.PC.Typ…

---

## [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…

---

## [ufl\_legacy.log.UFLException: determinant\_expr not implemented for shape (4, 4)](https://fenicsproject.discourse.group/t/ufl-legacy-log-uflexception-determinant-expr-not-implemented-for-shape-4-4/16302)

<div class="topic-metadata">

**Author:** [@Deep\_Math](https://fenicsproject.discourse.group/u/Deep_Math)\
**Replies:** 3\
**Last updated:** [November 15, 2024, 6:34am UTC](https://fenicsproject.discourse.group/t/ufl-legacy-log-uflexception-determinant-expr-not-implemented-for-shape-4-4/16302 "2024-11-15T06:34:57Z")

</div>

I want to assemble the matrices of my weak form, I’m doing compressible flow and plastic fluid structure interaction, the variables are (p,u,T), which have 4 variables, then I write a function to assemble the weak form …

---

## [Invert matrix only once for time-dep problems](https://fenicsproject.discourse.group/t/invert-matrix-only-once-for-time-dep-problems/16108)

<div class="topic-metadata">

**Author:** [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Replies:** 4\
**Last updated:** [October 24, 2024, 5:43pm UTC](https://fenicsproject.discourse.group/t/invert-matrix-only-once-for-time-dep-problems/16108 "2024-10-24T17:43:01Z")

</div>

Dear community, in the tutorial Diffusion of a Gaussian function the sentence We observe that the left hand side of the system, the matrix does not change from one time step to another, thus we only need to assemble i…

---

## [How to create a Matrix (dolfin.cpp.la.Matrix) from Vectors (dolfin.cpp.la.Vector)?](https://fenicsproject.discourse.group/t/how-to-create-a-matrix-dolfin-cpp-la-matrix-from-vectors-dolfin-cpp-la-vector/2434)

<div class="topic-metadata">

**Author:** [@e56283](https://fenicsproject.discourse.group/u/e56283)\
**Replies:** 6\
**Last updated:** [September 24, 2024, 1:09pm UTC](https://fenicsproject.discourse.group/t/how-to-create-a-matrix-dolfin-cpp-la-matrix-from-vectors-dolfin-cpp-la-vector/2434 "2024-09-24T13:09:39Z")

</div>

Hi all: I have several vectors (\<dolfin.cpp.la.Vector at…) and I need to create a matrix\<dolfin.cpp.la.Matrix at…) from them like this (every column of the matrix will be a vector): A = \[vector1, vector2, vector3, …\] I…

---

## [Elementwise multiplication in variational form / Hadamard product](https://fenicsproject.discourse.group/t/elementwise-multiplication-in-variational-form-hadamard-product/15754)

<div class="topic-metadata">

**Author:** [@jt509](https://fenicsproject.discourse.group/u/jt509)\
**Replies:** 1\
**Last updated:** [September 9, 2024, 7:36pm UTC](https://fenicsproject.discourse.group/t/elementwise-multiplication-in-variational-form-hadamard-product/15754 "2024-09-09T19:36:25Z")

</div>

Hi community I want to perform the operation A .\* v, for example \\begin{bmatrix} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\\\ 7 & 8 & 9 \\end{bmatrix} .\* \\begin{bmatrix} 1 \\\\ 0 \\\\ 1 \\end{bmatrix} = \\begin{bmatrix} 1 & 0 & 3 \\\\ 4 & 0 & 6…

---

## [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 …

---

## [Linear solver change](https://fenicsproject.discourse.group/t/linear-solver-change/15572)

<div class="topic-metadata">

**Author:** [@nickaaa](https://fenicsproject.discourse.group/u/nickaaa)\
**Replies:** 1\
**Last updated:** [August 18, 2024, 5:42pm UTC](https://fenicsproject.discourse.group/t/linear-solver-change/15572 "2024-08-18T17:42:40Z")

</div>

Hello everybody! Now I have a code for a heat solver. However, I don’t want to use LU method as my linear solver, since my coefficient matrix is time-dependent. I want to use a more efficient way to solve the linear pro…

---

## [Effective elasticity tensor](https://fenicsproject.discourse.group/t/effective-elasticity-tensor/15167)

<div class="topic-metadata">

**Author:** [@tuderic](https://fenicsproject.discourse.group/u/tuderic)\
**Replies:** 2\
**Last updated:** [July 8, 2024, 4:21pm UTC](https://fenicsproject.discourse.group/t/effective-elasticity-tensor/15167 "2024-07-08T16:21:59Z")

</div>

Hi Community, I have a question about the numerical homogenization of the effective stiffness tensor. This is done in this excellent example of legacy fenics. I apply this procedure in 3D. As a result, I get an unsymme…

---

## [Using petsc4py.PETSc.SNES directly](https://fenicsproject.discourse.group/t/using-petsc4py-petsc-snes-directly/2368)

<div class="topic-metadata">

**Author:** [@niewiarowski](https://fenicsproject.discourse.group/u/niewiarowski)\
**Replies:** 23\
**Last updated:** [June 13, 2024, 7:22pm UTC](https://fenicsproject.discourse.group/t/using-petsc4py-petsc-snes-directly/2368 "2024-06-13T19:22:57Z")

</div>

Hi, I would like to interface with the petsc4py.PETSc.SNES object directly to access some specific PETSc functions, but I cannot find any documentation on how to use to the SNES object in FEniCS e.g. how to convert the …

---

## [PETsc error code is : 63](https://fenicsproject.discourse.group/t/petsc-error-code-is-63/14780)

<div class="topic-metadata">

**Author:** [@Kumar\_Pushpak](https://fenicsproject.discourse.group/u/Kumar_Pushpak)\
**Replies:** 5\
**Last updated:** [May 28, 2024, 5:02am UTC](https://fenicsproject.discourse.group/t/petsc-error-code-is-63/14780 "2024-05-28T05:02:02Z")

</div>

I am trying to solve three pde’s with mixedElement. I suspect i did somethin wrong in applying boundary condition but i am new to Fenics so would really appreciate any kind of help. from dolfin import \* from mshr import…

---

## [Handling Time Terms in Implicit Difference Method](https://fenicsproject.discourse.group/t/handling-time-terms-in-implicit-difference-method/14737)

<div class="topic-metadata">

**Author:** [@nikoleeaa](https://fenicsproject.discourse.group/u/nikoleeaa)\
**Replies:** 0\
**Last updated:** [May 20, 2024, 1:38pm UTC](https://fenicsproject.discourse.group/t/handling-time-terms-in-implicit-difference-method/14737 "2024-05-20T13:38:20Z")

</div>

Hello! I am encountering some issues related to very small time steps in my numerical simulations and would appreciate your assistance. In my model, the time step dt is extremely small, approximately on the order of 10…

---

## [AttributeError: 'petsc4py.PETSc.KSP' object has no attribute 'matSolve'](https://fenicsproject.discourse.group/t/attributeerror-petsc4py-petsc-ksp-object-has-no-attribute-matsolve/14461)

<div class="topic-metadata">

**Author:** [@lyunfei1211](https://fenicsproject.discourse.group/u/lyunfei1211)\
**Replies:** 7\
**Last updated:** [April 30, 2024, 8:41am UTC](https://fenicsproject.discourse.group/t/attributeerror-petsc4py-petsc-ksp-object-has-no-attribute-matsolve/14461 "2024-04-30T08:41:10Z")

</div>

I use petsc4py (installed by Ubuntu, petsc4py V3.15.1) solve the linear system with multiple right-hand sides. And I look up the petsc4py user manual and find the method ‘petsc4py.PETSc.KSP.matSolve()’. But when I run my…

---

## [Copy a numpy matrix into a fencis function](https://fenicsproject.discourse.group/t/copy-a-numpy-matrix-into-a-fencis-function/14410)

<div class="topic-metadata">

**Author:** [@LuciaPL](https://fenicsproject.discourse.group/u/LuciaPL)\
**Replies:** 1\
**Last updated:** [April 24, 2024, 12:10pm UTC](https://fenicsproject.discourse.group/t/copy-a-numpy-matrix-into-a-fencis-function/14410 "2024-04-24T12:10:19Z")

</div>

Hi, I am kind of new in FEniCS and I am having some problems when solving a problem. I have matrix (which I have turned into a vector so that the problem is easier) which I calculate as the following: for cont in range…

---

## [How to define uniform load on edge in 3D](https://fenicsproject.discourse.group/t/how-to-define-uniform-load-on-edge-in-3d/4564)

<div class="topic-metadata">

**Author:** [@Mh.X](https://fenicsproject.discourse.group/u/Mh.X)\
**Replies:** 5\
**Last updated:** [April 20, 2024, 6:46am UTC](https://fenicsproject.discourse.group/t/how-to-define-uniform-load-on-edge-in-3d/4564 "2024-04-20T06:46:54Z")

</div>

hello, let’s consider a 3D problem, such as elasticity problem of a 3D beam. My question is how to apply load on an edge (line). I can use MeshValueFuntion and measure ds to apply loads on a surface. And in 2D problem, …

---

## [Creating a PETSc Matrix from given Matrix, solve eigenvalue problem (petsc4py?)](https://fenicsproject.discourse.group/t/creating-a-petsc-matrix-from-given-matrix-solve-eigenvalue-problem-petsc4py/1649)

<div class="topic-metadata">

**Author:** [@Yannik](https://fenicsproject.discourse.group/u/Yannik)\
**Replies:** 4\
**Last updated:** [April 16, 2024, 10:21pm UTC](https://fenicsproject.discourse.group/t/creating-a-petsc-matrix-from-given-matrix-solve-eigenvalue-problem-petsc4py/1649 "2024-04-16T22:21:09Z")

</div>

Hi everyone, I’m using macOS Mojave (10.14.6), miniconda, and FEniCS 2018 with Python. I have a Matrix (to be more precise the stiffness and the mass matrix) as a Numpy array and now I want to plug it into a PETSc matr…

---

## [AMG for elasticity problems leaks with PETSc AMG smoothers](https://fenicsproject.discourse.group/t/amg-for-elasticity-problems-leaks-with-petsc-amg-smoothers/13936)

<div class="topic-metadata">

**Author:** [@marchirschvogel](https://fenicsproject.discourse.group/u/marchirschvogel)\
**Replies:** 3\
**Last updated:** [April 12, 2024, 1:32pm UTC](https://fenicsproject.discourse.group/t/amg-for-elasticity-problems-leaks-with-petsc-amg-smoothers/13936 "2024-04-12T13:32:16Z")

</div>

Dear community, I want to solve a nonlinear problem using GMRES preconditioned with BoomerAMG. My setup experiences a strong memory leak when using a smoother, e.g. ParaSails. I am not sure whether this is related to th…

---

## [SLEPc gives indefinite matrix error](https://fenicsproject.discourse.group/t/slepc-gives-indefinite-matrix-error/14137)

<div class="topic-metadata">

**Author:** [@jedi](https://fenicsproject.discourse.group/u/jedi)\
**Replies:** 0\
**Last updated:** [April 5, 2024, 9:03pm UTC](https://fenicsproject.discourse.group/t/slepc-gives-indefinite-matrix-error/14137 "2024-04-05T21:03:31Z")

</div>

Hello again After some much apprciated assistance on this discussion, I have managed to get a Microstrip line eigenvalue solver. Ignoring all the hard stuff ahead of me (calculating H-fields, impedances, etc.), I rushe…

---

## [Compute Null Space of Assembled PETSc Matrix?](https://fenicsproject.discourse.group/t/compute-null-space-of-assembled-petsc-matrix/11385)

<div class="topic-metadata">

**Author:** [@jkrokowski](https://fenicsproject.discourse.group/u/jkrokowski)\
**Replies:** 1\
**Last updated:** [February 21, 2024, 8:50am UTC](https://fenicsproject.discourse.group/t/compute-null-space-of-assembled-petsc-matrix/11385 "2024-02-21T08:50:33Z")

</div>

I have rank-deficient PETSc Matrix that is assembled from a variational problem. I would like to extract the basis of the null space of this matrix. A dense SVD computation works well up to a certain problem size. Howeve…

[Next page](https://fenicsproject.discourse.group/c/linear-algebra/9.md?page=1)
