Save matrix A and right hand side b in MATLAB .mat format #2870
-
Hi, I am trying to import assembled matrix A and the right hand side b of the linear system from Steady-state advection equation with up-winding problem (https://www.firedrakeproject.org/demos/upwind_advection.py.html) into MATLAB. Is there any way to save the matrix A and rhs b in .mat format or a python readable Compressed Sparse Row matrix format from firedrake? Thank you |
Beta Was this translation helpful? Give feedback.
Answered by
dham
Apr 13, 2023
Replies: 1 comment
-
Courtesy of @pbrubeck on Slack: indptr, indices, values = assemble(a).petscmat.getValuesCSR()
import scipy
A = scipy.sparse.csr_matrix((values, (indptr, indices))
mdict = {"fem_matrix": A}
scipy.io.savemat("firedrake_output", mdict) And: values = assemble(L).dat.data_ro |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dham
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Courtesy of @pbrubeck on Slack:
And: