195 BoundaryInfo & boundary_info = mesh.get_boundary_info();
197 #if LIBMESH_HAVE_PETSC
202 PetscInt Mx, My, xp, yp;
218 const PetscInt *lx, *ly;
221 #if PETSC_VERSION_LESS_THAN(3, 9, 0)
222 DMGetWorkArray(da, xp + yp + 2, PETSC_INT, &lxo);
225 DMGetWorkArray(da, xp + yp + 2, MPIU_INT, &lxo);
230 DMDAGetOwnershipRanges(da, &lx, &ly, NULL);
232 for (PetscInt i = 0; i < xp; i++)
233 lxo[i + 1] = lxo[i] + lx[i];
237 for (PetscInt i = 0; i < yp; i++)
238 lyo[i + 1] = lyo[i] + ly[i];
241 PetscInt xpid, ypid, xpidplus, ypidplus;
245 PetscFindInt(i, xp + 1, lxo, &xpid);
247 xpid = xpid < 0 ? -xpid - 1 - 1 : xpid;
249 PetscFindInt(i + 1, xp + 1, lxo, &xpidplus);
251 xpidplus = xpidplus < 0 ? -xpidplus - 1 - 1 : xpidplus;
253 PetscFindInt(j, yp + 1, lyo, &ypid);
255 ypid = ypid < 0 ? -ypid - 1 - 1 : ypid;
257 PetscFindInt(j + 1, yp + 1, lyo, &ypidplus);
259 ypidplus = ypidplus < 0 ? -ypidplus - 1 - 1 : ypidplus;
260 #if PETSC_VERSION_LESS_THAN(3, 9, 0)
261 DMRestoreWorkArray(da, xp + yp + 2, PETSC_INT, &lxo);
263 DMRestoreWorkArray(da, xp + yp + 2, MPIU_INT, &lxo);
267 auto node0_ptr = mesh.add_point(Point(static_cast<Real>(i) / nx, static_cast<Real>(j) / ny, 0),
269 node0_ptr->set_unique_id() =
node_id_Quad4(type, nx, 0, i, j, 0);
270 node0_ptr->set_id() = node0_ptr->unique_id();
272 node0_ptr->processor_id() = xpid + ypid * xp;
276 mesh.add_point(Point(static_cast<Real>(i + 1) / nx, static_cast<Real>(j) / ny, 0),
278 node1_ptr->set_unique_id() =
node_id_Quad4(type, nx, 0, i + 1, j, 0);
279 node1_ptr->set_id() = node1_ptr->unique_id();
280 node1_ptr->processor_id() = xpidplus + ypid * xp;
284 mesh.add_point(Point(static_cast<Real>(i + 1) / nx, static_cast<Real>(j + 1) / ny, 0),
286 node2_ptr->set_unique_id() =
node_id_Quad4(type, nx, 0, i + 1, j + 1, 0);
287 node2_ptr->set_id() = node2_ptr->unique_id();
288 node2_ptr->processor_id() = xpidplus + ypidplus * xp;
292 mesh.add_point(Point(static_cast<Real>(i) / nx, static_cast<Real>(j + 1) / ny, 0),
294 node3_ptr->set_unique_id() =
node_id_Quad4(type, nx, 0, i, j + 1, 0);
295 node3_ptr->set_id() = node3_ptr->unique_id();
296 node3_ptr->processor_id() = xpid + ypidplus * xp;
299 Elem * elem =
new Quad4;
300 elem->set_id(elem_id);
301 elem->processor_id() = pid;
302 elem->set_unique_id() = elem_id;
303 elem = mesh.add_elem(elem);
304 elem->set_node(0) = node0_ptr;
305 elem->set_node(1) = node1_ptr;
306 elem->set_node(2) = node2_ptr;
307 elem->set_node(3) = node3_ptr;
311 boundary_info.add_side(elem, 0, 0);
315 boundary_info.add_side(elem, 1, 1);
319 boundary_info.add_side(elem, 2, 2);
323 boundary_info.add_side(elem, 3, 3);