[petsc-users] question about arbitrary eigenvector selection in SLEPC
Matthew Knepley
knepley at gmail.com
Thu May 29 12:01:30 CDT 2014
On Thu, May 29, 2014 at 10:58 AM, Giacomo Mulas <gmulas at oa-cagliari.inaf.it>
wrote:
> On Thu, 29 May 2014, Matthew Knepley wrote:
>
> There might be an easier way to do this:
>> PetscScalar val = 0.0, gval;
>>
>> VecGetOwnershipRange(xr, &low, &high);
>> if ((myindex >= low) && (myindex < high)) {
>> VecGetArray(localx1,&a);
>> val = a[myindex-low];
>> VecRestoreArray(localx1, &a);
>> }
>> MPI_Allreduce(&val, &gval, 1, MPIU_SCALAR, MPI_SUM, PETSC_COMM_WORLD);
>>
>> Now everyone has the value at myindex.
>>
>
> brilliant, why didn't I think of this? Only, I guess you were
> copying/pasting and some variable names slipped, namely localx instead of
> xr. Should it be
>
Yes
Matt
> PetscScalar val = 0.0, gval;
> PetscScalar *a;
>
> VecGetOwnershipRange(xr, &low, &high);
> if ((myindex >= low) && (myindex < high)) {
> VecGetArray(xr,&a);
> val = a[myindex-low]; VecRestoreArray(xr, &a);
> }
> MPI_Allreduce(&val, &gval, 1, MPIU_SCALAR, MPI_SUM, PETSC_COMM_WORLD);
> *rr = gval*gval;
> *ri = 0;
>
> ?
>
> Thanks!
> Giacomo
>
> --
> _________________________________________________________________
>
> Giacomo Mulas <gmulas at oa-cagliari.inaf.it>
> _________________________________________________________________
>
> INAF - Osservatorio Astronomico di Cagliari
> via della scienza 5 - 09047 Selargius (CA)
>
> tel. +39 070 71180244
> mob. : +39 329 6603810
> _________________________________________________________________
>
> "When the storms are raging around you, stay right where you are"
> (Freddy Mercury)
> _________________________________________________________________
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140529/424ab582/attachment.html>
More information about the petsc-users
mailing list