Issue when apply MPC and dirichletbc together

was trying to use dolfinx_MPC to apply periodic boundary conditions together with Dirichlet bcs, something like
u3 = u2 + u4, with u4=10.
However, the results show that only part of the Dirichlet BCS are applied. Can create_general_constraint be used with fem.dirichletbc together? Same codes are as following

Thanks in advance


bc1x = fem.dirichletbc(0.0, dofs=n1x, V=V.sub(0))
bc1y = fem.dirichletbc(0.0, dofs=n1y, V=V.sub(1))

bc2x = fem.dirichletbc(0.0, dofs=n2x, V=V.sub(0))

bc4x = fem.dirichletbc(10.0, dofs=n4x, V=V.sub(0))
bc4y = fem.dirichletbc(0.0, dofs=n4y, V=V.sub(1))

bcs = [bc1x, bc2x, bc1y, bc4y, bc4x]

#MPC
mpc = MultiPointConstraint(V)

mpcx = {np.array([ a/2, b/2], dtype=np.float64).tobytes():
       {np.array([ -a/2, b/2], dtype=np.float64).tobytes(): 1,
        np.array([  a/2, -b/2], dtype=np.float64).tobytes(): -1}}

mpcy = {np.array([a/2, b/2], dtype=np.float64).tobytes():
       {np.array([ -a/2, b/2], dtype=np.float64).tobytes(): 1}}

mpc.create_general_constraint(mpcx, subspace_master=0, subspace_slave=0)
mpc.create_general_constraint(mpcy, subspace_master=1, subspace_slave=1)

mpc.finalize()

problem = LinearProblem(a, L, mpc, bcs=bcs,
                        petsc_options={"ksp_type": "preonly", "pc_type": "lu"})

That kind of behavior is currently not supported.

I started some work with this a while back, But I didn’t have time to finish the user interface for it.

As a workaround, I would apply the Dirichlet condition weakly with Nitsches method, see
https://jsdokken.com/dolfinx-tutorial/chapter1/nitsche.html

1 Like

Thanks. Can I use dolfinx_MPC to apply MPC and assemble matrices? Then, once the Jacobian matrices and residual are obtained, then manually apply the Dirichlet conditions. Is it feasible?

No. As you can see in the readme of dolfinx MPC, it computes K^TAK to eliminate dofs from the system, thus applying it afterwards won’t enforce it in a constraint.

1 Like

I see. Thanks. Can both Dirichlet conditions and MPC both exist in to model when using create_general_constraint, if Dirichlet conditions are not applied to nodes involving MPC?

Yes, then it can be used together