This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Subdomain in eigensolver

+1 vote

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)
asked May 13, 2014 by Shizu FEniCS Novice (350 points)

Hi, how are e1 and e2 defined? I tried with constants and in that case I could not reproduce your error with version 1.3.0 .

It's true, I just realized that this error comes from the following of my code:

class ElectricWall(SubDomain):
  def inside(self, x, on_boundary):
    return on_boundary;

electric_wall = DirichletBC( V, Expression(("0.0","0.0")), ElectricWall())

electric_wall.apply ( S )
electric_wall.apply ( T )

(and yeah, e1 and e2 are const)
PS: Thanks a lot for this fast reply.

I have
e1 = 0 and e2 =4
And It seems that the errors comes when e1=0

What's your dolfin version? I applied bcs and everything and get no error.

...