[petsc-users] Extracting Vec from VecNest
Vijay S. Mahadevan
vijay.m at gmail.com
Wed Feb 27 18:50:14 CST 2013
Always give the full error message and use error checking for PETSc
functions. (CHKERRQ, CHKERRABORT)
The VecGetSubVector routine expects the entire index set for the
component vector you need i.e., size of isset should be equal to size
of the vector. Instead you are asking for the reference to the first
component of the sub-vector in VecNest. This not possible.
> What's the proper way of extracting components?
For getting a single sub-component, it might be appropriate to use
VecNestGetSubVec but you are tying yourself too closely to the VecNest
data type.
For example:
VecNestGetSubVec(x, n, &sub_x);
Vijay
On Wed, Feb 27, 2013 at 6:09 PM, Amneet Bhalla <mail2amneet at gmail.com> wrote:
> I have packaged few vectors into a single Vec. I want to extract
> components of this composite Vec at some time in the code. Doing things
> this way is giving me an error.
>
> static const int NO_COMPS = ...;
> Vec array_x[NO_COMPS] = {.....};
> Vec x;
> VecCreateNest(PETSC_COMM_WORLD, NO_COMPS, PETSC_NULL, array_x, &x);
>
> for(int n = 0; n < NO_COMPS; ++n)
> {
> Vec sub_x;
> IS iset;
> ISCreateGeneral(PETSC_COMM_WORLD, 1, &n, PETSC_COPY_VALUES, &iset);
>
> VecGetSubVector(x, iset, &sub_x);
> //ERROR: Index set not found in nested Vec!
>
> ISDestroy(&iset);
>
> }
>
> What's the proper way of extracting components?
>
> --
> Amneet
>
>
>
More information about the petsc-users
mailing list