Accessing values of a block matrix system
Dear Firedrakers, I'm trying to compare the matrices I get from matlab to the ones generated in Firedrake, but I've run into some issues: A = assemble(a, nest=True) print A.getValues(1,1) gives me File "compressible_stratified.py", line 137, in <module> print A.getValues(1,1) AttributeError: 'Matrix' object has no attribute 'getValues' How would I fix this ? Regards Will
Use print A.M.handle.getValues(1,1) On Wednesday, August 24, 2016, William Booker <scwb@leeds.ac.uk> wrote:
Dear Firedrakers,
I'm trying to compare the matrices I get from matlab to the ones generated in Firedrake, but I've run into some issues:
A = assemble(a, nest=True)
print A.getValues(1,1)
gives me
File "compressible_stratified.py", line 137, in <module> print A.getValues(1,1) AttributeError: 'Matrix' object has no attribute 'getValues'
How would I fix this ?
Regards Will
Hi, I now get the following error File "compressible_stratified.py", line 137, in <module> print A.M.handle.getValues(1,1) File "PETSc/Mat.pyx", line 738, in petsc4py.PETSc.Mat.getValues (src/petsc4py.PETSc.c:121949) File "PETSc/petscmat.pxi", line 919, in petsc4py.PETSc.matgetvalues (src/petsc4py.PETSc.c:29292) petsc4py.PETSc.Error: error code 56 [0] MatGetValues() line 1845 in /tmp/pip-v0eIT6-build/src/mat/interface/matrix.c [0] No support for this operation for this object type [0] Mat type nest ________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Justin Chang <jychang48@gmail.com> Sent: 24 August 2016 19:18:54 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] Accessing values of a block matrix system Use print A.M.handle.getValues(1,1) On Wednesday, August 24, 2016, William Booker <scwb@leeds.ac.uk<mailto:scwb@leeds.ac.uk>> wrote: Dear Firedrakers, I'm trying to compare the matrices I get from matlab to the ones generated in Firedrake, but I've run into some issues: A = assemble(a, nest=True) print A.getValues(1,1) gives me File "compressible_stratified.py", line 137, in <module> print A.getValues(1,1) AttributeError: 'Matrix' object has no attribute 'getValues' How would I fix this ? Regards Will
On 25/08/16 12:03, William Booker wrote:
Hi,
I now get the following error
File "compressible_stratified.py", line 137, in <module> print A.M.handle.getValues(1,1) File "PETSc/Mat.pyx", line 738, in petsc4py.PETSc.Mat.getValues (src/petsc4py.PETSc.c:121949) File "PETSc/petscmat.pxi", line 919, in petsc4py.PETSc.matgetvalues (src/petsc4py.PETSc.c:29292) petsc4py.PETSc.Error: error code 56 [0] MatGetValues() line 1845 in /tmp/pip-v0eIT6-build/src/mat/interface/matrix.c [0] No support for this operation for this object type [0] Mat type nest
Which values do you want? It is not clear to me. You have: A = assemble(a, nest=True) Which, because your functionspace is mixed with 2 components, is a 2x2 block matrix: A00 A01 A10 A11 Because you said nest=True, this is stored as 4 separate block matrices. Therefore getting values from the whole thing is not supported by PETSc. If you want the whole matrix A: A = assemble(a, nest=False) vals = A.M.values if you want the 00 block (in this case it doesn't matter if you build with nest=True or False) vals00 = A.M[0, 0].values etc... Lawrence
participants (3)
- 
                
                Justin Chang
- 
                
                Lawrence Mitchell
- 
                
                William Booker