# Domain Decomposition with PETSc

Does anyone have any experience on Domain Decomposition using PETSc library? I have used PETSc for creating my vectors and matrix within my C++ code. I also used KSP to solve the linear system.

I used following examples to learn about Domain Decomposition in PETSc but they were not helpful:

I would be grateful if you give me some hints on how to do the graph partitioning and domain decomposition with PETSc.

## 1 Answer

I suggest understanding a structured grid example before getting into unstructured. So start with something like snes/examples/tutorials/ex5.c. For unstructured, you can manage everything, as in the ex10d that was removed because it was a bad example, or you can use DMPlex, the component that manages unstructured meshes in PETSc. The ex12 you mention is an example of this, but it hides a lot of details and I don't think it's great for beginners.

Your question is not very specific so I don't know what you're having a hard time with.

• I have created the mesh of my case study with Pointwise. My code is written in c++ and I have linked it with PETSc. So the code is able to be used in Parallel. I went through different examples in PETSc, But still it is not clear for me that how can I do graph partitioning on the mesh that I already have created and what commands to use for doing the domain decomposition... – Nazi Oct 21 '14 at 21:01
• There is not a single Right Way to do it and partitioning is not something PETSc does directly. You can use PETSc's interface to external packages like ParMETIS and Scotch. If you use a supported mesh format, DMPlex can read it and call ParMETIS to partition and distribute. I can't give you a simple recipe because people have different requirements and assumptions and because doing it well is not particularly simple. If you want higher level and more opinionated support for distribution and discretization, you might check out libMesh or (even higher-level) MOOSE, or many others. – Jed Brown Oct 22 '14 at 6:35
• Thanks Jed Brown. According to what you said, I tried to learn about DMPlexCreateFromDAG to be able to make my mesh as input to PETSc and then use DMPlex to do the Domain Decomposition. I just have one question and it is that, how much using DMPlex for doing the descretization will improve the speed of running the codes. As I said before, I have a code that is linked with PETSc and can be used for parallel purposes but its speed is super slow. Can I speed up the simulation by using DMPlex? – Nazi Oct 30 '14 at 16:09
• This is not a question that can be answered without knowing where your application spends its time. Run with -log_summary as a start, then consider other profiling toos. – Jed Brown Oct 31 '14 at 4:54