This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to initialize a PETScMatrix with given sizes?

0 votes

Dear all,
I would like to initialize a PETScMatrix A with given sizes mxm. In FeniCS 1.0.0, it is very simple, I can call A.resize(m,m). However, this method was removed in the new version, FeniCS 1.2.0. Temporarily, I have to use assemble method to initialize a matrix but it is not a good way for my problem. Could you please show me how to initialize such the matrix?
Thank you very much for your help,
Best regards,
Dang

asked Dec 16, 2013 by dang.1032170 FEniCS Novice (180 points)

1 Answer

0 votes

You need to construct a TensorLayout object, and use this to initialise the PETScMatrix.

The old interface was unfortunate. It is not suitable for sparse matrices, which is why it has been removed.

answered Dec 21, 2013 by Garth N. Wells FEniCS Expert (35,930 points)
...