83 const dof_id_type elem_id,
84 const processor_id_type pid,
87 BoundaryInfo & boundary_info =
mesh.get_boundary_info();
93 PetscInt Mx, My, xp, yp;
94 LibmeshPetscCallA(
mesh.comm().get(),
110 const PetscInt *lx, *ly;
113#if PETSC_VERSION_LESS_THAN(3, 9, 0)
114 LibmeshPetscCallA(
mesh.comm().get(), DMGetWorkArray(da, xp + yp + 2, PETSC_INT, &lxo));
117 LibmeshPetscCallA(
mesh.comm().get(), DMGetWorkArray(da, xp + yp + 2, MPIU_INT, &lxo));
123 LibmeshPetscCallA(
mesh.comm().get(), DMDAGetOwnershipRanges(da, &lx, &ly, NULL));
125 for (PetscInt i = 0; i < xp; i++)
126 lxo[i + 1] = lxo[i] + lx[i];
130 for (PetscInt i = 0; i < yp; i++)
131 lyo[i + 1] = lyo[i] + ly[i];
134 PetscInt xpid, ypid, xpidplus, ypidplus;
138 LibmeshPetscCallA(
mesh.comm().get(), PetscFindInt(i, xp + 1, lxo, &xpid));
140 xpid = xpid < 0 ? -xpid - 1 - 1 : xpid;
142 LibmeshPetscCallA(
mesh.comm().get(), PetscFindInt(i + 1, xp + 1, lxo, &xpidplus));
144 xpidplus = xpidplus < 0 ? -xpidplus - 1 - 1 : xpidplus;
146 LibmeshPetscCallA(
mesh.comm().get(), PetscFindInt(j, yp + 1, lyo, &ypid));
148 ypid = ypid < 0 ? -ypid - 1 - 1 : ypid;
150 LibmeshPetscCallA(
mesh.comm().get(), PetscFindInt(j + 1, yp + 1, lyo, &ypidplus));
152 ypidplus = ypidplus < 0 ? -ypidplus - 1 - 1 : ypidplus;
153#if PETSC_VERSION_LESS_THAN(3, 9, 0)
154 LibmeshPetscCallA(
mesh.comm().get(), DMRestoreWorkArray(da, xp + yp + 2, PETSC_INT, &lxo));
156 LibmeshPetscCallA(
mesh.comm().get(), DMRestoreWorkArray(da, xp + yp + 2, MPIU_INT, &lxo));
160 auto node0_ptr =
mesh.add_point(Point(
static_cast<Real
>(i) / nx,
static_cast<Real
>(j) / ny, 0),
163 node0_ptr->set_id() = node0_ptr->unique_id();
165 node0_ptr->processor_id() = xpid + ypid * xp;
169 mesh.add_point(Point(
static_cast<Real
>(i + 1) / nx,
static_cast<Real
>(j) / ny, 0),
172 node1_ptr->set_id() = node1_ptr->unique_id();
173 node1_ptr->processor_id() = xpidplus + ypid * xp;
177 mesh.add_point(Point(
static_cast<Real
>(i + 1) / nx,
static_cast<Real
>(j + 1) / ny, 0),
179 node2_ptr->set_unique_id(
node_id_Quad4(nx, 0, i + 1, j + 1, 0));
180 node2_ptr->set_id() = node2_ptr->unique_id();
181 node2_ptr->processor_id() = xpidplus + ypidplus * xp;
185 mesh.add_point(Point(
static_cast<Real
>(i) / nx,
static_cast<Real
>(j + 1) / ny, 0),
188 node3_ptr->set_id() = node3_ptr->unique_id();
189 node3_ptr->processor_id() = xpid + ypidplus * xp;
192 Elem * elem =
new Quad4;
193 elem->set_id(elem_id);
194 elem->processor_id() = pid;
196 elem->set_unique_id(elem_id + (nx + 1) * (ny + 1));
197 elem =
mesh.add_elem(elem);
198 elem->set_node(0, node0_ptr);
199 elem->set_node(1, node1_ptr);
200 elem->set_node(2, node2_ptr);
201 elem->set_node(3, node3_ptr);
205 boundary_info.add_side(elem, 0, 0);
209 boundary_info.add_side(elem, 1, 1);
213 boundary_info.add_side(elem, 2, 2);
217 boundary_info.add_side(elem, 3, 3);
329 const auto pid =
mesh.comm().rank();
331 BoundaryInfo & boundary_info =
mesh.get_boundary_info();
340 PetscInt xs, ys, xm, ym, Mx, My, xp, yp;
343 LibmeshPetscCallA(
mesh.comm().get(),
344 DMDAGetCorners(da, &xs, &ys, PETSC_IGNORE, &xm, &ym, PETSC_IGNORE));
345 LibmeshPetscCallA(
mesh.comm().get(),
361 for (PetscInt j = ys; j < ys + ym; j++)
362 for (PetscInt i = xs; i < xs + xm; i++)
372 dof_id_type ele_id = (i - 1) + (j - 1) * (Mx - 1);
379 if ((ys == 0 && ym == 1) || (xs == 0 && xm == 1))
380 for (PetscInt j = ys; j < ys + ym; j++)
381 for (PetscInt i = xs; i < xs + xm; i++)
385 mesh.find_neighbors();
387 mesh.find_neighbors(
true);
390 for (
auto & elem_ptr :
mesh.element_ptr_range())
391 for (
unsigned int s = 0; s < elem_ptr->n_sides(); s++)
392 if (!elem_ptr->neighbor_ptr(s) && !boundary_info.n_boundary_ids(elem_ptr, s))
393 elem_ptr->set_neighbor(s,
const_cast<RemoteElem *
>(remote_elem));
397 mesh.skip_partitioning(
true);
401 mesh.set_next_unique_id(Mx * My + (Mx - 1) * (My - 1));
404 mesh.allow_renumbering(
false);
405 mesh.allow_find_neighbors(
false);
406 mesh.prepare_for_use();
407 mesh.allow_find_neighbors(
true);