NgException: other mir not set, pls report to developers

Hi,

Exception from the title is invoked by the following part of my code:

    Xp = CoefficientFunction((x, y))
    cf = (Xp - Xp.Other()) * contact.normal
    integral_of_difference = Integrate(cf, mesh)

The .Other can only be used in ContactBoundary (for now). If you want to compute this integral, you need to assemble or apply a BilinearForm right now.

Thank you for the answer, christoper.

Could you point me a bit on how to make this BilinearForm? I’ve tried with

X = CoefficientFunction((x, y))
gf1.Set(X)
b = BilinearForm(fes)
b += gf1 * u * ds(definedon=mesh.Boundaries(mesh_fun.bnds["Slave contact boundary string"]))
b += -gfu1 * u * ds(definedon=mesh.Boundaries(mesh_fun.bnds["Master contact boundary string"]))

and then for every calculated displacement gfu:

b.Apply(gfu.vec, res)

but doesn’t work.

Hi, no I mean one using the ContactBoundary from here: 6.2 Contact Problems — NGS-Py 6.2.2403 documentation

something like

cb = ContactBoundary(mesh.Boundaries("main"), mesh.Boundaries("secondary"))
cb.AddIntegrator((X - X.Other()) * v)
a = BilinearForm(fes)
cb.Update(gf=displacement, bf=a)
one = GridFunction(fes)
one.Set(1, defindon=mesh.Boundaries("main"))
tmp = one.vec.CreateVector()
a.Apply(displacement.vec, tmp2)
integral = InnerProduct(tmp2, one.vec) 

(not tested, let me know if it works/not works)

It’s not really nice… We should add some nicer way to do this…

Thanky again, christoper. It works after I switched from integrator

cb.AddIntegrator((X - X.Other()) * v)

to energy formulation

cb.AddEnergy((X - X.Other()) * u)

It is however hard for me to check if resulting number is correct, so I tried to calculate element-by-element product instead of integral, with

mult.FV().NumPy()[:] = one.vec.FV().NumPy() * tmp.FV().NumPy()

Now I am struggling to figure out how to evaluate the grid function mult as NumPy array. Applying mult.FV().NumPy() gives me a huge vector for which I don’t know how to represent on mesh nodes. Can you help me there as well?