[petsc-dev] bug in TS

Barry Smith bsmith at mcs.anl.gov
Thu Sep 12 13:34:23 CDT 2013


  If A is B then ts->Arhs ends up not being ts->Brhs  Thus when the RHSJacobian function of the user is called it is called with two different matrices. If the use does not fill up BOTH matrices then bad stuff happens. For example my normal model is fill up to B and call MatAssemblyBegin/End() on A but this means A is left empty.

  A short term fix for me is to change this code to generate the same Arhs and Brhs if A is B.  But this needs proper fixing.  In fact this whole system of creating the matrices for TS is a bit convoluted and confusing; ideally it would simpler and clearer.

   Barry


#undef __FUNCT__
#define __FUNCT__ "TSGetRHSMats_Private"
static PetscErrorCode TSGetRHSMats_Private(TS ts,Mat *Arhs,Mat *Brhs)
{
  Mat            A,B;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  ierr = TSGetIJacobian(ts,&A,&B,NULL,NULL);CHKERRQ(ierr);
  if (Arhs) {
    if (!ts->Arhs) {
      ierr = MatDuplicate(A,MAT_DO_NOT_COPY_VALUES,&ts->Arhs);CHKERRQ(ierr);
    }
    *Arhs = ts->Arhs;
  }
  if (Brhs) {
    if (!ts->Brhs) {
      ierr = MatDuplicate(B,MAT_DO_NOT_COPY_VALUES,&ts->Brhs);CHKERRQ(ierr);
    }
    *Brhs = ts->Brhs;
  }
  PetscFunctionReturn(0);
}




More information about the petsc-dev mailing list