# Question about PETSc

**URL:** <https://community.freefem.org/t/question-about-petsc/2670>\
**Category:** General Discussion\
**Created:** [August 30, 2023, 11:49am UTC](https://community.freefem.org/t/question-about-petsc/2670 "2023-08-30T11:49:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [August 30, 2023, 11:49am UTC](https://community.freefem.org/t/question-about-petsc/2670/1 "2023-08-30T11:49:57Z")

</div>

Hi, is it possible to use PETSc while using the ‘problem’ keyword? Or is it necessary to use the ‘varf’ keyword when using PETSc?

Cheers!

---

<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:** [August 30, 2023, 12:12pm UTC](https://community.freefem.org/t/question-about-petsc/2670/2 "2023-08-30T12:12:45Z")

</div>

It is necessary to use the `varf` keyword.

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [August 30, 2023, 12:53pm UTC](https://community.freefem.org/t/question-about-petsc/2670/3 "2023-08-30T12:53:02Z")

</div>

Awesome. One further question: is it possible to use varf to solve a system of transient non-linear homogeneous PDEs in multiple unknowns (with the Newton method employed to deal with the non-linearity)? I assume that this is possible, but I’d just like to check before I try anything. I’ve managed to solve my system using the ‘problem’ keyword, but I really would like to try using the ‘varf’ keyword so that I can use a more efficient solver, such as PETSc. I’ve started getting the occasional memory error with my current code, which I’ve been told could be the result of using the standard UMFPACK solver.

---

<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:** [August 30, 2023, 1:04pm UTC](https://community.freefem.org/t/question-about-petsc/2670/4 "2023-08-30T13:04:07Z")

</div>

Yes, of course. You can even use `SNESSolve`, so that you don’t have to reimplement the wheel and code the Newton method yourself.

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [August 30, 2023, 1:13pm UTC](https://community.freefem.org/t/question-about-petsc/2670/5 "2023-08-30T13:13:21Z")

</div>

I’ve not heard of SNESSolve, where can I read about it? Also, by wheel do you mean the iteration loop? Many thanks.

---

<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:** [August 30, 2023, 1:15pm UTC](https://community.freefem.org/t/question-about-petsc/2670/6 "2023-08-30T13:15:28Z")

</div>

> **[Reinventing the wheel](https://en.wikipedia.org/wiki/Reinventing_the_wheel)**
>
> To reinvent the wheel is to attempt to duplicate—most likely with inferior results—a basic method that has already previously been created or optimized by others. 
> The inspiration for this idiomatic metaphor is that the wheel is an ancient archetype of human ingenuity (one so profound that it continues to underlie much of modern technology). As it has already been invented and is not considered to have any inherent flaws, an attempt to reinvent it would add no value to it and be a waste of time...

Most of these examples use `SNESSolve` [https://github.com/FreeFem/FreeFem-sources/tree/master/examples/hpddm#nonlinear-problems](https://github.com/FreeFem/FreeFem-sources/tree/master/examples/hpddm#nonlinear-problems). Also, of course, the PETSc manual is important [SNESSolve — PETSc 3.19.4 documentation](https://petsc.org/release/manualpages/SNES/SNESSolve/).

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [August 30, 2023, 1:45pm UTC](https://community.freefem.org/t/question-about-petsc/2670/7 "2023-08-30T13:45:09Z")

</div>

Oh I see, what you mean now. I’ll investigate this material, many thanks!

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [August 30, 2023, 1:58pm UTC](https://community.freefem.org/t/question-about-petsc/2670/8 "2023-08-30T13:58:46Z")

</div>

Apologies, but is there a way to view the original form of the PDE problem for each of the examples in the first link you provided? I could probably work backwards from the freefem code to determine the original form of the problem, but it would be awkward. Being able to see the original PDE problem corresponding to each freeFEM script would be very useful.

---

<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:** [August 30, 2023, 2:02pm UTC](https://community.freefem.org/t/question-about-petsc/2670/9 "2023-08-30T14:02:04Z")

</div>

For some of these, they are in [FreeFem-tutorial](https://joliv.et/FreeFem-tutorial).
