<div dir="ltr">Dear Petsc developers, <div><br></div><div>I am writing my own code to calculate the FEM matrix. The following is my general framework,</div><div><br></div><div>DMPlexCreateGmsh();</div><div>MPI_Comm_rank (Petsc_comm_world, &rank);</div><div>DMPlexDistribute (.., .., &dmDist);</div><div><br></div><div>dm = dmDist;</div><div>//This can create separate dm s for different processors. (reordering.)</div><div><br></div><div>MatCreate (Petsc_comm_world, &A)</div><div>// Loop over every tetrahedral element to calculate the local matrix for each processor. Then we can get a local matrix A for each processor.</div><div><br></div><div><i>My question is : it seems we should build a global matrix B (assemble all the As for each partition) and then transfer B to KSP. KSP will do the parallelization correctly, right? </i></div><div><br></div><div>If that is right, I should define a whole domain matrix B before the partitioning (MatCreate (Petsc_comm_world, &B); ), and then use localtoglobal (which petsc function should I use? Do you have any examples.) map to add A to B at the right positions (MatSetValues) ? </div><div><br></div><div>Does that make sense? </div><div><br></div><div>Thanks, </div><div><br></div><div>Xiaodong</div><div> </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>