I use NGSolve - Python and I want to use gridfunctions(related ngsolve.BaseVector) and
bilinearforms (related ngsolve.BaseMatrix) as vectors and as matrices in SciPy. Is there a direct
and easy way to use them as vectors and matrices in SciPy?
I could not find any reference to this topic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
BaseVector -> NumPy Vector:
bv[:].NumPy()
get a NgSolve vector by bv[:] from the baseVector and the vector class has a .NumPy() function.
Matrix is a bit more work because of the SparseMatrix format, but you can use a.mat.COO() to get the COOrdinate format of the matrix and build a scipy sparse.sparse.coo_matrix out of that information.
BaseVector should be without any hard copying, with the matrix im not entirely sure...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use NGSolve - Python and I want to use gridfunctions(related ngsolve.BaseVector) and
bilinearforms (related ngsolve.BaseMatrix) as vectors and as matrices in SciPy. Is there a direct
and easy way to use them as vectors and matrices in SciPy?
I could not find any reference to this topic.
BaseVector -> NumPy Vector:
bv[:].NumPy()
get a NgSolve vector by bv[:] from the baseVector and the vector class has a .NumPy() function.
Matrix is a bit more work because of the SparseMatrix format, but you can use a.mat.COO() to get the COOrdinate format of the matrix and build a scipy sparse.sparse.coo_matrix out of that information.
BaseVector should be without any hard copying, with the matrix im not entirely sure...