I want to compute the seconda order normal derivative of VectorH1 on internal facets such as in CutFEM problem.
I have tried
-
method 1: use
dn
operator in ngsxfem -
method 2: interpolate (element-wise) nodes of an expression tree into another fe-space
but none of them work.
# normal derivative jumps:
def dnjump(u,order,comp = -1):
if order%2==0:
return dn(u,order,comp) - dn(u.Other(),order,comp)
else:
return dn(u,order,comp) + dn(u.Other(),order,comp)
mesh = Mesh(unit_square.GenerateMesh(maxh=1))
Vh = VectorH1(mesh, order=2, dgjumps=True)
u, v = Vh.TnT()
nF = specialcf.normal(mesh.dim)
# method 1:
bf1b = BilinearForm(Vh)
bf1b += InnerProduct(dnjump(u, 2), dnjump(v, 2)) * dx(skeleton=True)
bf1b.Assemble()
print(bf1b.mat.DeleteZeroElements(1e-10))
# method 2:
fes2 = VectorH1(mesh, order=1)
gp_term = InnerProduct(grad(Interpolate(grad(u)*nF, fes2))*nF, grad(Interpolate(grad(v)*nF, fes2))*nF)
bf2b = BilinearForm(Vh)
bf2b += gp_term * dx(skeleton=True)
bf2b.Assemble()
print(bf2b.mat.DeleteZeroElements(1e-10))
When use method 1, following error happen:
NgException Traceback (most recent call last)
Cell In[282], line 20
18 bf1b = BilinearForm(Vh)
19 bf1b += InnerProduct(dnjump(u, 2), dnjump(v, 2)) * dx(skeleton=True)
—> 20 bf1b.Assemble()
21 print(bf1b.mat.DeleteZeroElements(1e-10))
NgException: std::bad_cast
in Assemble BilinearForm ‘biform_from_py’
When use method 2, following error happen:
NgException Traceback (most recent call last)
Cell In[284], line 28
26 bf2b = BilinearForm(Vh)
27 bf2b += gp_term * dx(skeleton=True)
—> 28 bf2b.Assemble()
29 print(bf2b.mat.DeleteZeroElements(1e-10))
NgException: Error: DifferentialOperator::CalcMatrix called for base class, type = N6ngcomp17InterpolateDiffOpEin Assemble BilinearForm ‘biform_from_py’
Attachment:
seconda_order_normal_derivative_of_VectorH1.py (848 Bytes)