# Request for additional documentation on Petsc-related functions

**URL:** https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608
**Category:** Feature Request
**Created:** [December 2, 2024, 8:43am UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608 "2024-12-02T08:43:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![QZH\_xia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/qzh_xia/32/2612_2.png) [@QZH\_xia](https://community.freefem.org/u/QZH_xia)
#### Post date: [December 2, 2024, 8:43am UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608/1 "2024-12-02T08:43:12Z")

</div>

Hello,

I initially learned Petsc and am now trying to use FreeFem to call Petsc. However, when I attempted to use it to solve problems, I found that FreeFem offers very little documentation regarding Petsc-related functions (such as `ChangeNumbering`, `SNESSolve`, `plotMPI`, etc.) on the official website. The “Functions” section in the documentation only covers some basic functions, while the usage of other functions can only be explored blindly through examples. In Petsc’s official documentation，every function is well-explained.  
Would it be possible to improve the related content on the FreeFem website? Perhaps I have missed some study materials. If there are relevant pages, could you please share the link with me?

Best regards,  
Lina

---

<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 2, 2024, 2:28pm UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608/2 "2024-12-02T14:28:54Z")

</div>

Both [https://www.youtube.com/watch?v=-Aw2O46V2bo](https://www.youtube.com/watch?v=-Aw2O46V2bo) and [FreeFem-tutorial](https://joliv.et/FreeFem-tutorial) should explain things in greater details.

---

<div class="post-metadata">

### Author: ![usiu5555](https://avatars.discourse-cdn.com/v4/letter/u/e19adc/32.png) [@usiu5555](https://community.freefem.org/u/usiu5555)
#### Post date: [December 17, 2024, 6:49am UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608/3 "2024-12-17T06:49:42Z")

</div>

Watching a YouTube series to find a signature and description for a function is quite… hard. Examples in the link to the tutorial have minimal comments. The PDF has the following description for ChangeNumbering:  
ChangeNumbering(Mat,K[int]), without specifying what obligatory arguments are, and worse, in all examples the function is used with 3 parameters, for example:  
`ChangeNumbering(T, w[], u, exchange = true, inverse = true);`

Is there no other way to learn than to blind experimenting? I am currently trying to understand this thing from an example:  
`TSSolve(T, funcJ, funcRes, wPETSc, sparams = "-ts_type beuler -ts_dt 0.1 -ts_max_time 100 -ts_exact_final_time interpolate -ts_max_snes_failures -1 -ts_view -pc_type lu -ts_adapt_type basic -ts_rtol 1e-3", monitor = funcM);`  
, that on the PETSc website has a highly different signature:  
`PetscErrorCode TSSolve(TS ts, Vec u)`  
and it is really hard to even guess where to look for explanations ☹

---

<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 17, 2024, 7:07am UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608/4 "2024-12-17T07:07:57Z")

</div>

You can have a look here: [https://arxiv.org/pdf/1806.01437](https://arxiv.org/pdf/1806.01437). Depending on the `TSType`, the parameters are either `F`, `G`, or the Jacobians.

---

<div class="post-metadata">

### Author: ![usiu5555](https://avatars.discourse-cdn.com/v4/letter/u/e19adc/32.png) [@usiu5555](https://community.freefem.org/u/usiu5555)
#### Post date: [December 18, 2024, 6:40am UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608/5 "2024-12-18T06:40:55Z")

</div>

Thanks for all the links and the answers. If you don’t mind, I am trying to understand this example: [FreeFem-sources/examples/hpddm/heat-TS-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/heat-TS-2d-PETSc.edp)

From the article you provided, I understand that `w/wPETSc` is the solution and `funcJ` is the `j` function provided to `TSSetIJacobian`. In the article, there is no explanation of what _M_ or _f_ are. In the example, it seems _M_ is a vector of 1s while _f_ is the stiffness matrix, which appears counterintuitive, so I think I am wrong. Do you know what these symbols mean?

---

<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 18, 2024, 7:07am UTC](https://community.freefem.org/t/request-for-additional-documentation-on-petsc-related-functions/3608/6 "2024-12-18T07:07:08Z")

</div>

`funcRes()` (resp. `funcJ()`) implements `IFunctionHeat()` (resp. `IJacobianHeat()`) from [https://petsc.org/release/src/ts/tutorials/ex3.c.html](https://petsc.org/release/src/ts/tutorials/ex3.c.html), which are respectively used in [TSSetIFunction — PETSc 3.22.2 documentation](https://petsc.org/release/manualpages/TS/TSSetIFunction/) and [TSSetIJacobian — PETSc 3.22.2 documentation](https://petsc.org/release/manualpages/TS/TSSetIJacobian/).
