Hello,
I am trying to solve Helmholtz equation with sub-domain, but I have this error:
Error: unable to set given rows to identity matrix.
Reason: some diagonal elements not preallocated
Where: This error was encountered inside PETScMatrix.cpp.
Here is my complete code before error comes:
class Dielectric(SubDomain):
def inside(self, x, on_boundary):
return (between(x[1], (0.0, 0.25)))
dielectric = Dielectric()
mesh = RectangleMesh ( 0, 0, 1, 0.5, 8, 4)
domains = CellFunction("size_t", mesh)
domains.set_all(0)
dielectric.mark(domains, 1)
dx = Measure("dx")[domains]
V = FunctionSpace ( mesh, "Nedelec 1st kind H(curl)", 3 )
u = TestFunction(V)
v = TrialFunction(V)
def curl_t(w):
return Dx(w[1], 0) - Dx(w[0], 1)
s = curl_t(u)*curl_t(v)*dx(0) + curl_t(u)*curl_t(v)*dx(1)
t = dot( v, u ) * ( 1 - e1) * dx(0) + dot( v, u) * ( 1 - e2) * dx(1)
S = PETScMatrix()
T = PETScMatrix()
assemble(s, tensor=S)
assemble(t, tensor=T)