# How to solve multiple problems in parallel (not domain decomposition)

**URL:** <https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767>\
**Category:** General Discussion\
**Created:** [May 22, 2022, 8:57am UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767 "2022-05-22T08:57:58Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Jade](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@Jade](https://community.freefem.org/u/Jade)\
**Post date:** [July 17, 2022, 3:51pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/24 "2022-07-17T15:51:50Z")

</div>

Failing to run mpirun with a Python script in Ubuntu, I come back and try to implement the parallel computing directly in the edp file. Again, the problem is with domain decomposition. So `Mat` is a type in PETSc, but the function `createMat` is in `macro_ddm.idp`. I can’t use it without loading `macro_ddm.idp`. Can I create a `Mat` type without using this function?

---

<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:** [July 17, 2022, 3:54pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/25 "2022-07-17T15:54:01Z")

</div>

Yes, of course, as I’ve already told you in the past…

---

<div class="post-metadata">

**Author:** ![Jade](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@Jade](https://community.freefem.org/u/Jade)\
**Post date:** [July 17, 2022, 3:54pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/26 "2022-07-17T15:54:09Z")

</div>

The example in the link includes `macro_ddm.idp`.

---

<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:** [July 17, 2022, 3:55pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/27 "2022-07-17T15:55:12Z")

</div>

So? The particular lines that are highlighted do not use any stuff from `macro_ddm.idp`.

---

<div class="post-metadata">

**Author:** ![Jade](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@Jade](https://community.freefem.org/u/Jade)\
**Post date:** [July 17, 2022, 4:00pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/28 "2022-07-17T16:00:19Z")

</div>

But the matrix A is created using `createMat`, which is included in `macro_ddm.idp`. If A is created using the regular method, then I can’t use KSPSolve to solve the multiple rhs problem.

---

<div class="post-metadata">

**Author:** ![Jade](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@Jade](https://community.freefem.org/u/Jade)\
**Post date:** [July 17, 2022, 4:06pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/29 "2022-07-17T16:06:42Z")

</div>

I have tried to solve the multiple rhs problem using the regular method by something like `sol = A^-1*rhs` , where `rhs` is also a matrix (with or without the brackets syntax in different places), but the solution is always wrong, like the one in my previous post [https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/17](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/17). Can someone explain why this simple method fails?

---

<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:** [July 17, 2022, 4:11pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/30 "2022-07-17T16:11:57Z")

</div>

> But the matrix A is created using `createMat`

Again, the particular lines that are highlighted in the last link I sent do not use a `Mat` called `A`, but rather `Wn`.

---

<div class="post-metadata">

**Author:** ![Jade](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@Jade](https://community.freefem.org/u/Jade)\
**Post date:** [July 17, 2022, 6:08pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/31 "2022-07-17T18:08:55Z")

</div>

Finally, I created the system matrix by one line:

```auto
Mat<complex> A(Vh.ndof, communicator = mpiCommSelf);

```

---

<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:** [July 17, 2022, 6:20pm UTC](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767/32 "2022-07-17T18:20:03Z")

</div>

Yes, precisely the line I highlighted 2 months ago.

[Previous page](https://community.freefem.org/t/how-to-solve-multiple-problems-in-parallel-not-domain-decomposition/1767.md?page=1)
