← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Fixes for PETSc 2.3.3 compatibility.

 



Johan Hake wrote:
Hello Marc!

    here's a little patch I did to handle the change in MatInfo from
Petsc-3.0.0 (which no longer includes global sizes...this is handled
by MatGetSize)

Ok.

I believe this bit of code has the same  functionality as your
original code (whether that test is appropriate for determining the
same NonZeroStructure, I'm not sure)

Thanks!
  // mspieg: matinfo no longer includes sizes in petsc-dev
   MatInfo this_info, other_info;
   MatGetInfo(*(this->A), MAT_GLOBAL_SUM, &this_info);
   MatGetInfo(*A.mat(),   MAT_GLOBAL_SUM, &other_info);
   PetscInt this_m, this_n, other_m, other_n;
   MatGetSize(*(this->A),&this_m,&this_n);
   MatGetSize(*(this->A),&other_m,&other_n);

   return this_info.nz_allocated   == other_info.nz_allocated   && \
          this_n == other_n && \
          this_m  == other_m;

However as you say I am not sure this is enough to determine the same nonzero patter. As a side note we also store the size of the global matrix so we probably do not have to call PETSc for this.

Should we include more comparisions from the MatInfo, memory, blocksize?

This should be left to the user,

void PETScMatrix::axpy(double a, const GenericMatrix& A, bool same_nonzero_pattern = false);

The test for the non-zero pattern doesn't look robust to me. I would expect that if there was an efficient, robust test to compare sparsity patterns that PETSc would perform this.

Also, there is a problem with the code in PETScMatrix::axpy(..). Instead of

  dolfin_assert(sameNonzeroPattern(*AA));
  MatAXPY(*(this->A), a, *AA->mat(), SAME_NONZERO_PATTERN);

it should be

  if (sameNonzeroPattern(*AA))
    MatAXPY(*(this->A), a, *AA->mat(), SAME_NONZERO_PATTERN);
  else
    MatAXPY(*(this->A), a, *AA->mat(), DIFFERENT_NONZERO_PATTERN);

Garth


Johan

cheers
marc

On Mar 4, 2009, at 2:50 PM, Johan Hake wrote:
On Wednesday 04 March 2009 20:16:56 Garth N. Wells wrote:
Johan Hake wrote:
On Wednesday 04 March 2009 12:46:10 DOLFIN wrote:
One or more new changesets pushed to the primary dolfin repository.
A short summary of the last three changesets is included below.

changeset:   5791:7b24d1479dff485f4db0ba38c2e28984a0a3cf46
tag:         tip
user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
date:        Wed Mar 04 11:33:23 2009 +0000
files:       dolfin/la/PETScKrylovSolver.cpp
dolfin/la/PETScKrylovSolver.h dolfin/la/PETScMatrix.cpp
dolfin/la/PETScMatrix.h
dolfin/la/PETScPreconditioner.cpp dolfin/la/PETScPreconditioner.h
description:
Fixes for PETSc 2.3.3 compatibility.
This commit broke the linear algebra test for PETSc matrices. The
check
for the sparsity pattern is commented out, and en error is raised
instead. Is it not possible to check the non zero pattern for PETSc
matrices in 3.0?
The same check doesn't work with PETSc 3.0 because of changes to
MatInfo.
Ok.

The check is not pretty so we should find a better solution if this
function is required.
I think it would be nice to have it, as PETSc can do some
optimalizations if
two matrices have the same pattern.

There is a PETSc function
MatGetSeqNonzeroStructure which may help, but I haven't had time
to look
at it.
Haven't looked to deep into MatGetSeqNonzeroStructure. But it
sounds like it
gives the nonzero sparsity pattern which we really are not
interested in.

Why is the function PETScMatrix::sameNonzeroPattern required? It's
not
implemented for all backends.
When I implemented the axpy function I added this test. I do check
the nonzero
pattern for EpetraMatrices too, but there I only do it once, so no
extra
function.

I think we should be able to still use the MatInfo structure, but
maybe some
guidence from the PETSc developers could help?

Johan

Garth

Johan

changeset:   5790:05d6f03e87a8bb33cc5dc55add40e8de1c6ebfd0
user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
date:        Wed Mar 04 11:21:41 2009 +0000
files:       dolfin/la/PETScKrylovMatrix.cpp
dolfin/la/PETScKrylovSolver.cpp dolfin/la/PETScKrylovSolver.h
dolfin/la/PETScLUSolver.cpp dolfin/la/PETScMatrix.cpp
dolfin/la/PETScMatrix.h dolfin/la/PETScPreconditioner.cpp
dolfin/la/PETScPreconditioner.h description:
PETSc 3 updates.


changeset:   5789:3abcc647c6141cc4b2fd035cc417eedf80872ae7
user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
date:        Wed Mar 04 10:45:44 2009 +0000
files:       dolfin/la/PETScKrylovSolver.cpp
description:
Some updates for PETSc 3.

-------------------------------------------------------------------
---
For more details, visit http://www.fenics.org/hg/dolfin
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev
----------------------------------------------------
Marc Spiegelman
Lamont-Doherty Earth Observatory
Dept. of Applied Physics/Applied Math
Columbia University
http://www.ldeo.columbia.edu/~mspieg
tel: 845 704 2323 (SkypeIn)
----------------------------------------------------






Follow ups

References