# schurPreconditioner & schurList

**URL:** <https://community.freefem.org/t/schurpreconditioner-schurlist/4162>\
**Category:** General Discussion\
**Created:** [December 23, 2025, 12:26am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162 "2025-12-23T00:26:35Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [December 23, 2025, 12:26am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/1 "2025-12-23T00:26:35Z")

</div>

It seems very hard to get the the parameters **schurPreconditioner** and **schurList** correct for a PETSc block preconditioner. For a block matrix like:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f924b17a6f397daa6d2328401a4f1b6af69e5aeb.png)

Is the following syntax correct for prameters **schurPreconditioner** and **schurList**?

```auto
func Pk=[P2,P2,P2];

fespace Sh(ThS, Pk);
fespace Vh(Th, Pk);

fespace Ph(Th, P1);

```

```auto
real[int] list(tndof);

list(0 : u2dof-1) = 0;
list(u2dof : u2dof+pndof - 1) = 1:pndof;
list(u2dof+pndof:u2dof+p2dof-1) = pndof+1:p2dof;
list(u2dof+p2dof:u2dof+p2dof+andof-1) = p2dof+1:p2dof+andof;
list(u2dof+p2dof+andof:tndof-1) = p2dof+andof+1 : p2dof+a2dof;

matrix[int] S(4);

varf vSchur(p, q) = int3(p * q);
S[0] = vSchur(Ph, Ph);
S[1] =S[0];

varf aSchur([ax,ay,az],[ahx,ahy,ahz]) = int2d(ThS)( vect(ah)'vect(a) );
S[2] = aSchur(Sh,Sh);
S[3] = S[2];

set(M, sparams = …
fields = usPETSc, names = names, schurPreconditioner = S, schurList = list);

```

Thanks a lot for your help in advance!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 23, 2025, 4:14am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/2 "2025-12-23T04:14:06Z")

</div>

The best way to know for sure is to just try the code.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [December 23, 2025, 12:41pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/3 "2025-12-23T12:41:46Z")

</div>

There is an error unfortunately:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/2/27b1bf0233aab7af30f8b54eb8d0151b736fb49b.png)

First, I tested an simpler case by filling the diagonal with mass matrices:

```auto
Mat M=

[[UU, 0, UP’, 0, UA’, 0],
 [UU, UU, 0, UP’, 0, UA’],
 [UP, 0, PP, 0, 0, 0],
 [0, UP, 0, PP, 0, 0],
 [UA, 0, 0, 0, AA, 0],
 [0, UA, 0, 0, 0, AA]];

```

and set the params like:  
`set(M, sparams = "-ksp_monitor -ksp_type fgmres -ksp_converged_reason -ksp_initial_guess_nonzero true -ksp_rtol 1.e-5 -ksp_max_it 100 "`  
`+ "-pc_type fieldsplit -pc_fieldsplit_type multiplicative "`  
`+ "-fieldsplit_u_pc_type gamg "`  
`+ "-fieldsplit_v_pc_type gamg "`  
`+ "-fieldsplit_p_pc_type gamg "`  
`+ "-fieldsplit_q_pc_type gamg "`  
`+ "-fieldsplit_a_pc_type gamg "`  
`+ “-fieldsplit_b_pc_type gamg”,`  
`fields = usPETSc, names = names);`

There is no error although the solver didn’t converge.

However, when I add

`, schurPreconditioner = S, schurList = list)`

the above error appears. So, it seems that my `S and list` are not correct?

I am not sure the format of `schurPreconditioner `and `schurList`. The only reference I can find is the following paper. But the block matrix in this paper is much simpler, it has three blocks, and S[0] is the Schur preconditioner. Regarding parameter `schurList, `say my Schur is a 1000x1000 matrix, should I create a `schurList `from 1 to 1000?

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f93bb3285ac65e91b3f04f75ff2ae1b0d0d81b8e.png)

By the way, chatGTP suggested the following, but the same error occurs.

```auto
real[int] schurList(tndof);

// u, v → not Schur
schurList(0 : u2dof-1) = 0;

// p, q → Schur block 1
schurList(u2dof : u2dof+p2dof-1) = 1;

// a, b → Schur block 2
schurList(u2dof+p2dof : tndof-1) = 2;

```

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 23, 2025, 1:19pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/4 "2025-12-23T13:19:30Z")

</div>

Please share a minimal code to reproduce the issue.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [December 23, 2025, 1:46pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/5 "2025-12-23T13:46:03Z")

</div>

[stokes\_adjoint\_six\_fields.edp](https://community.freefem.org/uploads/short-url/6F8pIcsdhH9dTnDwoomqRWcvQEF.edp) (7.1 KB)

[bc1.log](https://community.freefem.org/uploads/short-url/kIJewu3MCG9i6FgcXgwlFlAQLEz.log) (2.3 MB)

[fluid1.mesh](https://community.freefem.org/uploads/short-url/4q8VJIe53OzfVjWOUfykBWqEGcr.mesh) (4.4 MB)

Sorry, it still need to reads a mesh and boundary data from bc1.log  
I can spend more time to simply the code by generating a 3D mesh in FreeFem ….  
If you remove

`schurPreconditioner = S, schurList = list)`

there would be no error. Thank you very much for your help with this.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [December 23, 2025, 2:37pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/6 "2025-12-23T14:37:01Z")

</div>

[stokes\_adjoint\_six\_fields\_simple\_mesh.edp](https://community.freefem.org/uploads/short-url/lf26pqxW7IrRE3PoJaOP8xd3q9l.edp) (4.7 KB)

This is a simpler version.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 23, 2025, 8:07pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/7 "2025-12-23T20:07:55Z")

</div>

The code runs fine for me. What is your FreeFEM and PETSc versions?

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [December 23, 2025, 9:51pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/8 "2025-12-23T21:51:55Z")

</div>

That’s strange. FreeFEM is 4.12

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 24, 2025, 5:09am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/9 "2025-12-24T05:09:56Z")

</div>

That’s not strange at all since you are using an outdated FreeFEM version. Use the `develop` branch and try again, please.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [December 24, 2025, 9:47am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/10 "2025-12-24T09:47:19Z")

</div>

Thank you for your help. I will update my FreeFEM.

But can I confirm that when you run

[stokes\_adjoint\_six\_fields\_simple\_mesh.edp](https://community.freefem.org/uploads/short-url/7fFg7SUi1fW0404uANL89AVICNr.edp) (4.7 KB)

`, schurPreconditioner = S, schurList = schurList);`

has been included?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 24, 2025, 11:52am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/11 "2025-12-24T11:52:47Z")

</div>

It was not in the original code, so it was not included… Now, I get an error indeed. I will look into it.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 25, 2025, 9:44am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/12 "2025-12-25T09:44:47Z")

</div>

OK, now I see the issue. You cannot use those parameters when the `Mat` has no associated domain decomposition. Since you are using a block constructor for `M`, it indeed has no domain decomposition attached to it. In the case, I case the simplest thing to do would be to just write a custom `func` and use a `PCSHELL`.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 25, 2025, 9:48am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/13 "2025-12-25T09:48:24Z")

</div>

I have added an assert here: [Ensure that there is a domain decomposition attached to the Mat · FreeFem/FreeFem-sources@7bb1771 · GitHub](https://github.com/FreeFem/FreeFem-sources/commit/7bb1771a802269fee001b70ba1e4f191684f9a92), thanks for the report.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [January 6, 2026, 9:19pm UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/14 "2026-01-06T21:19:18Z")

</div>

Hi again, did you mean adding the following line  
`ffassert(ptA->_A);`

in file _PETSc.hpp_

would solve the problem?

I have done so in the source file, and recompile FreeFem. However, it failed as shown below:

> — global numbering created (in 2.008170e-04)  
> — global CSR created (in 5.669300e-05)  
> current line = 279 mpirank 0 / 4  
> Assertion fail : (ptA-\>\_A)  
> line :119, in file PETSc.hpp  
> current line = 279 mpirank 1 / 4  
> current line = 279 mpirank 2 / 4  
> current line = 279 mpirank 3 / 4  
> Assertion fail : (ptA-\>\_A)  
> line :119, in file PETSc.hpp  
> err code 6 , mpirank 0  
> WARNING! There are options you set that were not used!  
> WARNING! could be spelling mistake, etc!  
> There are 12 unused database options. They are:  
> Option left: name:-fieldsplit\_a\_pc\_type value: gamg source: code  
> Option left: name:-fieldsplit\_b\_pc\_type value: gamg source: code  
> Option left: name:-fieldsplit\_p\_pc\_type value: gamg source: code  
> Option left: name:-fieldsplit\_q\_pc\_type value: gamg source: code  
> Option left: name:-fieldsplit\_u\_pc\_type value: gamg source: code  
> Option left: name:-fieldsplit\_v\_pc\_type value: gamg source: code  
> Option left: name:-ksp\_converged\_reason (no value) source: code  
> Option left: name:-ksp\_initial\_guess\_nonzero value: true source: code  
> Option left: name:-ksp\_max\_it value: 100 source: code  
> Option left: name:-ksp\_monitor (no value) source: code  
> Option left: name:-ksp\_rtol value: 1.e-5 source: code  
> Option left: name:-ksp\_type value: fgmres source: code  
> Assertion fail : (ptA-\>\_A)  
> line :119, in file PETSc.hpp  
> err code 6 , mpirank 1  
> Assertion fail : (ptA-\>\_A)  
> line :119, in file PETSc.hpp  
> err code 6 , mpirank 2  
> Assertion fail : (ptA-\>\_A)  
> line :119, in file PETSc.hpp  
> err code 6 , mpirank 3

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 7, 2026, 3:57am UTC](https://community.freefem.org/t/schurpreconditioner-schurlist/4162/15 "2026-01-07T03:57:02Z")

</div>

No, I didn’t mean that. I meant that your code is not supposed to work, so now it properly errors out instead of running into a segmentation fault.
