Setting periodic constraints for large meshes

I think I’ve located the issue. The issue is that when the elements get this small, my tolerance in pull back for determining the intersection goes very close to machine precision.
See: Make tolerance slightly larger by jorgensd · Pull Request #104 · jorgensd/dolfinx_mpc · GitHub for the suggested change.
At least the issue is resolved for 180x180x180 mesh with 7 procs:

import dolfinx
import dolfinx_mpc
from mpi4py import MPI
import basix.ufl
import numpy as np


n = [180]
tol = 1e-8
for n_size in n:
    domain = dolfinx.mesh.create_unit_cube(
        MPI.COMM_WORLD, n_size, n_size, n_size, cell_type=dolfinx.mesh.CellType.hexahedron)

    # funcitonspace
    P1 = basix.ufl.element(
        "Lagrange", domain.topology.cell_name(), 1, gdim=domain.geometry.dim)
    V = dolfinx.fem.functionspace(domain, P1)
    print(domain.comm.rank, V.dofmap.index_map.size_local,
          "/", V.dofmap.index_map.size_global)
    # periodic boundary conditions
    mpc = dolfinx_mpc.MultiPointConstraint(V)

    def periodic_boundary_y(x):
        return np.isclose(x[1], 1.0, atol=tol)

    def periodic_relation_y(x):
        out_x = np.zeros_like(x)
        out_x[0] = x[0]
        out_x[1] = 1 - x[1]
        out_x[2] = x[2]
        return out_x

    bcs = []
    mpc.create_periodic_constraint_geometrical(
        V, periodic_boundary_y, periodic_relation_y, bcs)
    mpc.finalize()
    MPI.COMM_WORLD.Barrier()
    if MPI.COMM_WORLD.rank == 0:
        print(f"Succesfully created periodic constraint for size {n_size}.")
1 848968 / 5929741
2 848458 / 5929741
3 839859 / 5929741
5 852260 / 5929741
0 838798 / 5929741
Succesfully created periodic constraint for size 180.
6 857276 / 5929741
4 844122 / 5929741

Tested for 200 and 220

0 1146683 / 8120601
Succesfully created periodic constraint for size 200.
1 1162537 / 8120601
2 1171795 / 8120601
3 1151006 / 8120601
5 1162744 / 8120601
6 1168585 / 8120601
4 1157251 / 8120601

4 1548939 / 10793861
6 1552706 / 10793861
0 1518867 / 10793861
Succesfully created periodic constraint for size 220.
3 1546520 / 10793861
2 1541853 / 10793861
1 1542862 / 10793861
5 1542114 / 10793861
1 Like