# Changing PETSc communicator

**URL:** <https://community.freefem.org/t/changing-petsc-communicator/1570>\
**Category:** General Discussion\
**Created:** [March 3, 2022, 9:21pm UTC](https://community.freefem.org/t/changing-petsc-communicator/1570 "2022-03-03T21:21:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Markov](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@Markov](https://community.freefem.org/u/Markov)\
**Post date:** [March 3, 2022, 9:21pm UTC](https://community.freefem.org/t/changing-petsc-communicator/1570/1 "2022-03-03T21:21:59Z")

</div>

Hello everyone,

I would like to run PETSc on a subset of MPI\_COMM\_WORLD, hence I would like to create a smaller communicator and I was wondering where to add it in the source files (since It can not be modified in a script file like in a c++ code). I tried to declare it in PETSc-code.hpp before the initialization of PETSc but my code dead locked.

I’d appreciate any feedback on this problem.

---

<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:** [March 4, 2022, 6:08am UTC](https://community.freefem.org/t/changing-petsc-communicator/1570/2 "2022-03-04T06:08:10Z")

</div>

You can define your own communicator in the `.edp` and pass that to the `Mat` constructor using the parameter `communicator`. See, e.g., [FreeFem-sources/diffusion-cartesian-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/diffusion-cartesian-2d-PETSc.edp#L48).
