Errors regarding dolfinx_mpc

Hi, I would like to implement pbc using dolfinx_mpc, but I work in CPP interface, so I start by translating the demos from python into CPP.

For the demo here: https://github.com/jorgensd/dolfinx_mpc/blob/v0.6.0/python/demos/demo_periodic_geometrical.py

the PBC is defined like this
Screenshot from 2023-10-12 17-12-21

I write my codes as follows:


and creat the PBC:

The issue is that, I can compile my codes successfully. But the program can not run unless I set the bc to be empty, the error message is:


does anyone know how to fix the issue? Thanks very much!

What do you mean by “unless I set the bc to be empty”?
For setting periodic bcs with dolfinx_mpc, you need to give Dirichlet bcs as an input, as it removes these DOFs from the multipoint constraint.
If you do not set Dirichlet bcs to you problem, then you still need to provide empty bcs (at least for python).

That means if I write my codes as follows:

dolfinx_mpc::create_periodic_condition_geometrical(V, periodic_condition,periodic_relation,{},1,false);

where the Dirichlet BC is empty.
Maybe there is some issues with my Dirichlet BC?

I think the issue here is that you have not vectorized the input to the mapping functions. It expects a (3, num_points) array (flattened as a span in C++), not an array of len (3)

Do you refer to the periodic_relation term? I have also suspicious about this variable, I went to the source code and found that the function is designed as follows:

Screenshot from 2023-10-13 15-58-48

so the expected input is:

const std::function<std::vector(std::span)>& relation

I suppose that I should create a function who receivs a span and returns to a vector, but I can not find any errors in my code, since this function is not that complicated. Do you know how to fix it, or is there any related demos? Thanks!

I would suggest having a look at:

As it is a function that maps the span to the (3, num_points) multi-dimensional span.