124989b8cSPeter Brune #include <petsc-private/tsimpl.h> /*I "petscts.h" I*/ 207475bc1SBarry Smith #include <petsc-private/dmimpl.h> 324989b8cSPeter Brune 4d74926cbSBarry Smith #undef __FUNCT__ 5d74926cbSBarry Smith #define __FUNCT__ "DMTSDestroy" 6d74926cbSBarry Smith static PetscErrorCode DMTSDestroy(DMTS *kdm) 7d74926cbSBarry Smith { 8d74926cbSBarry Smith PetscErrorCode ierr; 9d74926cbSBarry Smith 10d74926cbSBarry Smith PetscFunctionBegin; 11d74926cbSBarry Smith if (!*kdm) PetscFunctionReturn(0); 12d74926cbSBarry Smith PetscValidHeaderSpecific((*kdm),DMTS_CLASSID,1); 13d74926cbSBarry Smith if (--((PetscObject)(*kdm))->refct > 0) {*kdm = 0; PetscFunctionReturn(0);} 14d74926cbSBarry Smith if ((*kdm)->ops->destroy) {ierr = ((*kdm)->ops->destroy)(*kdm);CHKERRQ(ierr);} 15d74926cbSBarry Smith ierr = PetscHeaderDestroy(kdm);CHKERRQ(ierr); 16d74926cbSBarry Smith PetscFunctionReturn(0); 17d74926cbSBarry Smith } 18d74926cbSBarry Smith 19d74926cbSBarry Smith #undef __FUNCT__ 202d53ad75SBarry Smith #define __FUNCT__ "DMTSLoad" 212d53ad75SBarry Smith PetscErrorCode DMTSLoad(DMTS kdm,PetscViewer viewer) 222d53ad75SBarry Smith { 232d53ad75SBarry Smith PetscErrorCode ierr; 242d53ad75SBarry Smith 252d53ad75SBarry Smith PetscFunctionBegin; 262d53ad75SBarry Smith ierr = PetscViewerBinaryRead(viewer,&kdm->ops->ifunction,1,PETSC_FUNCTION);CHKERRQ(ierr); 27ad6bc421SBarry Smith ierr = PetscViewerBinaryRead(viewer,&kdm->ops->ifunctionview,1,PETSC_FUNCTION);CHKERRQ(ierr); 28ad6bc421SBarry Smith ierr = PetscViewerBinaryRead(viewer,&kdm->ops->ifunctionload,1,PETSC_FUNCTION);CHKERRQ(ierr); 29ad6bc421SBarry Smith if (kdm->ops->ifunctionload) { 30ad6bc421SBarry Smith ierr = (*kdm->ops->ifunctionload)(&kdm->ifunctionctx,viewer);CHKERRQ(ierr); 31ad6bc421SBarry Smith } 322d53ad75SBarry Smith ierr = PetscViewerBinaryRead(viewer,&kdm->ops->ijacobian,1,PETSC_FUNCTION);CHKERRQ(ierr); 33ad6bc421SBarry Smith ierr = PetscViewerBinaryRead(viewer,&kdm->ops->ijacobianview,1,PETSC_FUNCTION);CHKERRQ(ierr); 34ad6bc421SBarry Smith ierr = PetscViewerBinaryRead(viewer,&kdm->ops->ijacobianload,1,PETSC_FUNCTION);CHKERRQ(ierr); 35ad6bc421SBarry Smith if (kdm->ops->ijacobianload) { 36ad6bc421SBarry Smith ierr = (*kdm->ops->ijacobianload)(&kdm->ijacobianctx,viewer);CHKERRQ(ierr); 37ad6bc421SBarry Smith } 382d53ad75SBarry Smith PetscFunctionReturn(0); 392d53ad75SBarry Smith } 402d53ad75SBarry Smith 412d53ad75SBarry Smith #undef __FUNCT__ 422d53ad75SBarry Smith #define __FUNCT__ "DMTSView" 432d53ad75SBarry Smith PetscErrorCode DMTSView(DMTS kdm,PetscViewer viewer) 442d53ad75SBarry Smith { 452d53ad75SBarry Smith PetscErrorCode ierr; 462d53ad75SBarry Smith PetscBool isascii,isbinary; 472d53ad75SBarry Smith 482d53ad75SBarry Smith PetscFunctionBegin; 492d53ad75SBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); 502d53ad75SBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERBINARY,&isbinary);CHKERRQ(ierr); 512d53ad75SBarry Smith if (isascii) { 52c7a10e08SBarry Smith #if defined(PETSC_SERIALIZE_FUNCTIONS) 532d53ad75SBarry Smith const char *fname; 542d53ad75SBarry Smith 552d53ad75SBarry Smith ierr = PetscFPTFind(kdm->ops->ifunction,&fname);CHKERRQ(ierr); 562d53ad75SBarry Smith if (fname) { 572d53ad75SBarry Smith ierr = PetscViewerASCIIPrintf(viewer," IFunction used by TS: %s\n",fname);CHKERRQ(ierr); 582d53ad75SBarry Smith } 592d53ad75SBarry Smith ierr = PetscFPTFind(kdm->ops->ijacobian,&fname);CHKERRQ(ierr); 602d53ad75SBarry Smith if (fname) { 612d53ad75SBarry Smith ierr = PetscViewerASCIIPrintf(viewer," IJacobian function used by TS: %s\n",fname);CHKERRQ(ierr); 622d53ad75SBarry Smith } 63c7a10e08SBarry Smith #endif 642d53ad75SBarry Smith } else if (isbinary) { 6598da9c48SSatish Balay ierr = PetscViewerBinaryWrite(viewer,(void*)kdm->ops->ifunction,1,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr); 6698da9c48SSatish Balay ierr = PetscViewerBinaryWrite(viewer,(void*)kdm->ops->ifunctionview,1,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr); 6798da9c48SSatish Balay ierr = PetscViewerBinaryWrite(viewer,(void*)kdm->ops->ifunctionload,1,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr); 68ad6bc421SBarry Smith if (kdm->ops->ifunctionview) { 69ad6bc421SBarry Smith ierr = (*kdm->ops->ifunctionview)(kdm->ifunctionctx,viewer);CHKERRQ(ierr); 70ad6bc421SBarry Smith } 7198da9c48SSatish Balay ierr = PetscViewerBinaryWrite(viewer,(void*)kdm->ops->ijacobian,1,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr); 7298da9c48SSatish Balay ierr = PetscViewerBinaryWrite(viewer,(void*)kdm->ops->ijacobianview,1,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr); 7398da9c48SSatish Balay ierr = PetscViewerBinaryWrite(viewer,(void*)kdm->ops->ijacobianload,1,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr); 74ad6bc421SBarry Smith if (kdm->ops->ijacobianview) { 75ad6bc421SBarry Smith ierr = (*kdm->ops->ijacobianview)(kdm->ijacobianctx,viewer);CHKERRQ(ierr); 76ad6bc421SBarry Smith } 772d53ad75SBarry Smith } 782d53ad75SBarry Smith PetscFunctionReturn(0); 792d53ad75SBarry Smith } 802d53ad75SBarry Smith 812d53ad75SBarry Smith #undef __FUNCT__ 82d74926cbSBarry Smith #define __FUNCT__ "DMTSCreate" 83d74926cbSBarry Smith static PetscErrorCode DMTSCreate(MPI_Comm comm,DMTS *kdm) 84d74926cbSBarry Smith { 85d74926cbSBarry Smith PetscErrorCode ierr; 86d74926cbSBarry Smith 87d74926cbSBarry Smith PetscFunctionBegin; 88519f805aSKarl Rupp #if !defined(PETSC_USE_DYNAMIC_LIBRARIES) 890298fd71SBarry Smith ierr = TSInitializePackage(NULL);CHKERRQ(ierr); 90d74926cbSBarry Smith #endif 91*67c2884eSBarry Smith ierr = PetscHeaderCreate(*kdm, _p_DMTS, struct _DMTSOps, DMTS_CLASSID, "DMTS", "DMTS", "DMTS", comm, DMTSDestroy, DMTSView);CHKERRQ(ierr); 92d74926cbSBarry Smith ierr = PetscMemzero((*kdm)->ops, sizeof(struct _DMTSOps));CHKERRQ(ierr); 93d74926cbSBarry Smith PetscFunctionReturn(0); 94d74926cbSBarry Smith } 9524989b8cSPeter Brune 9624989b8cSPeter Brune #undef __FUNCT__ 97942e3340SBarry Smith #define __FUNCT__ "DMCoarsenHook_DMTS" 982a34c10cSBarry Smith /* Attaches the DMTS to the coarse level. 9924989b8cSPeter Brune * Under what conditions should we copy versus duplicate? 10024989b8cSPeter Brune */ 101942e3340SBarry Smith static PetscErrorCode DMCoarsenHook_DMTS(DM dm,DM dmc,void *ctx) 10224989b8cSPeter Brune { 10324989b8cSPeter Brune PetscErrorCode ierr; 10424989b8cSPeter Brune 10524989b8cSPeter Brune PetscFunctionBegin; 106942e3340SBarry Smith ierr = DMCopyDMTS(dm,dmc);CHKERRQ(ierr); 10724989b8cSPeter Brune PetscFunctionReturn(0); 10824989b8cSPeter Brune } 10924989b8cSPeter Brune 11024989b8cSPeter Brune #undef __FUNCT__ 111942e3340SBarry Smith #define __FUNCT__ "DMRestrictHook_DMTS" 11224989b8cSPeter Brune /* This could restrict auxiliary information to the coarse level. 11324989b8cSPeter Brune */ 114942e3340SBarry Smith static PetscErrorCode DMRestrictHook_DMTS(DM dm,Mat Restrict,Vec rscale,Mat Inject,DM dmc,void *ctx) 11524989b8cSPeter Brune { 11624989b8cSPeter Brune 11724989b8cSPeter Brune PetscFunctionBegin; 11824989b8cSPeter Brune PetscFunctionReturn(0); 11924989b8cSPeter Brune } 12024989b8cSPeter Brune 12124989b8cSPeter Brune #undef __FUNCT__ 122258e1594SPeter Brune #define __FUNCT__ "DMSubDomainHook_DMTS" 123258e1594SPeter Brune static PetscErrorCode DMSubDomainHook_DMTS(DM dm,DM subdm,void *ctx) 124258e1594SPeter Brune { 125258e1594SPeter Brune PetscErrorCode ierr; 126258e1594SPeter Brune 127258e1594SPeter Brune PetscFunctionBegin; 128258e1594SPeter Brune ierr = DMCopyDMTS(dm,subdm);CHKERRQ(ierr); 129258e1594SPeter Brune PetscFunctionReturn(0); 130258e1594SPeter Brune } 131258e1594SPeter Brune 132258e1594SPeter Brune #undef __FUNCT__ 133258e1594SPeter Brune #define __FUNCT__ "DMSubDomainRestrictHook_DMTS" 134258e1594SPeter Brune /* This could restrict auxiliary information to the coarse level. 135258e1594SPeter Brune */ 136258e1594SPeter Brune static PetscErrorCode DMSubDomainRestrictHook_DMTS(DM dm,VecScatter gscat,VecScatter lscat,DM subdm,void *ctx) 137258e1594SPeter Brune { 138258e1594SPeter Brune PetscFunctionBegin; 139258e1594SPeter Brune PetscFunctionReturn(0); 140258e1594SPeter Brune } 141258e1594SPeter Brune 142258e1594SPeter Brune #undef __FUNCT__ 143d74926cbSBarry Smith #define __FUNCT__ "DMTSCopy" 144d74926cbSBarry Smith /*@C 145d74926cbSBarry Smith DMTSCopy - copies the information in a DMTS to another DMTS 146d74926cbSBarry Smith 147d74926cbSBarry Smith Not Collective 148d74926cbSBarry Smith 149d74926cbSBarry Smith Input Argument: 150d74926cbSBarry Smith + kdm - Original DMTS 151d74926cbSBarry Smith - nkdm - DMTS to receive the data, should have been created with DMTSCreate() 152d74926cbSBarry Smith 153d74926cbSBarry Smith Level: developer 154d74926cbSBarry Smith 155d74926cbSBarry Smith .seealso: DMTSCreate(), DMTSDestroy() 156d74926cbSBarry Smith @*/ 157d74926cbSBarry Smith PetscErrorCode DMTSCopy(DMTS kdm,DMTS nkdm) 15824989b8cSPeter Brune { 15924989b8cSPeter Brune PetscErrorCode ierr; 16024989b8cSPeter Brune 16124989b8cSPeter Brune PetscFunctionBegin; 162d74926cbSBarry Smith PetscValidHeaderSpecific(kdm,DMTS_CLASSID,1); 163d74926cbSBarry Smith PetscValidHeaderSpecific(nkdm,DMTS_CLASSID,2); 164d74926cbSBarry Smith nkdm->ops->rhsfunction = kdm->ops->rhsfunction; 165d74926cbSBarry Smith nkdm->ops->rhsjacobian = kdm->ops->rhsjacobian; 166d74926cbSBarry Smith nkdm->ops->ifunction = kdm->ops->ifunction; 167d74926cbSBarry Smith nkdm->ops->ijacobian = kdm->ops->ijacobian; 168d74926cbSBarry Smith nkdm->ops->solution = kdm->ops->solution; 169d74926cbSBarry Smith nkdm->ops->destroy = kdm->ops->destroy; 170d74926cbSBarry Smith nkdm->ops->duplicate = kdm->ops->duplicate; 171d74926cbSBarry Smith 172d74926cbSBarry Smith nkdm->rhsfunctionctx = kdm->rhsfunctionctx; 173d74926cbSBarry Smith nkdm->rhsjacobianctx = kdm->rhsjacobianctx; 174d74926cbSBarry Smith nkdm->ifunctionctx = kdm->ifunctionctx; 175d74926cbSBarry Smith nkdm->ijacobianctx = kdm->ijacobianctx; 176d74926cbSBarry Smith nkdm->solutionctx = kdm->solutionctx; 177d74926cbSBarry Smith 178d74926cbSBarry Smith nkdm->data = kdm->data; 179d74926cbSBarry Smith 180d74926cbSBarry Smith /* 181d74926cbSBarry Smith nkdm->fortran_func_pointers[0] = kdm->fortran_func_pointers[0]; 182d74926cbSBarry Smith nkdm->fortran_func_pointers[1] = kdm->fortran_func_pointers[1]; 183d74926cbSBarry Smith nkdm->fortran_func_pointers[2] = kdm->fortran_func_pointers[2]; 184d74926cbSBarry Smith */ 185d74926cbSBarry Smith 186d74926cbSBarry Smith /* implementation specific copy hooks */ 187d74926cbSBarry Smith if (kdm->ops->duplicate) {ierr = (*kdm->ops->duplicate)(kdm,nkdm);CHKERRQ(ierr);} 18824989b8cSPeter Brune PetscFunctionReturn(0); 18924989b8cSPeter Brune } 19024989b8cSPeter Brune 19124989b8cSPeter Brune #undef __FUNCT__ 192942e3340SBarry Smith #define __FUNCT__ "DMGetDMTS" 19324989b8cSPeter Brune /*@C 194942e3340SBarry Smith DMGetDMTS - get read-only private DMTS context from a DM 19524989b8cSPeter Brune 19624989b8cSPeter Brune Not Collective 19724989b8cSPeter Brune 19824989b8cSPeter Brune Input Argument: 19924989b8cSPeter Brune . dm - DM to be used with TS 20024989b8cSPeter Brune 20124989b8cSPeter Brune Output Argument: 202942e3340SBarry Smith . tsdm - private DMTS context 20324989b8cSPeter Brune 20424989b8cSPeter Brune Level: developer 20524989b8cSPeter Brune 20624989b8cSPeter Brune Notes: 207942e3340SBarry Smith Use DMGetDMTSWrite() if write access is needed. The DMTSSetXXX API should be used wherever possible. 20824989b8cSPeter Brune 209942e3340SBarry Smith .seealso: DMGetDMTSWrite() 21024989b8cSPeter Brune @*/ 211942e3340SBarry Smith PetscErrorCode DMGetDMTS(DM dm,DMTS *tsdm) 21224989b8cSPeter Brune { 21324989b8cSPeter Brune PetscErrorCode ierr; 21424989b8cSPeter Brune 21524989b8cSPeter Brune PetscFunctionBegin; 21624989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 2172a34c10cSBarry Smith *tsdm = (DMTS) dm->dmts; 218d74926cbSBarry Smith if (!*tsdm) { 219942e3340SBarry Smith ierr = PetscInfo(dm,"Creating new DMTS\n");CHKERRQ(ierr); 220d74926cbSBarry Smith ierr = DMTSCreate(((PetscObject)dm)->comm,tsdm);CHKERRQ(ierr); 2212a34c10cSBarry Smith dm->dmts = (PetscObject) *tsdm; 2220298fd71SBarry Smith ierr = DMCoarsenHookAdd(dm,DMCoarsenHook_DMTS,DMRestrictHook_DMTS,NULL);CHKERRQ(ierr); 2230298fd71SBarry Smith ierr = DMSubDomainHookAdd(dm,DMSubDomainHook_DMTS,DMSubDomainRestrictHook_DMTS,NULL);CHKERRQ(ierr); 22424989b8cSPeter Brune } 22524989b8cSPeter Brune PetscFunctionReturn(0); 22624989b8cSPeter Brune } 22724989b8cSPeter Brune 22824989b8cSPeter Brune #undef __FUNCT__ 229942e3340SBarry Smith #define __FUNCT__ "DMGetDMTSWrite" 23024989b8cSPeter Brune /*@C 231942e3340SBarry Smith DMGetDMTSWrite - get write access to private DMTS context from a DM 23224989b8cSPeter Brune 23324989b8cSPeter Brune Not Collective 23424989b8cSPeter Brune 23524989b8cSPeter Brune Input Argument: 23624989b8cSPeter Brune . dm - DM to be used with TS 23724989b8cSPeter Brune 23824989b8cSPeter Brune Output Argument: 239942e3340SBarry Smith . tsdm - private DMTS context 24024989b8cSPeter Brune 24124989b8cSPeter Brune Level: developer 24224989b8cSPeter Brune 243942e3340SBarry Smith .seealso: DMGetDMTS() 24424989b8cSPeter Brune @*/ 245942e3340SBarry Smith PetscErrorCode DMGetDMTSWrite(DM dm,DMTS *tsdm) 24624989b8cSPeter Brune { 24724989b8cSPeter Brune PetscErrorCode ierr; 248942e3340SBarry Smith DMTS sdm; 24924989b8cSPeter Brune 25024989b8cSPeter Brune PetscFunctionBegin; 25124989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 252942e3340SBarry Smith ierr = DMGetDMTS(dm,&sdm);CHKERRQ(ierr); 25324989b8cSPeter Brune if (!sdm->originaldm) sdm->originaldm = dm; 25424989b8cSPeter Brune if (sdm->originaldm != dm) { /* Copy on write */ 2552a34c10cSBarry Smith DMTS oldsdm = sdm; 256942e3340SBarry Smith ierr = PetscInfo(dm,"Copying DMTS due to write\n");CHKERRQ(ierr); 257d74926cbSBarry Smith ierr = DMTSCreate(((PetscObject)dm)->comm,&sdm);CHKERRQ(ierr); 258d74926cbSBarry Smith ierr = DMTSCopy(oldsdm,sdm);CHKERRQ(ierr); 2592a34c10cSBarry Smith ierr = DMTSDestroy((DMTS*)&dm->dmts);CHKERRQ(ierr); 2602a34c10cSBarry Smith dm->dmts = (PetscObject) sdm; 26124989b8cSPeter Brune } 26224989b8cSPeter Brune *tsdm = sdm; 26324989b8cSPeter Brune PetscFunctionReturn(0); 26424989b8cSPeter Brune } 26524989b8cSPeter Brune 26624989b8cSPeter Brune #undef __FUNCT__ 267942e3340SBarry Smith #define __FUNCT__ "DMCopyDMTS" 26824989b8cSPeter Brune /*@C 269942e3340SBarry Smith DMCopyDMTS - copies a DM context to a new DM 27024989b8cSPeter Brune 27124989b8cSPeter Brune Logically Collective 27224989b8cSPeter Brune 27324989b8cSPeter Brune Input Arguments: 27424989b8cSPeter Brune + dmsrc - DM to obtain context from 27524989b8cSPeter Brune - dmdest - DM to add context to 27624989b8cSPeter Brune 27724989b8cSPeter Brune Level: developer 27824989b8cSPeter Brune 27924989b8cSPeter Brune Note: 28024989b8cSPeter Brune The context is copied by reference. This function does not ensure that a context exists. 28124989b8cSPeter Brune 282942e3340SBarry Smith .seealso: DMGetDMTS(), TSSetDM() 28324989b8cSPeter Brune @*/ 284942e3340SBarry Smith PetscErrorCode DMCopyDMTS(DM dmsrc,DM dmdest) 28524989b8cSPeter Brune { 28624989b8cSPeter Brune PetscErrorCode ierr; 28724989b8cSPeter Brune 28824989b8cSPeter Brune PetscFunctionBegin; 28924989b8cSPeter Brune PetscValidHeaderSpecific(dmsrc,DM_CLASSID,1); 29024989b8cSPeter Brune PetscValidHeaderSpecific(dmdest,DM_CLASSID,2); 2912a34c10cSBarry Smith ierr = DMTSDestroy((DMTS*)&dmdest->dmts);CHKERRQ(ierr); 2922a34c10cSBarry Smith dmdest->dmts = dmsrc->dmts; 2932a34c10cSBarry Smith ierr = PetscObjectReference(dmdest->dmts);CHKERRQ(ierr); 2940298fd71SBarry Smith ierr = DMCoarsenHookAdd(dmdest,DMCoarsenHook_DMTS,DMRestrictHook_DMTS,NULL);CHKERRQ(ierr); 2950298fd71SBarry Smith ierr = DMSubDomainHookAdd(dmdest,DMSubDomainHook_DMTS,DMSubDomainRestrictHook_DMTS,NULL);CHKERRQ(ierr); 29624989b8cSPeter Brune PetscFunctionReturn(0); 29724989b8cSPeter Brune } 29824989b8cSPeter Brune 29924989b8cSPeter Brune #undef __FUNCT__ 30024989b8cSPeter Brune #define __FUNCT__ "DMTSSetIFunction" 30124989b8cSPeter Brune /*@C 30224989b8cSPeter Brune DMTSSetIFunction - set TS implicit function evaluation function 30324989b8cSPeter Brune 30424989b8cSPeter Brune Not Collective 30524989b8cSPeter Brune 30624989b8cSPeter Brune Input Arguments: 30724989b8cSPeter Brune + dm - DM to be used with TS 30824989b8cSPeter Brune . func - function evaluation function, see TSSetIFunction() for calling sequence 30924989b8cSPeter Brune - ctx - context for residual evaluation 31024989b8cSPeter Brune 31124989b8cSPeter Brune Level: advanced 31224989b8cSPeter Brune 31324989b8cSPeter Brune Note: 31424989b8cSPeter Brune TSSetFunction() is normally used, but it calls this function internally because the user context is actually 31524989b8cSPeter Brune associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 31624989b8cSPeter Brune not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 31724989b8cSPeter Brune 31824989b8cSPeter Brune .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 31924989b8cSPeter Brune @*/ 32024989b8cSPeter Brune PetscErrorCode DMTSSetIFunction(DM dm,TSIFunction func,void *ctx) 32124989b8cSPeter Brune { 32224989b8cSPeter Brune PetscErrorCode ierr; 323942e3340SBarry Smith DMTS tsdm; 32424989b8cSPeter Brune 32524989b8cSPeter Brune PetscFunctionBegin; 32624989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 327942e3340SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 328d74926cbSBarry Smith if (func) tsdm->ops->ifunction = func; 32924989b8cSPeter Brune if (ctx) tsdm->ifunctionctx = ctx; 33024989b8cSPeter Brune PetscFunctionReturn(0); 33124989b8cSPeter Brune } 33224989b8cSPeter Brune 33324989b8cSPeter Brune #undef __FUNCT__ 33424989b8cSPeter Brune #define __FUNCT__ "DMTSGetIFunction" 33524989b8cSPeter Brune /*@C 33624989b8cSPeter Brune DMTSGetIFunction - get TS implicit residual evaluation function 33724989b8cSPeter Brune 33824989b8cSPeter Brune Not Collective 33924989b8cSPeter Brune 34024989b8cSPeter Brune Input Argument: 34124989b8cSPeter Brune . dm - DM to be used with TS 34224989b8cSPeter Brune 34324989b8cSPeter Brune Output Arguments: 34424989b8cSPeter Brune + func - function evaluation function, see TSSetIFunction() for calling sequence 34524989b8cSPeter Brune - ctx - context for residual evaluation 34624989b8cSPeter Brune 34724989b8cSPeter Brune Level: advanced 34824989b8cSPeter Brune 34924989b8cSPeter Brune Note: 35024989b8cSPeter Brune TSGetFunction() is normally used, but it calls this function internally because the user context is actually 35124989b8cSPeter Brune associated with the DM. 35224989b8cSPeter Brune 35324989b8cSPeter Brune .seealso: DMTSSetContext(), DMTSSetFunction(), TSSetFunction() 35424989b8cSPeter Brune @*/ 35524989b8cSPeter Brune PetscErrorCode DMTSGetIFunction(DM dm,TSIFunction *func,void **ctx) 35624989b8cSPeter Brune { 35724989b8cSPeter Brune PetscErrorCode ierr; 358942e3340SBarry Smith DMTS tsdm; 35924989b8cSPeter Brune 36024989b8cSPeter Brune PetscFunctionBegin; 36124989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 362942e3340SBarry Smith ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr); 363d74926cbSBarry Smith if (func) *func = tsdm->ops->ifunction; 36424989b8cSPeter Brune if (ctx) *ctx = tsdm->ifunctionctx; 36524989b8cSPeter Brune PetscFunctionReturn(0); 36624989b8cSPeter Brune } 36724989b8cSPeter Brune 36824989b8cSPeter Brune 36924989b8cSPeter Brune #undef __FUNCT__ 37024989b8cSPeter Brune #define __FUNCT__ "DMTSSetRHSFunction" 37124989b8cSPeter Brune /*@C 37224989b8cSPeter Brune DMTSSetRHSFunction - set TS explicit residual evaluation function 37324989b8cSPeter Brune 37424989b8cSPeter Brune Not Collective 37524989b8cSPeter Brune 37624989b8cSPeter Brune Input Arguments: 37724989b8cSPeter Brune + dm - DM to be used with TS 37824989b8cSPeter Brune . func - RHS function evaluation function, see TSSetRHSFunction() for calling sequence 37924989b8cSPeter Brune - ctx - context for residual evaluation 38024989b8cSPeter Brune 38124989b8cSPeter Brune Level: advanced 38224989b8cSPeter Brune 38324989b8cSPeter Brune Note: 384ef20d060SBarry Smith TSSetRSHFunction() is normally used, but it calls this function internally because the user context is actually 38524989b8cSPeter Brune associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 38624989b8cSPeter Brune not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 38724989b8cSPeter Brune 38824989b8cSPeter Brune .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 38924989b8cSPeter Brune @*/ 39024989b8cSPeter Brune PetscErrorCode DMTSSetRHSFunction(DM dm,TSRHSFunction func,void *ctx) 39124989b8cSPeter Brune { 39224989b8cSPeter Brune PetscErrorCode ierr; 393942e3340SBarry Smith DMTS tsdm; 39424989b8cSPeter Brune 39524989b8cSPeter Brune PetscFunctionBegin; 39624989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 397942e3340SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 398d74926cbSBarry Smith if (func) tsdm->ops->rhsfunction = func; 39924989b8cSPeter Brune if (ctx) tsdm->rhsfunctionctx = ctx; 40024989b8cSPeter Brune PetscFunctionReturn(0); 40124989b8cSPeter Brune } 40224989b8cSPeter Brune 40324989b8cSPeter Brune #undef __FUNCT__ 404ef20d060SBarry Smith #define __FUNCT__ "DMTSGetSolutionFunction" 405ef20d060SBarry Smith /*@C 406ef20d060SBarry Smith DMTSGetSolutionFunction - gets the TS solution evaluation function 407ef20d060SBarry Smith 408ef20d060SBarry Smith Not Collective 409ef20d060SBarry Smith 410ef20d060SBarry Smith Input Arguments: 411ef20d060SBarry Smith . dm - DM to be used with TS 412ef20d060SBarry Smith 413ef20d060SBarry Smith Output Parameters: 414ef20d060SBarry Smith + func - solution function evaluation function, see TSSetSolution() for calling sequence 415ef20d060SBarry Smith - ctx - context for solution evaluation 416ef20d060SBarry Smith 417ef20d060SBarry Smith Level: advanced 418ef20d060SBarry Smith 419ef20d060SBarry Smith .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 420ef20d060SBarry Smith @*/ 421ef20d060SBarry Smith PetscErrorCode DMTSGetSolutionFunction(DM dm,TSSolutionFunction *func,void **ctx) 422ef20d060SBarry Smith { 423ef20d060SBarry Smith PetscErrorCode ierr; 424942e3340SBarry Smith DMTS tsdm; 425ef20d060SBarry Smith 426ef20d060SBarry Smith PetscFunctionBegin; 427ef20d060SBarry Smith PetscValidHeaderSpecific(dm,DM_CLASSID,1); 428942e3340SBarry Smith ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr); 429d74926cbSBarry Smith if (func) *func = tsdm->ops->solution; 430ef20d060SBarry Smith if (ctx) *ctx = tsdm->solutionctx; 431ef20d060SBarry Smith PetscFunctionReturn(0); 432ef20d060SBarry Smith } 433ef20d060SBarry Smith 434ef20d060SBarry Smith #undef __FUNCT__ 435ef20d060SBarry Smith #define __FUNCT__ "DMTSSetSolutionFunction" 436ef20d060SBarry Smith /*@C 437ef20d060SBarry Smith DMTSSetSolutionFunction - set TS solution evaluation function 438ef20d060SBarry Smith 439ef20d060SBarry Smith Not Collective 440ef20d060SBarry Smith 441ef20d060SBarry Smith Input Arguments: 442ef20d060SBarry Smith + dm - DM to be used with TS 443ef20d060SBarry Smith . func - solution function evaluation function, see TSSetSolution() for calling sequence 444ef20d060SBarry Smith - ctx - context for solution evaluation 445ef20d060SBarry Smith 446ef20d060SBarry Smith Level: advanced 447ef20d060SBarry Smith 448ef20d060SBarry Smith Note: 449ef20d060SBarry Smith TSSetSolutionFunction() is normally used, but it calls this function internally because the user context is actually 450ef20d060SBarry Smith associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 451ef20d060SBarry Smith not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 452ef20d060SBarry Smith 453ef20d060SBarry Smith .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 454ef20d060SBarry Smith @*/ 455ef20d060SBarry Smith PetscErrorCode DMTSSetSolutionFunction(DM dm,TSSolutionFunction func,void *ctx) 456ef20d060SBarry Smith { 457ef20d060SBarry Smith PetscErrorCode ierr; 458942e3340SBarry Smith DMTS tsdm; 459ef20d060SBarry Smith 460ef20d060SBarry Smith PetscFunctionBegin; 461ef20d060SBarry Smith PetscValidHeaderSpecific(dm,DM_CLASSID,1); 462942e3340SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 463d74926cbSBarry Smith if (func) tsdm->ops->solution = func; 464ef20d060SBarry Smith if (ctx) tsdm->solutionctx = ctx; 465ef20d060SBarry Smith PetscFunctionReturn(0); 466ef20d060SBarry Smith } 467ef20d060SBarry Smith 468ef20d060SBarry Smith #undef __FUNCT__ 4699b7cd975SBarry Smith #define __FUNCT__ "DMTSSetForcingFunction" 4709b7cd975SBarry Smith /*@C 4719b7cd975SBarry Smith DMTSSetForcingFunction - set TS forcing function evaluation function 4729b7cd975SBarry Smith 4739b7cd975SBarry Smith Not Collective 4749b7cd975SBarry Smith 4759b7cd975SBarry Smith Input Arguments: 4769b7cd975SBarry Smith + dm - DM to be used with TS 4779b7cd975SBarry Smith . TSForcingFunction - forcing function evaluation function 4789b7cd975SBarry Smith - ctx - context for solution evaluation 4799b7cd975SBarry Smith 4809b7cd975SBarry Smith Level: advanced 4819b7cd975SBarry Smith 4829b7cd975SBarry Smith Note: 4839b7cd975SBarry Smith TSSetForcingFunction() is normally used, but it calls this function internally because the user context is actually 4849b7cd975SBarry Smith associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 4859b7cd975SBarry Smith not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 4869b7cd975SBarry Smith 4879b7cd975SBarry Smith .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian(), TSSetForcingFunction(), DMTSGetForcingFunction() 4889b7cd975SBarry Smith @*/ 4899b7cd975SBarry Smith PetscErrorCode DMTSSetForcingFunction(DM dm,PetscErrorCode (*TSForcingFunction)(TS,PetscReal,Vec,void*),void *ctx) 4909b7cd975SBarry Smith { 4919b7cd975SBarry Smith PetscErrorCode ierr; 4929b7cd975SBarry Smith DMTS tsdm; 4939b7cd975SBarry Smith 4949b7cd975SBarry Smith PetscFunctionBegin; 4959b7cd975SBarry Smith PetscValidHeaderSpecific(dm,DM_CLASSID,1); 4969b7cd975SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 4979b7cd975SBarry Smith if (TSForcingFunction) tsdm->ops->forcing = TSForcingFunction; 4989b7cd975SBarry Smith if (ctx) tsdm->forcingctx = ctx; 4999b7cd975SBarry Smith PetscFunctionReturn(0); 5009b7cd975SBarry Smith } 5019b7cd975SBarry Smith 5029b7cd975SBarry Smith 5039b7cd975SBarry Smith #undef __FUNCT__ 5049b7cd975SBarry Smith #define __FUNCT__ "DMTSGetForcingFunction" 5059b7cd975SBarry Smith /*@C 5069b7cd975SBarry Smith DMTSGetForcingFunction - get TS forcing function evaluation function 5079b7cd975SBarry Smith 5089b7cd975SBarry Smith Not Collective 5099b7cd975SBarry Smith 5109b7cd975SBarry Smith Input Argument: 5119b7cd975SBarry Smith . dm - DM to be used with TS 5129b7cd975SBarry Smith 5139b7cd975SBarry Smith Output Arguments: 5149b7cd975SBarry Smith + TSForcingFunction - forcing function evaluation function 5159b7cd975SBarry Smith - ctx - context for solution evaluation 5169b7cd975SBarry Smith 5179b7cd975SBarry Smith Level: advanced 5189b7cd975SBarry Smith 5199b7cd975SBarry Smith Note: 5209b7cd975SBarry Smith TSSetForcingFunction() is normally used, but it calls this function internally because the user context is actually 5219b7cd975SBarry Smith associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 5229b7cd975SBarry Smith not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 5239b7cd975SBarry Smith 5249b7cd975SBarry Smith .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian(), TSSetForcingFunction(), DMTSGetForcingFunction() 5259b7cd975SBarry Smith @*/ 5269b7cd975SBarry Smith PetscErrorCode DMTSGetForcingFunction(DM dm,PetscErrorCode (**TSForcingFunction)(TS,PetscReal,Vec,void*),void **ctx) 5279b7cd975SBarry Smith { 5289b7cd975SBarry Smith PetscErrorCode ierr; 5299b7cd975SBarry Smith DMTS tsdm; 5309b7cd975SBarry Smith 5319b7cd975SBarry Smith PetscFunctionBegin; 5329b7cd975SBarry Smith PetscValidHeaderSpecific(dm,DM_CLASSID,1); 5339b7cd975SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 5349b7cd975SBarry Smith if (TSForcingFunction) *TSForcingFunction = tsdm->ops->forcing; 5359b7cd975SBarry Smith if (ctx) *ctx = tsdm->forcingctx; 5369b7cd975SBarry Smith PetscFunctionReturn(0); 5379b7cd975SBarry Smith } 5389b7cd975SBarry Smith 5399b7cd975SBarry Smith #undef __FUNCT__ 54024989b8cSPeter Brune #define __FUNCT__ "DMTSGetRHSFunction" 54124989b8cSPeter Brune /*@C 54224989b8cSPeter Brune DMTSGetRHSFunction - get TS explicit residual evaluation function 54324989b8cSPeter Brune 54424989b8cSPeter Brune Not Collective 54524989b8cSPeter Brune 54624989b8cSPeter Brune Input Argument: 54724989b8cSPeter Brune . dm - DM to be used with TS 54824989b8cSPeter Brune 54924989b8cSPeter Brune Output Arguments: 55024989b8cSPeter Brune + func - residual evaluation function, see TSSetRHSFunction() for calling sequence 55124989b8cSPeter Brune - ctx - context for residual evaluation 55224989b8cSPeter Brune 55324989b8cSPeter Brune Level: advanced 55424989b8cSPeter Brune 55524989b8cSPeter Brune Note: 55624989b8cSPeter Brune TSGetFunction() is normally used, but it calls this function internally because the user context is actually 55724989b8cSPeter Brune associated with the DM. 55824989b8cSPeter Brune 55924989b8cSPeter Brune .seealso: DMTSSetContext(), DMTSSetFunction(), TSSetFunction() 56024989b8cSPeter Brune @*/ 56124989b8cSPeter Brune PetscErrorCode DMTSGetRHSFunction(DM dm,TSRHSFunction *func,void **ctx) 56224989b8cSPeter Brune { 56324989b8cSPeter Brune PetscErrorCode ierr; 564942e3340SBarry Smith DMTS tsdm; 56524989b8cSPeter Brune 56624989b8cSPeter Brune PetscFunctionBegin; 56724989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 568942e3340SBarry Smith ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr); 569d74926cbSBarry Smith if (func) *func = tsdm->ops->rhsfunction; 57024989b8cSPeter Brune if (ctx) *ctx = tsdm->rhsfunctionctx; 57124989b8cSPeter Brune PetscFunctionReturn(0); 57224989b8cSPeter Brune } 57324989b8cSPeter Brune 57424989b8cSPeter Brune #undef __FUNCT__ 57524989b8cSPeter Brune #define __FUNCT__ "DMTSSetIJacobian" 57624989b8cSPeter Brune /*@C 57724989b8cSPeter Brune DMTSSetIJacobian - set TS Jacobian evaluation function 57824989b8cSPeter Brune 57924989b8cSPeter Brune Not Collective 58024989b8cSPeter Brune 58124989b8cSPeter Brune Input Argument: 58224989b8cSPeter Brune + dm - DM to be used with TS 58324989b8cSPeter Brune . func - Jacobian evaluation function, see TSSetIJacobian() for calling sequence 58424989b8cSPeter Brune - ctx - context for residual evaluation 58524989b8cSPeter Brune 58624989b8cSPeter Brune Level: advanced 58724989b8cSPeter Brune 58824989b8cSPeter Brune Note: 58924989b8cSPeter Brune TSSetJacobian() is normally used, but it calls this function internally because the user context is actually 59024989b8cSPeter Brune associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 59124989b8cSPeter Brune not. If DM took a more central role at some later date, this could become the primary method of setting the Jacobian. 59224989b8cSPeter Brune 59324989b8cSPeter Brune .seealso: DMTSSetContext(), TSSetFunction(), DMTSGetJacobian(), TSSetJacobian() 59424989b8cSPeter Brune @*/ 59524989b8cSPeter Brune PetscErrorCode DMTSSetIJacobian(DM dm,TSIJacobian func,void *ctx) 59624989b8cSPeter Brune { 59724989b8cSPeter Brune PetscErrorCode ierr; 598942e3340SBarry Smith DMTS sdm; 59924989b8cSPeter Brune 60024989b8cSPeter Brune PetscFunctionBegin; 60124989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 602942e3340SBarry Smith ierr = DMGetDMTSWrite(dm,&sdm);CHKERRQ(ierr); 603d74926cbSBarry Smith if (func) sdm->ops->ijacobian = func; 60424989b8cSPeter Brune if (ctx) sdm->ijacobianctx = ctx; 60524989b8cSPeter Brune PetscFunctionReturn(0); 60624989b8cSPeter Brune } 60724989b8cSPeter Brune 60824989b8cSPeter Brune #undef __FUNCT__ 60924989b8cSPeter Brune #define __FUNCT__ "DMTSGetIJacobian" 61024989b8cSPeter Brune /*@C 61124989b8cSPeter Brune DMTSGetIJacobian - get TS Jacobian evaluation function 61224989b8cSPeter Brune 61324989b8cSPeter Brune Not Collective 61424989b8cSPeter Brune 61524989b8cSPeter Brune Input Argument: 61624989b8cSPeter Brune . dm - DM to be used with TS 61724989b8cSPeter Brune 61824989b8cSPeter Brune Output Arguments: 61924989b8cSPeter Brune + func - Jacobian evaluation function, see TSSetIJacobian() for calling sequence 62024989b8cSPeter Brune - ctx - context for residual evaluation 62124989b8cSPeter Brune 62224989b8cSPeter Brune Level: advanced 62324989b8cSPeter Brune 62424989b8cSPeter Brune Note: 62524989b8cSPeter Brune TSGetJacobian() is normally used, but it calls this function internally because the user context is actually 62624989b8cSPeter Brune associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 62724989b8cSPeter Brune not. If DM took a more central role at some later date, this could become the primary method of setting the Jacobian. 62824989b8cSPeter Brune 62924989b8cSPeter Brune .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 63024989b8cSPeter Brune @*/ 63124989b8cSPeter Brune PetscErrorCode DMTSGetIJacobian(DM dm,TSIJacobian *func,void **ctx) 63224989b8cSPeter Brune { 63324989b8cSPeter Brune PetscErrorCode ierr; 634942e3340SBarry Smith DMTS tsdm; 63524989b8cSPeter Brune 63624989b8cSPeter Brune PetscFunctionBegin; 63724989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 638942e3340SBarry Smith ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr); 639d74926cbSBarry Smith if (func) *func = tsdm->ops->ijacobian; 64024989b8cSPeter Brune if (ctx) *ctx = tsdm->ijacobianctx; 64124989b8cSPeter Brune PetscFunctionReturn(0); 64224989b8cSPeter Brune } 64324989b8cSPeter Brune 64424989b8cSPeter Brune 64524989b8cSPeter Brune #undef __FUNCT__ 64624989b8cSPeter Brune #define __FUNCT__ "DMTSSetRHSJacobian" 64724989b8cSPeter Brune /*@C 64824989b8cSPeter Brune DMTSSetRHSJacobian - set TS Jacobian evaluation function 64924989b8cSPeter Brune 65024989b8cSPeter Brune Not Collective 65124989b8cSPeter Brune 65224989b8cSPeter Brune Input Argument: 65324989b8cSPeter Brune + dm - DM to be used with TS 65424989b8cSPeter Brune . func - Jacobian evaluation function, see TSSetRHSJacobian() for calling sequence 65524989b8cSPeter Brune - ctx - context for residual evaluation 65624989b8cSPeter Brune 65724989b8cSPeter Brune Level: advanced 65824989b8cSPeter Brune 65924989b8cSPeter Brune Note: 66024989b8cSPeter Brune TSSetJacobian() is normally used, but it calls this function internally because the user context is actually 66124989b8cSPeter Brune associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 66224989b8cSPeter Brune not. If DM took a more central role at some later date, this could become the primary method of setting the Jacobian. 66324989b8cSPeter Brune 66424989b8cSPeter Brune .seealso: DMTSSetContext(), TSSetFunction(), DMTSGetJacobian(), TSSetJacobian() 66524989b8cSPeter Brune @*/ 66624989b8cSPeter Brune PetscErrorCode DMTSSetRHSJacobian(DM dm,TSRHSJacobian func,void *ctx) 66724989b8cSPeter Brune { 66824989b8cSPeter Brune PetscErrorCode ierr; 669942e3340SBarry Smith DMTS tsdm; 67024989b8cSPeter Brune 67124989b8cSPeter Brune PetscFunctionBegin; 67224989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 673942e3340SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 674d74926cbSBarry Smith if (func) tsdm->ops->rhsjacobian = func; 67524989b8cSPeter Brune if (ctx) tsdm->rhsjacobianctx = ctx; 67624989b8cSPeter Brune PetscFunctionReturn(0); 67724989b8cSPeter Brune } 67824989b8cSPeter Brune 67924989b8cSPeter Brune #undef __FUNCT__ 68024989b8cSPeter Brune #define __FUNCT__ "DMTSGetRHSJacobian" 68124989b8cSPeter Brune /*@C 68224989b8cSPeter Brune DMTSGetRHSJacobian - get TS Jacobian evaluation function 68324989b8cSPeter Brune 68424989b8cSPeter Brune Not Collective 68524989b8cSPeter Brune 68624989b8cSPeter Brune Input Argument: 68724989b8cSPeter Brune . dm - DM to be used with TS 68824989b8cSPeter Brune 68924989b8cSPeter Brune Output Arguments: 69024989b8cSPeter Brune + func - Jacobian evaluation function, see TSSetRHSJacobian() for calling sequence 69124989b8cSPeter Brune - ctx - context for residual evaluation 69224989b8cSPeter Brune 69324989b8cSPeter Brune Level: advanced 69424989b8cSPeter Brune 69524989b8cSPeter Brune Note: 69624989b8cSPeter Brune TSGetJacobian() is normally used, but it calls this function internally because the user context is actually 69724989b8cSPeter Brune associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 69824989b8cSPeter Brune not. If DM took a more central role at some later date, this could become the primary method of setting the Jacobian. 69924989b8cSPeter Brune 70024989b8cSPeter Brune .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 70124989b8cSPeter Brune @*/ 70224989b8cSPeter Brune PetscErrorCode DMTSGetRHSJacobian(DM dm,TSRHSJacobian *func,void **ctx) 70324989b8cSPeter Brune { 70424989b8cSPeter Brune PetscErrorCode ierr; 705942e3340SBarry Smith DMTS tsdm; 70624989b8cSPeter Brune 70724989b8cSPeter Brune PetscFunctionBegin; 70824989b8cSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 709942e3340SBarry Smith ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr); 710d74926cbSBarry Smith if (func) *func = tsdm->ops->rhsjacobian; 71124989b8cSPeter Brune if (ctx) *ctx = tsdm->rhsjacobianctx; 71224989b8cSPeter Brune PetscFunctionReturn(0); 71324989b8cSPeter Brune } 714ad6bc421SBarry Smith 715ad6bc421SBarry Smith #undef __FUNCT__ 716ad6bc421SBarry Smith #define __FUNCT__ "DMTSSetIFunctionSerialize" 717ad6bc421SBarry Smith /*@C 718ad6bc421SBarry Smith DMTSSetIFunctionSerialize - sets functions used to view and load a IFunction context 719ad6bc421SBarry Smith 720ad6bc421SBarry Smith Not Collective 721ad6bc421SBarry Smith 722ad6bc421SBarry Smith Input Arguments: 723ad6bc421SBarry Smith + dm - DM to be used with TS 724ad6bc421SBarry Smith . view - viewer function 725ad6bc421SBarry Smith - load - loading function 726ad6bc421SBarry Smith 727ad6bc421SBarry Smith Level: advanced 728ad6bc421SBarry Smith 729ad6bc421SBarry Smith .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 730ad6bc421SBarry Smith @*/ 731ad6bc421SBarry Smith PetscErrorCode DMTSSetIFunctionSerialize(DM dm,PetscErrorCode (*view)(void*,PetscViewer),PetscErrorCode (*load)(void**,PetscViewer)) 732ad6bc421SBarry Smith { 733ad6bc421SBarry Smith PetscErrorCode ierr; 734ad6bc421SBarry Smith DMTS tsdm; 735ad6bc421SBarry Smith 736ad6bc421SBarry Smith PetscFunctionBegin; 737ad6bc421SBarry Smith PetscValidHeaderSpecific(dm,DM_CLASSID,1); 738ad6bc421SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 739ad6bc421SBarry Smith tsdm->ops->ifunctionview = view; 740ad6bc421SBarry Smith tsdm->ops->ifunctionload = load; 741ad6bc421SBarry Smith PetscFunctionReturn(0); 742ad6bc421SBarry Smith } 743ad6bc421SBarry Smith 744ad6bc421SBarry Smith #undef __FUNCT__ 745ad6bc421SBarry Smith #define __FUNCT__ "DMTSSetIJacobianSerialize" 746ad6bc421SBarry Smith /*@C 747ad6bc421SBarry Smith DMTSSetIJacobianSerialize - sets functions used to view and load a IJacobian context 748ad6bc421SBarry Smith 749ad6bc421SBarry Smith Not Collective 750ad6bc421SBarry Smith 751ad6bc421SBarry Smith Input Arguments: 752ad6bc421SBarry Smith + dm - DM to be used with TS 753ad6bc421SBarry Smith . view - viewer function 754ad6bc421SBarry Smith - load - loading function 755ad6bc421SBarry Smith 756ad6bc421SBarry Smith Level: advanced 757ad6bc421SBarry Smith 758ad6bc421SBarry Smith .seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian() 759ad6bc421SBarry Smith @*/ 760ad6bc421SBarry Smith PetscErrorCode DMTSSetIJacobianSerialize(DM dm,PetscErrorCode (*view)(void*,PetscViewer),PetscErrorCode (*load)(void**,PetscViewer)) 761ad6bc421SBarry Smith { 762ad6bc421SBarry Smith PetscErrorCode ierr; 763ad6bc421SBarry Smith DMTS tsdm; 764ad6bc421SBarry Smith 765ad6bc421SBarry Smith PetscFunctionBegin; 766ad6bc421SBarry Smith PetscValidHeaderSpecific(dm,DM_CLASSID,1); 767ad6bc421SBarry Smith ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr); 768ad6bc421SBarry Smith tsdm->ops->ijacobianview = view; 769ad6bc421SBarry Smith tsdm->ops->ijacobianload = load; 770ad6bc421SBarry Smith PetscFunctionReturn(0); 771ad6bc421SBarry Smith } 772