[petsc-users] reordering the dmda dof

Jed Brown jedbrown at mcs.anl.gov
Fri Oct 11 08:41:23 CDT 2013


Bishesh Khanal <bisheshkh at gmail.com> writes:
> Thanks Matt, but I was trying to check if there is any problem in a matrix
> I created. I had my old prototype code in MATLAB where I created a matrix
> by having a block of rows for each dof. So as a quick test, I wanted to
> write the matrix I created in Petsc to a file and read it with matlab and
> compare the two matrices, taking a difference would help me spot errors
> quickly.

Just permute the matrix, either using ISCreateGeneral and MatPermute or
in Matlab by creating P = [1, m+1, 2*m+1, 2, m+2, 2*m+2, ...] and then
looking at A(P,P).

> Please let me know if there is a quick way to do that. And if there are
> better ways to track down possible errors in the matrix creation by having
> better visualization of elements of the matrix created in petsc (without
> going to matlab), I'd be happy to learn that too.

If this is the Jacobian of something, use -snes_type test to compare
what you assembled to the matrix obtained by finite differencing the
residual function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131011/e905d814/attachment-0001.pgp>


More information about the petsc-users mailing list