-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SubMatrices to compute eigvals in demo qgbasinmodes #2402
Conversation
Sweet. I like the |
It was Lawrence's idea :) |
Run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a bit of work to be correct in parallel.
@@ -214,7 +223,7 @@ solver:: | |||
|
|||
and we gather the final eigenfunctions :: | |||
|
|||
eigenmodes_real.vector()[:], eigenmodes_imag.vector()[:] = vr, vi | |||
eigenmodes_real.vector()[ISin.array], eigenmodes_imag.vector()[ISin.array] = vr, vi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also insert the Dirichlet conditions into these eigenvectors (bc.apply
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary, given that bc = DirichletBC(Vcg, 0.0, "on_boundary")
?
Applied most of @wence- suggestions. Now it doesn't run because I don't know how to properly implement |
I probably got the syntax wrong for getting the size of the matrix |
I corrected (
whereas after the modification from this pull request the output becomes
The real part is different (but still very close to 0), whereas the imaginary parts differ by TODO:
|
bcnodes = Vcg.dof_dset.lgmap.apply(bc.nodes).astype(pyop2.datatypes.IntType) | ||
ISbd = PETSc.IS().createGeneral(bcnodes, comm=petsc_a.comm) | ||
s, e = petsc_a.getOwnershipRange() | ||
ISin = ISbd.complement(s, e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In parallel, ISbd.complement(s, e)
may rise exception:
File PETSc/IS.pyx:234, in petsc4py.PETSc.IS.complement()
Error: error code 62
[0] ISComplement() at /home/zzyang/workspace/firedrake-gcc/firedrake-mini-petsc-complex/src/petsc/src/vec/is/is/utils/iscoloring.c:815
[0] Invalid argument
[0] Index set must be sorted
[1:execute]
Maybe need add
s, e = petsc_a.getOwnershipRange()
bcnodes = bcnodes[np.logical_and(bcnodes < e, bcnodes >= s)]
bcnodes.sort()
to delete the ghost nodes and sort the array before creating the ISbd
.
If this is to be done it should be done in LinearEigenSolver. The right thing to do, though, is RestrictedFunctionSpace, which is hopefully coming. |
To compute the eigenvalues more robustly, create submatrices by removing rows and columns associated with degrees of freedom. This trick was suggested (on a different example) by @jandrej , @wence- , @francesco-ballarin and Matt Knepley, among others.
Disclaimer I haven't run the demo to check that it runs because I don't know how to convert an
*.py.rst
into a*.py
I can run.