[petsc-dev] State restriction of snes solutions without rscale

Jed Brown jed at jedbrown.org
Tue Feb 24 10:07:34 CST 2015


Lawrence Mitchell <lawrence.mitchell at imperial.ac.uk> writes:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
>
> I provide both the state restriction matrix (DMCreateInjection) along
> with residual transfer (DMCreateInterpolation), and therefore don't
> provide the (optional) scaling vector in DMCreateInterpolation.
> However, DMRestrictHook_SNESVecSol, called indirectly during
> SNESSolve_FAS just does:
>
>   ierr = MatRestrict(Restrict,Xfine,Xcoarse);CHKERRQ(ierr);
>   ierr = VecPointwiseMult(Xcoarse,Xcoarse,Rscale);CHKERRQ(ierr);
>
> Which fails if Rscale hasn't been provided.
>
> How about using the Inject matrix first if the user has provided it?
> Something like:

Yes, Inject should be preferred.

> diff --git a/src/snes/interface/snes.c b/src/snes/interface/snes.c
> index cc9cc30..d037650 100644
> - --- a/src/snes/interface/snes.c
> +++ b/src/snes/interface/snes.c
> @@ -481,8 +481,12 @@ static PetscErrorCode
> DMRestrictHook_SNESVecSol(DM dmfine,Mat Restrict,Vec Rscal
>      Xfine = Xfine_named;
>    }
>    ierr =
> DMGetNamedGlobalVector(dmcoarse,"SNESVecSol",&Xcoarse);CHKERRQ(ierr);
> - -  ierr = MatRestrict(Restrict,Xfine,Xcoarse);CHKERRQ(ierr);
> - -  ierr = VecPointwiseMult(Xcoarse,Xcoarse,Rscale);CHKERRQ(ierr);
> +  if (Inject) {
> +    ierr = MatRestrict(Inject,Xfine,Xcoarse);CHKERRQ(ierr);
> +  } else {
> +    ierr = MatRestrict(Restrict,Xfine,Xcoarse);CHKERRQ(ierr);
> +    ierr = VecPointwiseMult(Xcoarse,Xcoarse,Rscale);CHKERRQ(ierr);
> +  }
>    ierr =
> DMRestoreNamedGlobalVector(dmcoarse,"SNESVecSol",&Xcoarse);CHKERRQ(ierr);
>    if (Xfine_named) {ierr =
> DMRestoreNamedGlobalVector(dmfine,"SNESVecSol",&Xfine_named);CHKERRQ(ierr);}
>    PetscFunctionReturn(0);
>
> Cheers,
>
> Lawrence
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
>
> iQEcBAEBAgAGBQJU7J7KAAoJECOc1kQ8PEYvcVUIAMo30Dxz1FfwwNA2UK2UOl4c
> hoUunk3JY5N3B/K6rWRtj2UOQ7u8/pOx+p2xqX7G4r25Raa55FqxVGjvOX5gTcgC
> Qe2BSGNzgaUlK02NCMdNhJxZ5WUpmId+d3QcCWG23So35J4FWW6CkI3UEPq5k+Wq
> Qeznojk3gStymPZv8I+XRM8pINBLAFZR6j0XhaR9RUuW/TTOcb0aVoZNTwOFqx7l
> pxwEH69DcQ4taYgyo0arIB8e20dizUn6yptWucw9aSEAT+2NcFlF0d3RIdqwfz6E
> sqd6Xj+ZcsWgCeXAf65DiqJTvoSLNOmQhvv17ZB/zzLeGMom2oSp65v2IznVDk0=
> =iKrZ
> -----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20150224/bf6e51d1/attachment.sig>


More information about the petsc-dev mailing list