- Thank you received: 0

The forum is in read only mode.

#
VHeight does not make sense for BlockMatrix

*VHeight does not make sense for BlockMatrix*was created by

*ajf367*

So i'm running some code to solve a quadratic eigenvalue problem but encountering an error when I run it.

This gives the error message

Does anyone know how to resolve this error?

Code:

import netgen.gui
from netgen.geom2d import SplineGeometry
from ngsolve import *
import matplotlib.pyplot as plt
import netgen.geom2d as geom2d
from netgen.geom2d import unit_square
import numpy as np
geo = SplineGeometry()
geo.AddCircle( (0.0, 0.0), r=1.0, leftdomain=0, rightdomain=1, bc = "scatterer")
geo.AddCircle ( (0.0, 0.0), r=1.4, leftdomain=1, rightdomain=2)
geo.AddCircle ( (0.0, 0.0), r=1.9, leftdomain=2, rightdomain=0)
ngmesh = geo.GenerateMesh(maxh=0.02)
mesh = Mesh(ngmesh)
mesh.SetPML(pml.Radial(origin=(0.0,0.0), rad=1.4, alpha=1j), definedon=2)
nn=2;
fes = H1(mesh, order=4, complex=True, dirichlet="dir")
u = fes.TrialFunction()
v = fes.TestFunction()
k = BilinearForm (fes, symmetric=True)
k += -1*grad(u)*grad(v)*dx
c = BilinearForm (fes, symmetric=True)
c += 1j*u*v*ds("outerbnd")
m = BilinearForm (fes, symmetric=True)
m += (1+nn)*u*v*dx
k.Assemble()
c.Assemble()
m.Assemble()
I = IdentityMatrix(fes.ndof, complex=False)
II = -1*I
B1 = BlockMatrix([[m.mat, None], [None, I]])
B2 = BlockMatrix([[c.mat, k.mat], [II, None]])
u = GridFunction(fes, multidim=20, name='resonances')
with TaskManager():
lam = ArnoldiSolver(B2, B1, fes.FreeDofs(), u.vecs, shift=2)
Draw(u)

Code:

---------------------------------------------------------------------------
NgException Traceback (most recent call last)
<ipython-input-16-af6cb1fe1cdb> in <module>
42 u = GridFunction(fes, multidim=20, name='resonances')
43 with TaskManager():
---> 44 lam = ArnoldiSolver(B2, B1, fes.FreeDofs(), u.vecs, shift=2)
45 Draw(u)
46
NgException: VHeight does not make sense for BlockMatrix

Does anyone know how to resolve this error?

Replied by

*ddrake*on topic*VHeight does not make sense for BlockMatrix*
Hi,

It might be better to make I and II complex, since m.mat, k.mat, c.mat and u.vecs are complex, but I don't think the issue is with your code -- just that some of the lower level functionality hasn't been fully implemented yet for the complex case.

The error "VHeight does not make sense for BlockMatrix" occurs in the Python bindings for ArnoldiSolver where the height of the first matrix is checked. Height() maps to Vheight() in basematrix.hpp but is not implemented by BlockMatrix and gives the message in specialmatrix.hpp .

Just to see what would happen, I commented out that Height test to allow the code to proceed. I then got an error in basevector.cpp . There's a comment indicating the implementation of BlockVector is not complete for complex components.

Best,

Dow

It might be better to make I and II complex, since m.mat, k.mat, c.mat and u.vecs are complex, but I don't think the issue is with your code -- just that some of the lower level functionality hasn't been fully implemented yet for the complex case.

The error "VHeight does not make sense for BlockMatrix" occurs in the Python bindings for ArnoldiSolver where the height of the first matrix is checked. Height() maps to Vheight() in basematrix.hpp but is not implemented by BlockMatrix and gives the message in specialmatrix.hpp .

Just to see what would happen, I commented out that Height test to allow the code to proceed. I then got an error in basevector.cpp . There's a comment indicating the implementation of BlockVector is not complete for complex components.

Best,

Dow

Time to create page: 0.095 seconds