[petsc-dev] [petsc-users] MATNEST with shell matrices

Jed Brown jedbrown at mcs.anl.gov
Fri Mar 1 23:56:15 CST 2013


I already explained the issue with VecValidValues and suggested a possible
resolution. You're welcome to submit a patch, otherwise I'll get to it
eventually.


On Fri, Mar 1, 2013 at 8:00 PM, Amneet Bhalla <mail2amneet at gmail.com> wrote:

> Vijay I am running things on single processor.
>
> Is my understanding of creation of temporary Vec vt1 right in previous
> email? Also shouldn't all
> temporary Vecs be generated via user-defined function for MatShell, where
> one can get chance to adjust shell Vecs.
>
> On Fri, Mar 1, 2013 at 6:31 PM, Vijay S. Mahadevan <vijay.m at gmail.com>wrote:
>
>> Amneet, are you witnessing these errors in parallel alone, by any chance ?
>>
>> The reason I ask is because one of the tests using VecNest (with
>> Get/Set SubVec = vec/examples/tests/ex41.c) fails in parallel and I
>> have a patch to fix this (attached). The primary issue is that calls
>> to SetSubVec create a mismatch in numbering of the IS maintained by
>> the VecNest structure which gets propagated by VecDuplicate. This only
>> happens in parallel though because the local numbering of the IS is
>> what gets modified wrongly. It might be a separate unrelated issue to
>> yours but cannot confirm for sure.
>>
>> Jed can you please review this patch. If it works, feel free to push
>> after testing on ex41.c. I also have a variation of ex41 that is a
>> little more rigorous but I can send that to you in a separate patch.
>>
>> Vijay
>>
>> On Fri, Mar 1, 2013 at 5:05 PM, Amneet Bhalla <mail2amneet at gmail.com>
>> wrote:
>> > Jed this is output from gdb:
>> >
>> > #0  0x0000000000000000 in ?? ()
>> > #1  0x00000000009857fd in VecGetArrayRead (x=0x33ba0b0,
>> a=0x7fff1f0cf100) at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/include/petsc-private/vecimpl.h:350
>> > #2  0x000000000098f67f in VecGetArray_Nest (X=0x33c0850,
>> x=0x7fff1f0cf200)
>> > at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/src/vec/vec/impls/nest/vecnest.c:719
>> > #3  0x0000000000a3f4df in VecGetArrayRead (x=0x33c0850,
>> a=0x7fff1f0cf200) at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/include/petsc-private/vecimpl.h:350
>> > #4  0x0000000000a51d83 in MatMult (mat=0x326e480, x=0x33150c0,
>> y=0x33c0850)
>> > at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/src/mat/interface/matrix.c:2092
>> > #5  0x00000000012b2b78 in KSPInitialResidual (ksp=0x32f6bb0,
>> > vsoln=0x33150c0, vt1=0x33c0850, vt2=0x33d3c60, vres=0x33e6d30,
>> vb=0x3328710)
>> > at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/src/ksp/ksp/interface/itres.c:54
>> > #6  0x0000000000da2faa in KSPSolve_GMRES (ksp=0x32f6bb0) at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/src/ksp/ksp/impls/gmres/gmres.c:230
>> > #7  0x0000000000d1ae6b in KSPSolve (ksp=0x32f6bb0, b=0x3328710,
>> x=0x33150c0)
>> > at
>> >
>> /home/amneet/SOFTWARES/LIBRARIESIBAMR/PETSc-3.3-Lite/src/ksp/ksp/interface/itfunc.c:446
>> > #8  0x00000000006b8b0a in
>> IBTK::PETScBlockKrylovLinearSolver::solveSystem
>> > (this=0x31f4310, x=0x329ed20, b=0x32b75d0) at
>> > PETScBlockKrylovLinearSolver.C:381
>> > #9  0x00000000005777e3 in main (argc=5, argv=0x7fff1f0d3468) at
>> main.C:274
>> >
>> > In frame 5, there is call to function
>> >  PetscErrorCode  KSPInitialResidual(KSP ksp,Vec vsoln,Vec vt1,Vec
>> vt2,Vec
>> > vres,Vec vb)
>> >
>> > which calls the matrix-vector function in frame 4, i.e,
>> > ierr = KSP_MatMult(ksp,Amat,vsoln,vt1);CHKERRQ(ierr);
>> >
>> > Now the error comes in frame 4, where there is call to
>> > VecValidValues(y,3,PETSC_FALSE); y being vt1, a temporary left Vec to
>> hold
>> > value
>> > of user-defined matrix vector product.
>> >
>> > I have passed a user-defined function to tell MatShell how to create
>> > left/right Vec(s);
>> > where I also set left/right->ops->getarray = PETSC_NULL. If vt1 was
>> created
>> > using
>> > this routine, there would not have been any error related to
>> > VecGetArrayRead routine
>> > and should have printed some tracer printf statements. So my guess is
>> that
>> > this temporary
>> > vector is created by directly calling VecDuplicate routine which sets
>> >  vec->ops->getarray = VecGetArray_Nest by default.
>> >
>> >
>> > On Fri, Mar 1, 2013 at 1:07 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>> >>>
>> >>> Where should this routine be added and how should it look like for
>> shell
>> >>> vectors? I had assumed that
>> >>> such changes should be done in user defined MatGetVecs routine.
>> Clearly
>> >>> this is not happening.
>> >>
>> >>
>> >> Please explain.
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Amneet
>> >
>> >
>> >
>>
>
>
>
> --
> Amneet
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130302/6c937ea8/attachment.html>


More information about the petsc-dev mailing list