Creata a 'Mat' with all componets are zero PETSc

Hi,
I am leanring to develop a code using FreeFEM with PETSc. I just met a problem that is to create a ‘Mat’ type matrix with all components being zero. My solution is

int N = 200;
real[int, int] A(N, N);
A = 0.; matrix empA = A;
Mat empAm = empA;

However, this solution is not efficient since A is not sparse despite empA is sparse.

I checked the FreeFEM-PETSc tutorial (here) but didn’t find an efficient solution. Does FreeFEM provide a function resembling ‘MatZeroEntries’ in PETSc?
Can this function extend to a matrix with different rows and columns?

A little personal suggestion: I suggest the developers put the link of the FreeFEM-PETSc tutorial on the documentation page (here) since this is a really good material to learn FreeFEM with PETSc.

I really appreciate any help you can provide.

I’m not sure I understand what you want to achieve. Just a matrix full of zeros?

$ cat empty.edp 
load "PETSc"
matrix A(20, 20);
Mat B(A);
ObjectView(B);
$ ff-mpirun -n 1 empty.edp -v 0
Mat Object: 1 MPI process
  type: seqaij
row 0:
row 1:
row 2:
row 3:
row 4:
row 5:
row 6:
row 7:
row 8:
row 9:
row 10:
row 11:
row 12:
row 13:
row 14:
row 15:
row 16:
row 17:
row 18:
row 19:
1 Like

Thank you, prj. This is exactly what I want.