# About solve matrix

**URL:** https://community.freefem.org/t/about-solve-matrix/4098
**Category:** General Discussion
**Created:** [October 9, 2025, 12:27pm UTC](https://community.freefem.org/t/about-solve-matrix/4098 "2025-10-09T12:27:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [October 9, 2025, 12:27pm UTC](https://community.freefem.org/t/about-solve-matrix/4098/1 "2025-10-09T12:27:24Z")

</div>

Dear FreeFem developers and users:

I would like to ask a question and hope to receive some help or suggestions.

(1)Background: For the following global matrix KGlobal (where A, B, C, etc., are all block matrices), it is common to solve it using:  
set(KGlobal, solver=sparsesolver);  
result = KGlobal^-1 \* RHS;  
KGlobal = [  
[A, 0, 0, MS’],  
[0, B, C, MR’],  
[0, D, E, 0],  
[MS, MR, 0, 0]  
];

(2)My issue: Suppose now that the block matrix MR and its transpose change at each time step. If I continue to use the above solution method at every time step, I would need to reassemble, factorize, and solve the matrix at each step, which would be an extremely time-consuming process. Therefore, for cases where only a small portion of the matrix changes over time while the rest remains unchanged, does FreeFem++ offer a relatively convenient method to avoid this global operation?

I am still not very proficient with this software. If my description is unclear, I apologize for any confusion.

---

<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: [October 9, 2025, 2:45pm UTC](https://community.freefem.org/t/about-solve-matrix/4098/2 "2025-10-09T14:45:24Z")

</div>

With a FreeFEM `matrix` it is not possible to exploit this feature and just reassemble the changing part of the block matrix `KGlobal`. With a PETSc `Mat` it is possible to exploit this feature.

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [October 9, 2025, 3:13pm UTC](https://community.freefem.org/t/about-solve-matrix/4098/3 "2025-10-09T15:13:29Z")

</div>

I am very honored to receive your reply, Professor. May I ask if there are any reference cases? I haven’t delved deeply into this part of the content, and I hope to receive further guidance from you. Thank you very much, Professor

---

<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: [October 10, 2025, 12:57pm UTC](https://community.freefem.org/t/about-solve-matrix/4098/4 "2025-10-10T12:57:46Z")

</div>

There are some examples in the `examples/hpddm` folder using block matrices, e.g., `stokes-block-2d-PETSc.edp`.
