PETSC_EXTERN PetscErrorCode MatMFFDSetBase_MFFD(Mat J,Vec U,Vec F) { PetscErrorCode ierr; MatMFFD ctx = (MatMFFD)J->data; PetscFunctionBegin; ierr = MatMFFDResetHHistory(J);CHKERRQ(ierr); if (!ctx->current_u) { ierr = VecDuplicate(U,&ctx->current_u);CHKERRQ(ierr); ierr = VecLockReadPush(ctx->current_u);CHKERRQ(ierr); } ierr = VecLockReadPop(ctx->current_u);CHKERRQ(ierr); ierr = VecCopy(U,ctx->current_u);CHKERRQ(ierr); ierr = VecLockReadPush(ctx->current_u);CHKERRQ(ierr); if (F) { if (ctx->current_f_allocated) {ierr = VecDestroy(&ctx->current_f);CHKERRQ(ierr);} ctx->current_f = F; ctx->current_f_allocated = PETSC_FALSE; } else if (!ctx->current_f_allocated) { ierr = MatCreateVecs(J,NULL,&ctx->current_f);CHKERRQ(ierr); ctx->current_f_allocated = PETSC_TRUE; } if (!ctx->w) { ierr = VecDuplicate(ctx->current_u,&ctx->w);CHKERRQ(ierr); } J->assembled = PETSC_TRUE; PetscFunctionReturn(0); }
/* MatAssemblyEnd_MFFD - Resets the ctx->ncurrenth to zero. This allows the user to indicate the beginning of a new linear solve by calling MatAssemblyXXX() on the matrix free matrix. This then allows the MatCreateMFFD_WP() to properly compute ||U|| only the first time in the linear solver rather than every time. This function is referenced directly from MatAssemblyEnd_SNESMF(), which may be in a different shared library hence it must be labeled as PETSC_EXTERN */ PETSC_EXTERN PetscErrorCode MatAssemblyEnd_MFFD(Mat J,MatAssemblyType mt) { PetscErrorCode ierr; MatMFFD j = (MatMFFD)J->data; PetscFunctionBegin; ierr = MatMFFDResetHHistory(J);CHKERRQ(ierr); j->vshift = 0.0; j->vscale = 1.0; PetscFunctionReturn(0); }
void PETSC_STDCALL matmffdresethhistory_(Mat J, int *__ierr ){ *__ierr = MatMFFDResetHHistory( (Mat)PetscToPointer((J) )); }