Update:
I tested a more simplified example with mpc.create_periodic_constraint_geometrical
:
import dolfinx
import dolfinx_mpc
from mpi4py import MPI
import basix.ufl
import numpy as np
comm = MPI.COMM_WORLD
n_size = 100 # number of elements in each direction
mesh1 = dolfinx.mesh.create_unit_cube(
MPI.COMM_WORLD, n_size, n_size, n_size, cell_type=dolfinx.mesh.CellType.hexahedron)
mesh2 = dolfinx.mesh.create_box(MPI.COMM_WORLD,
[np.array([0, 0, 0]), np.array([n_size, n_size, n_size])],
[n_size, n_size, n_size], cell_type=dolfinx.mesh.CellType.hexahedron)
# mesh
def mapping(domain):
L_max = domain.geometry.x[:, 0].max()
# functionspace
P1 = basix.ufl.element("Lagrange", domain.topology.cell_name(), 1, gdim=domain.geometry.dim)
V = dolfinx.fem.functionspace(domain, P1)
## periodic boundary conditions
num_mapping_dofs = 0
mpc = dolfinx_mpc.MultiPointConstraint(V)
def periodic_boundary_y(x):
return np.isclose(x[1], L_max, atol=1e-6)
def periodic_relation_y(x):
nonlocal num_mapping_dofs
out_x = np.zeros_like(x)
out_x[0] = x[0]
out_x[1] = L_max - x[1]
out_x[2] = x[2]
num_mapping_dofs += len(out_x[0])
return out_x
bcs = []
mpc.create_periodic_constraint_geometrical(V, periodic_boundary_y, periodic_relation_y, bcs)
mpc.finalize()
print(f"Number of slaves: {len(mpc.slaves)}, total number of mapping DOFs through functions: {num_mapping_dofs}")
if __name__ == "__main__":
mapping(mesh1)
mapping(mesh2)
Locally, I get the correct result (dolfinx_mpc
is used via the docker image):
Number of slaves: 10201, total number of mapping DOFs through functions: 10201
Number of slaves: 10201, total number of mapping DOFs through functions: 10201
However, at the HPC, I get this result:
Number of slaves: 10201, total number of mapping DOFs through functions: 10201
Number of slaves: 201, total number of mapping DOFs through functions: 10201
The installation at the HPC was done via spack
and dolfinx_mpc
was build on top from source. I changed one parameter in utils.h
as discussed here. For both, I am using version 0.7.2
.
My questions are:
- Do you get the same results? I am a little bit confused, as I get different results for the execution on HPC and via docker image.
- Why does the example here work in contrast to the example above (at least via docker image)? Is there a difference in
mpc.create_periodic_constraint_geometrical
andmpc.create_periodic_constraint_topological
?
I am very grateful for your help. Thanks.