1b45d2f2cSJed Brown #include <petsc-private/snesimpl.h> /*I "petscsnes.h" I*/ 2679f678eSPeter Brune #include <petsc-private/dmimpl.h> /*I "petscdm.h" I*/ 36cab3a1bSJed Brown 46cab3a1bSJed Brown #undef __FUNCT__ 522c6f798SBarry Smith #define __FUNCT__ "DMSNESDestroy" 622c6f798SBarry Smith static PetscErrorCode DMSNESDestroy(DMSNES *kdm) 76cab3a1bSJed Brown { 86cab3a1bSJed Brown PetscErrorCode ierr; 96cab3a1bSJed Brown 106cab3a1bSJed Brown PetscFunctionBegin; 1122c6f798SBarry Smith if (!*kdm) PetscFunctionReturn(0); 1222c6f798SBarry Smith PetscValidHeaderSpecific((*kdm),DMSNES_CLASSID,1); 1322c6f798SBarry Smith if (--((PetscObject)(*kdm))->refct > 0) {*kdm = 0; PetscFunctionReturn(0);} 1422c6f798SBarry Smith if ((*kdm)->ops->destroy) {ierr = ((*kdm)->ops->destroy)(*kdm);CHKERRQ(ierr);} 1522c6f798SBarry Smith ierr = PetscHeaderDestroy(kdm);CHKERRQ(ierr); 1622c6f798SBarry Smith PetscFunctionReturn(0); 1722c6f798SBarry Smith } 1822c6f798SBarry Smith 1922c6f798SBarry Smith #undef __FUNCT__ 2022c6f798SBarry Smith #define __FUNCT__ "DMSNESCreate" 2122c6f798SBarry Smith static PetscErrorCode DMSNESCreate(MPI_Comm comm,DMSNES *kdm) 2222c6f798SBarry Smith { 2322c6f798SBarry Smith PetscErrorCode ierr; 2422c6f798SBarry Smith 2522c6f798SBarry Smith PetscFunctionBegin; 2622c6f798SBarry Smith #ifndef PETSC_USE_DYNAMIC_LIBRARIES 2722c6f798SBarry Smith ierr = SNESInitializePackage(PETSC_NULL);CHKERRQ(ierr); 2822c6f798SBarry Smith #endif 29*b4615a05SBarry Smith ierr = PetscHeaderCreate(*kdm, _p_DMSNES, struct _DMSNESOps, DMSNES_CLASSID, -1, "DMSNES", "DMSNES", "DMSNES", comm, DMSNESDestroy, PETSC_NULL);CHKERRQ(ierr); 3022c6f798SBarry Smith ierr = PetscMemzero((*kdm)->ops, sizeof(struct _DMSNESOps));CHKERRQ(ierr); 316cab3a1bSJed Brown PetscFunctionReturn(0); 326cab3a1bSJed Brown } 336cab3a1bSJed Brown 346cab3a1bSJed Brown #undef __FUNCT__ 35942e3340SBarry Smith #define __FUNCT__ "DMCoarsenHook_DMSNES" 36942e3340SBarry Smith /* Attaches the DMSNES to the coarse level. 376cab3a1bSJed Brown * Under what conditions should we copy versus duplicate? 386cab3a1bSJed Brown */ 39942e3340SBarry Smith static PetscErrorCode DMCoarsenHook_DMSNES(DM dm,DM dmc,void *ctx) 406cab3a1bSJed Brown { 416cab3a1bSJed Brown PetscErrorCode ierr; 426cab3a1bSJed Brown 436cab3a1bSJed Brown PetscFunctionBegin; 44942e3340SBarry Smith ierr = DMCopyDMSNES(dm,dmc);CHKERRQ(ierr); 456cab3a1bSJed Brown PetscFunctionReturn(0); 466cab3a1bSJed Brown } 476cab3a1bSJed Brown 486cab3a1bSJed Brown #undef __FUNCT__ 49942e3340SBarry Smith #define __FUNCT__ "DMRestrictHook_DMSNES" 50dfe15315SJed Brown /* This could restrict auxiliary information to the coarse level. 51caa4e7f2SJed Brown */ 52942e3340SBarry Smith static PetscErrorCode DMRestrictHook_DMSNES(DM dm,Mat Restrict,Vec rscale,Mat Inject,DM dmc,void *ctx) 53caa4e7f2SJed Brown { 54caa4e7f2SJed Brown 55caa4e7f2SJed Brown PetscFunctionBegin; 56caa4e7f2SJed Brown PetscFunctionReturn(0); 57caa4e7f2SJed Brown } 58caa4e7f2SJed Brown 59caa4e7f2SJed Brown #undef __FUNCT__ 60942e3340SBarry Smith #define __FUNCT__ "DMRefineHook_DMSNES" 61942e3340SBarry Smith static PetscErrorCode DMRefineHook_DMSNES(DM dm,DM dmf,void *ctx) 6203a0fabfSPeter Brune { 6303a0fabfSPeter Brune PetscErrorCode ierr; 6403a0fabfSPeter Brune 6503a0fabfSPeter Brune PetscFunctionBegin; 66942e3340SBarry Smith ierr = DMCopyDMSNES(dm,dmf);CHKERRQ(ierr); 6703a0fabfSPeter Brune PetscFunctionReturn(0); 6803a0fabfSPeter Brune } 6903a0fabfSPeter Brune 7003a0fabfSPeter Brune #undef __FUNCT__ 71942e3340SBarry Smith #define __FUNCT__ "DMInterpolateHook_DMSNES" 7203a0fabfSPeter Brune /* This could restrict auxiliary information to the coarse level. 7303a0fabfSPeter Brune */ 74942e3340SBarry Smith static PetscErrorCode DMInterpolateHook_DMSNES(DM dm,Mat Interp,DM dmf,void *ctx) 7503a0fabfSPeter Brune { 7603a0fabfSPeter Brune 7703a0fabfSPeter Brune PetscFunctionBegin; 7803a0fabfSPeter Brune PetscFunctionReturn(0); 7903a0fabfSPeter Brune } 8003a0fabfSPeter Brune 8103a0fabfSPeter Brune #undef __FUNCT__ 8222c6f798SBarry Smith #define __FUNCT__ "DMSNESCopy" 8322c6f798SBarry Smith /*@C 8422c6f798SBarry Smith DMSNESCopy - copies the information in a DMSNES to another DMSNES 8522c6f798SBarry Smith 8622c6f798SBarry Smith Not Collective 8722c6f798SBarry Smith 8822c6f798SBarry Smith Input Argument: 8922c6f798SBarry Smith + kdm - Original DMSNES 9022c6f798SBarry Smith - nkdm - DMSNES to receive the data, should have been created with DMSNESCreate() 9122c6f798SBarry Smith 9222c6f798SBarry Smith Level: developer 9322c6f798SBarry Smith 9422c6f798SBarry Smith .seealso: DMSNESCreate(), DMSNESDestroy() 9522c6f798SBarry Smith @*/ 9622c6f798SBarry Smith PetscErrorCode DMSNESCopy(DMSNES kdm,DMSNES nkdm) 9722c6f798SBarry Smith { 9822c6f798SBarry Smith PetscErrorCode ierr; 9922c6f798SBarry Smith 10022c6f798SBarry Smith PetscFunctionBegin; 10122c6f798SBarry Smith PetscValidHeaderSpecific(kdm,DMSNES_CLASSID,1); 10222c6f798SBarry Smith PetscValidHeaderSpecific(nkdm,DMSNES_CLASSID,2); 10322c6f798SBarry Smith nkdm->ops->computefunction = kdm->ops->computefunction; 10422c6f798SBarry Smith nkdm->ops->computegs = kdm->ops->computegs; 10522c6f798SBarry Smith nkdm->ops->computeobjective = kdm->ops->computeobjective; 10622c6f798SBarry Smith nkdm->ops->computepjacobian = kdm->ops->computepjacobian; 10722c6f798SBarry Smith nkdm->ops->computepfunction = kdm->ops->computepfunction; 10822c6f798SBarry Smith nkdm->ops->computeblockfunction = kdm->ops->computeblockfunction; 10922c6f798SBarry Smith nkdm->ops->computeblockjacobian = kdm->ops->computeblockjacobian; 11022c6f798SBarry Smith nkdm->ops->destroy = kdm->ops->destroy; 11122c6f798SBarry Smith nkdm->ops->duplicate = kdm->ops->duplicate; 11222c6f798SBarry Smith 11322c6f798SBarry Smith nkdm->functionctx = kdm->functionctx; 11422c6f798SBarry Smith nkdm->gsctx = kdm->gsctx; 11522c6f798SBarry Smith nkdm->pctx = kdm->pctx; 11622c6f798SBarry Smith nkdm->jacobianctx = kdm->jacobianctx; 11722c6f798SBarry Smith nkdm->objectivectx = kdm->objectivectx; 11822c6f798SBarry Smith nkdm->blockfunctionctx = kdm->blockfunctionctx; 11922c6f798SBarry Smith nkdm->blockjacobianctx = kdm->blockjacobianctx; 12022c6f798SBarry Smith nkdm->data = kdm->data; 12122c6f798SBarry Smith 12222c6f798SBarry Smith /* 12322c6f798SBarry Smith nkdm->fortran_func_pointers[0] = kdm->fortran_func_pointers[0]; 12422c6f798SBarry Smith nkdm->fortran_func_pointers[1] = kdm->fortran_func_pointers[1]; 12522c6f798SBarry Smith nkdm->fortran_func_pointers[2] = kdm->fortran_func_pointers[2]; 12622c6f798SBarry Smith */ 12722c6f798SBarry Smith 12822c6f798SBarry Smith /* implementation specific copy hooks */ 12922c6f798SBarry Smith if (kdm->ops->duplicate) {ierr = (*kdm->ops->duplicate)(kdm,nkdm);CHKERRQ(ierr);} 13022c6f798SBarry Smith PetscFunctionReturn(0); 13122c6f798SBarry Smith } 13222c6f798SBarry Smith 13322c6f798SBarry Smith #undef __FUNCT__ 134942e3340SBarry Smith #define __FUNCT__ "DMGetDMSNES" 1356cab3a1bSJed Brown /*@C 136942e3340SBarry Smith DMGetDMSNES - get read-only private DMSNES context from a DM 1376cab3a1bSJed Brown 1386cab3a1bSJed Brown Not Collective 1396cab3a1bSJed Brown 1406cab3a1bSJed Brown Input Argument: 1416cab3a1bSJed Brown . dm - DM to be used with SNES 1426cab3a1bSJed Brown 1436cab3a1bSJed Brown Output Argument: 144942e3340SBarry Smith . snesdm - private DMSNES context 1456cab3a1bSJed Brown 1466cab3a1bSJed Brown Level: developer 1476cab3a1bSJed Brown 1486cab3a1bSJed Brown Notes: 149942e3340SBarry Smith Use DMGetDMSNESWrite() if write access is needed. The DMSNESSetXXX API should be used wherever possible. 1506cab3a1bSJed Brown 151942e3340SBarry Smith .seealso: DMGetDMSNESWrite() 1526cab3a1bSJed Brown @*/ 153942e3340SBarry Smith PetscErrorCode DMGetDMSNES(DM dm,DMSNES *snesdm) 1546cab3a1bSJed Brown { 1556cab3a1bSJed Brown PetscErrorCode ierr; 1566cab3a1bSJed Brown 1576cab3a1bSJed Brown PetscFunctionBegin; 1586cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 159*b4615a05SBarry Smith *snesdm = (DMSNES) dm->dmsnes; 16022c6f798SBarry Smith if (!*snesdm) { 161942e3340SBarry Smith ierr = PetscInfo(dm,"Creating new DMSNES\n");CHKERRQ(ierr); 16222c6f798SBarry Smith ierr = DMSNESCreate(((PetscObject)dm)->comm,snesdm);CHKERRQ(ierr); 163*b4615a05SBarry Smith dm->dmsnes = (PetscObject) *snesdm; 164942e3340SBarry Smith ierr = DMCoarsenHookAdd(dm,DMCoarsenHook_DMSNES,DMRestrictHook_DMSNES,PETSC_NULL);CHKERRQ(ierr); 16522c6f798SBarry Smith ierr = DMRefineHookAdd(dm,DMRefineHook_DMSNES,DMInterpolateHook_DMSNES,PETSC_NULL);CHKERRQ(ierr); 1666cab3a1bSJed Brown } 1676cab3a1bSJed Brown PetscFunctionReturn(0); 1686cab3a1bSJed Brown } 1696cab3a1bSJed Brown 1706cab3a1bSJed Brown #undef __FUNCT__ 171942e3340SBarry Smith #define __FUNCT__ "DMGetDMSNESWrite" 1726cab3a1bSJed Brown /*@C 173942e3340SBarry Smith DMGetDMSNESWrite - get write access to private DMSNES context from a DM 1746cab3a1bSJed Brown 1756cab3a1bSJed Brown Not Collective 1766cab3a1bSJed Brown 1776cab3a1bSJed Brown Input Argument: 1786cab3a1bSJed Brown . dm - DM to be used with SNES 1796cab3a1bSJed Brown 1806cab3a1bSJed Brown Output Argument: 181942e3340SBarry Smith . snesdm - private DMSNES context 1826cab3a1bSJed Brown 1836cab3a1bSJed Brown Level: developer 1846cab3a1bSJed Brown 185942e3340SBarry Smith .seealso: DMGetDMSNES() 1866cab3a1bSJed Brown @*/ 187942e3340SBarry Smith PetscErrorCode DMGetDMSNESWrite(DM dm,DMSNES *snesdm) 1886cab3a1bSJed Brown { 1896cab3a1bSJed Brown PetscErrorCode ierr; 190942e3340SBarry Smith DMSNES sdm; 1916cab3a1bSJed Brown 1926cab3a1bSJed Brown PetscFunctionBegin; 1936cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 194942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 1956cab3a1bSJed Brown if (!sdm->originaldm) sdm->originaldm = dm; 1966cab3a1bSJed Brown if (sdm->originaldm != dm) { /* Copy on write */ 197*b4615a05SBarry Smith DMSNES oldsdm = sdm; 198942e3340SBarry Smith ierr = PetscInfo(dm,"Copying DMSNES due to write\n");CHKERRQ(ierr); 19922c6f798SBarry Smith ierr = DMSNESCreate(((PetscObject)dm)->comm,&sdm);CHKERRQ(ierr); 20022c6f798SBarry Smith ierr = DMSNESCopy(oldsdm,sdm);CHKERRQ(ierr); 201*b4615a05SBarry Smith ierr = DMSNESDestroy((DMSNES*)&dm->dmsnes);CHKERRQ(ierr); 202*b4615a05SBarry Smith dm->dmsnes = (PetscObject)sdm; 2036cab3a1bSJed Brown } 2046cab3a1bSJed Brown *snesdm = sdm; 2056cab3a1bSJed Brown PetscFunctionReturn(0); 2066cab3a1bSJed Brown } 2076cab3a1bSJed Brown 2086cab3a1bSJed Brown #undef __FUNCT__ 209942e3340SBarry Smith #define __FUNCT__ "DMCopyDMSNES" 2106cab3a1bSJed Brown /*@C 211942e3340SBarry Smith DMCopyDMSNES - copies a DM context to a new DM 2126cab3a1bSJed Brown 2136cab3a1bSJed Brown Logically Collective 2146cab3a1bSJed Brown 2156cab3a1bSJed Brown Input Arguments: 2166cab3a1bSJed Brown + dmsrc - DM to obtain context from 2176cab3a1bSJed Brown - dmdest - DM to add context to 2186cab3a1bSJed Brown 2196cab3a1bSJed Brown Level: developer 2206cab3a1bSJed Brown 2216cab3a1bSJed Brown Note: 2226cab3a1bSJed Brown The context is copied by reference. This function does not ensure that a context exists. 2236cab3a1bSJed Brown 224942e3340SBarry Smith .seealso: DMGetDMSNES(), SNESSetDM() 2256cab3a1bSJed Brown @*/ 226942e3340SBarry Smith PetscErrorCode DMCopyDMSNES(DM dmsrc,DM dmdest) 2276cab3a1bSJed Brown { 2286cab3a1bSJed Brown PetscErrorCode ierr; 2296cab3a1bSJed Brown 2306cab3a1bSJed Brown PetscFunctionBegin; 2316cab3a1bSJed Brown PetscValidHeaderSpecific(dmsrc,DM_CLASSID,1); 2326cab3a1bSJed Brown PetscValidHeaderSpecific(dmdest,DM_CLASSID,2); 233*b4615a05SBarry Smith ierr = DMSNESDestroy((DMSNES*)&dmdest->dmsnes);CHKERRQ(ierr); 234*b4615a05SBarry Smith dmdest->dmsnes = dmsrc->dmsnes; 235*b4615a05SBarry Smith ierr = PetscObjectReference(dmdest->dmsnes);CHKERRQ(ierr); 23622c6f798SBarry Smith ierr = DMCoarsenHookAdd(dmdest,DMCoarsenHook_DMSNES,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); 23722c6f798SBarry Smith ierr = DMRefineHookAdd(dmdest,DMRefineHook_DMSNES,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); 2386cab3a1bSJed Brown PetscFunctionReturn(0); 2396cab3a1bSJed Brown } 2406cab3a1bSJed Brown 2416cab3a1bSJed Brown #undef __FUNCT__ 2426cab3a1bSJed Brown #define __FUNCT__ "DMSNESSetFunction" 2436cab3a1bSJed Brown /*@C 2446cab3a1bSJed Brown DMSNESSetFunction - set SNES residual evaluation function 2456cab3a1bSJed Brown 2466cab3a1bSJed Brown Not Collective 2476cab3a1bSJed Brown 2486cab3a1bSJed Brown Input Arguments: 2496cab3a1bSJed Brown + dm - DM to be used with SNES 2506cab3a1bSJed Brown . func - residual evaluation function, see SNESSetFunction() for calling sequence 2516cab3a1bSJed Brown - ctx - context for residual evaluation 2526cab3a1bSJed Brown 2536cab3a1bSJed Brown Level: advanced 2546cab3a1bSJed Brown 2556cab3a1bSJed Brown Note: 2566cab3a1bSJed Brown SNESSetFunction() is normally used, but it calls this function internally because the user context is actually 2576cab3a1bSJed Brown associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 2586cab3a1bSJed Brown not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 2596cab3a1bSJed Brown 2606cab3a1bSJed Brown .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESSetJacobian() 2616cab3a1bSJed Brown @*/ 2626cab3a1bSJed Brown PetscErrorCode DMSNESSetFunction(DM dm,PetscErrorCode (*func)(SNES,Vec,Vec,void*),void *ctx) 2636cab3a1bSJed Brown { 2646cab3a1bSJed Brown PetscErrorCode ierr; 265942e3340SBarry Smith DMSNES sdm; 2666cab3a1bSJed Brown 2676cab3a1bSJed Brown PetscFunctionBegin; 2686cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 269fdaff8d6SPeter Brune if (func || ctx) { 270942e3340SBarry Smith ierr = DMGetDMSNESWrite(dm,&sdm);CHKERRQ(ierr); 271fdaff8d6SPeter Brune } 27222c6f798SBarry Smith if (func) sdm->ops->computefunction = func; 2736cab3a1bSJed Brown if (ctx) sdm->functionctx = ctx; 2746cab3a1bSJed Brown PetscFunctionReturn(0); 2756cab3a1bSJed Brown } 2766cab3a1bSJed Brown 2776cab3a1bSJed Brown #undef __FUNCT__ 2786cab3a1bSJed Brown #define __FUNCT__ "DMSNESGetFunction" 2796cab3a1bSJed Brown /*@C 2806cab3a1bSJed Brown DMSNESGetFunction - get SNES residual evaluation function 2816cab3a1bSJed Brown 2826cab3a1bSJed Brown Not Collective 2836cab3a1bSJed Brown 2846cab3a1bSJed Brown Input Argument: 2856cab3a1bSJed Brown . dm - DM to be used with SNES 2866cab3a1bSJed Brown 2876cab3a1bSJed Brown Output Arguments: 2886cab3a1bSJed Brown + func - residual evaluation function, see SNESSetFunction() for calling sequence 2896cab3a1bSJed Brown - ctx - context for residual evaluation 2906cab3a1bSJed Brown 2916cab3a1bSJed Brown Level: advanced 2926cab3a1bSJed Brown 2936cab3a1bSJed Brown Note: 2946cab3a1bSJed Brown SNESGetFunction() is normally used, but it calls this function internally because the user context is actually 2956cab3a1bSJed Brown associated with the DM. 2966cab3a1bSJed Brown 2976cab3a1bSJed Brown .seealso: DMSNESSetContext(), DMSNESSetFunction(), SNESSetFunction() 2986cab3a1bSJed Brown @*/ 2996cab3a1bSJed Brown PetscErrorCode DMSNESGetFunction(DM dm,PetscErrorCode (**func)(SNES,Vec,Vec,void*),void **ctx) 3006cab3a1bSJed Brown { 3016cab3a1bSJed Brown PetscErrorCode ierr; 302942e3340SBarry Smith DMSNES sdm; 3036cab3a1bSJed Brown 3046cab3a1bSJed Brown PetscFunctionBegin; 3056cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 306942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 30722c6f798SBarry Smith if (func) *func = sdm->ops->computefunction; 3086cab3a1bSJed Brown if (ctx) *ctx = sdm->functionctx; 3096cab3a1bSJed Brown PetscFunctionReturn(0); 3106cab3a1bSJed Brown } 3116cab3a1bSJed Brown 3126cab3a1bSJed Brown #undef __FUNCT__ 3132a4ee8f2SPeter Brune #define __FUNCT__ "DMSNESSetObjective" 3142a4ee8f2SPeter Brune /*@C 315081a7dcdSPeter Brune DMSNESSetObjective - set SNES objective evaluation function 3162a4ee8f2SPeter Brune 3172a4ee8f2SPeter Brune Not Collective 3182a4ee8f2SPeter Brune 3192a4ee8f2SPeter Brune Input Arguments: 3202a4ee8f2SPeter Brune + dm - DM to be used with SNES 3212a4ee8f2SPeter Brune . func - residual evaluation function, see SNESSetObjective() for calling sequence 3222a4ee8f2SPeter Brune - ctx - context for residual evaluation 3232a4ee8f2SPeter Brune 3242a4ee8f2SPeter Brune Level: advanced 3252a4ee8f2SPeter Brune 3262a4ee8f2SPeter Brune .seealso: DMSNESSetContext(), SNESGetObjective(), DMSNESSetFunction() 3272a4ee8f2SPeter Brune @*/ 3282a4ee8f2SPeter Brune PetscErrorCode DMSNESSetObjective(DM dm,SNESObjective func,void *ctx) 3292a4ee8f2SPeter Brune { 3302a4ee8f2SPeter Brune PetscErrorCode ierr; 331942e3340SBarry Smith DMSNES sdm; 3322a4ee8f2SPeter Brune 3332a4ee8f2SPeter Brune PetscFunctionBegin; 3342a4ee8f2SPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 335fdaff8d6SPeter Brune if (func || ctx) { 336942e3340SBarry Smith ierr = DMGetDMSNESWrite(dm,&sdm);CHKERRQ(ierr); 337fdaff8d6SPeter Brune } 33822c6f798SBarry Smith if (func) sdm->ops->computeobjective = func; 3392a4ee8f2SPeter Brune if (ctx) sdm->objectivectx = ctx; 3402a4ee8f2SPeter Brune PetscFunctionReturn(0); 3412a4ee8f2SPeter Brune } 3422a4ee8f2SPeter Brune 3432a4ee8f2SPeter Brune #undef __FUNCT__ 3442a4ee8f2SPeter Brune #define __FUNCT__ "DMSNESGetObjective" 3452a4ee8f2SPeter Brune /*@C 3462a4ee8f2SPeter Brune DMSNESGetObjective - get SNES objective evaluation function 3472a4ee8f2SPeter Brune 3482a4ee8f2SPeter Brune Not Collective 3492a4ee8f2SPeter Brune 3502a4ee8f2SPeter Brune Input Argument: 3512a4ee8f2SPeter Brune . dm - DM to be used with SNES 3522a4ee8f2SPeter Brune 3532a4ee8f2SPeter Brune Output Arguments: 3542a4ee8f2SPeter Brune + func - residual evaluation function, see SNESSetObjective() for calling sequence 3552a4ee8f2SPeter Brune - ctx - context for residual evaluation 3562a4ee8f2SPeter Brune 3572a4ee8f2SPeter Brune Level: advanced 3582a4ee8f2SPeter Brune 3592a4ee8f2SPeter Brune Note: 3602a4ee8f2SPeter Brune SNESGetFunction() is normally used, but it calls this function internally because the user context is actually 3612a4ee8f2SPeter Brune associated with the DM. 3622a4ee8f2SPeter Brune 3632a4ee8f2SPeter Brune .seealso: DMSNESSetContext(), DMSNESSetObjective(), SNESSetFunction() 3642a4ee8f2SPeter Brune @*/ 3652a4ee8f2SPeter Brune PetscErrorCode DMSNESGetObjective(DM dm,SNESObjective *func,void **ctx) 3662a4ee8f2SPeter Brune { 3672a4ee8f2SPeter Brune PetscErrorCode ierr; 368942e3340SBarry Smith DMSNES sdm; 3692a4ee8f2SPeter Brune 3702a4ee8f2SPeter Brune PetscFunctionBegin; 3712a4ee8f2SPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 372942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 37322c6f798SBarry Smith if (func) *func = sdm->ops->computeobjective; 3742a4ee8f2SPeter Brune if (ctx) *ctx = sdm->objectivectx; 3752a4ee8f2SPeter Brune PetscFunctionReturn(0); 3762a4ee8f2SPeter Brune } 3772a4ee8f2SPeter Brune 3782a4ee8f2SPeter Brune #undef __FUNCT__ 3796cab3a1bSJed Brown #define __FUNCT__ "DMSNESSetGS" 3806cab3a1bSJed Brown /*@C 3816cab3a1bSJed Brown DMSNESSetGS - set SNES Gauss-Seidel relaxation function 3826cab3a1bSJed Brown 3836cab3a1bSJed Brown Not Collective 3846cab3a1bSJed Brown 3856cab3a1bSJed Brown Input Argument: 3866cab3a1bSJed Brown + dm - DM to be used with SNES 3876cab3a1bSJed Brown . func - relaxation function, see SNESSetGS() for calling sequence 3886cab3a1bSJed Brown - ctx - context for residual evaluation 3896cab3a1bSJed Brown 3906cab3a1bSJed Brown Level: advanced 3916cab3a1bSJed Brown 3926cab3a1bSJed Brown Note: 3936cab3a1bSJed Brown SNESSetGS() is normally used, but it calls this function internally because the user context is actually 3946cab3a1bSJed Brown associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 3956cab3a1bSJed Brown not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 3966cab3a1bSJed Brown 3976cab3a1bSJed Brown .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESSetJacobian(), DMSNESSetFunction() 3986cab3a1bSJed Brown @*/ 3996cab3a1bSJed Brown PetscErrorCode DMSNESSetGS(DM dm,PetscErrorCode (*func)(SNES,Vec,Vec,void*),void *ctx) 4006cab3a1bSJed Brown { 4016cab3a1bSJed Brown PetscErrorCode ierr; 402942e3340SBarry Smith DMSNES sdm; 4036cab3a1bSJed Brown 4046cab3a1bSJed Brown PetscFunctionBegin; 4056cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 406fdaff8d6SPeter Brune if (func || ctx) { 407942e3340SBarry Smith ierr = DMGetDMSNESWrite(dm,&sdm);CHKERRQ(ierr); 408fdaff8d6SPeter Brune } 40922c6f798SBarry Smith if (func) sdm->ops->computegs = func; 4106cab3a1bSJed Brown if (ctx) sdm->gsctx = ctx; 4116cab3a1bSJed Brown PetscFunctionReturn(0); 4126cab3a1bSJed Brown } 4136cab3a1bSJed Brown 4146cab3a1bSJed Brown #undef __FUNCT__ 4156cab3a1bSJed Brown #define __FUNCT__ "DMSNESGetGS" 4166cab3a1bSJed Brown /*@C 4176cab3a1bSJed Brown DMSNESGetGS - get SNES Gauss-Seidel relaxation function 4186cab3a1bSJed Brown 4196cab3a1bSJed Brown Not Collective 4206cab3a1bSJed Brown 4216cab3a1bSJed Brown Input Argument: 4226cab3a1bSJed Brown . dm - DM to be used with SNES 4236cab3a1bSJed Brown 4246cab3a1bSJed Brown Output Arguments: 4256cab3a1bSJed Brown + func - relaxation function, see SNESSetGS() for calling sequence 4266cab3a1bSJed Brown - ctx - context for residual evaluation 4276cab3a1bSJed Brown 4286cab3a1bSJed Brown Level: advanced 4296cab3a1bSJed Brown 4306cab3a1bSJed Brown Note: 4316cab3a1bSJed Brown SNESGetGS() is normally used, but it calls this function internally because the user context is actually 4326cab3a1bSJed Brown associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 4336cab3a1bSJed Brown not. If DM took a more central role at some later date, this could become the primary method of setting the residual. 4346cab3a1bSJed Brown 4356cab3a1bSJed Brown .seealso: DMSNESSetContext(), SNESGetGS(), DMSNESGetJacobian(), DMSNESGetFunction() 4366cab3a1bSJed Brown @*/ 4376cab3a1bSJed Brown PetscErrorCode DMSNESGetGS(DM dm,PetscErrorCode (**func)(SNES,Vec,Vec,void*),void **ctx) 4386cab3a1bSJed Brown { 4396cab3a1bSJed Brown PetscErrorCode ierr; 440942e3340SBarry Smith DMSNES sdm; 4416cab3a1bSJed Brown 4426cab3a1bSJed Brown PetscFunctionBegin; 4436cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 444942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 44522c6f798SBarry Smith if (func) *func = sdm->ops->computegs; 4466cab3a1bSJed Brown if (ctx) *ctx = sdm->gsctx; 4476cab3a1bSJed Brown PetscFunctionReturn(0); 4486cab3a1bSJed Brown } 4496cab3a1bSJed Brown 4506cab3a1bSJed Brown #undef __FUNCT__ 4516cab3a1bSJed Brown #define __FUNCT__ "DMSNESSetJacobian" 4526cab3a1bSJed Brown /*@C 453ecfdb398SPeter Brune DMSNESSetJacobian - set SNES Jacobian evaluation function 4546cab3a1bSJed Brown 4556cab3a1bSJed Brown Not Collective 4566cab3a1bSJed Brown 4576cab3a1bSJed Brown Input Argument: 4586cab3a1bSJed Brown + dm - DM to be used with SNES 4596cab3a1bSJed Brown . func - Jacobian evaluation function, see SNESSetJacobian() for calling sequence 4606cab3a1bSJed Brown - ctx - context for residual evaluation 4616cab3a1bSJed Brown 4626cab3a1bSJed Brown Level: advanced 4636cab3a1bSJed Brown 4646cab3a1bSJed Brown Note: 4656cab3a1bSJed Brown SNESSetJacobian() is normally used, but it calls this function internally because the user context is actually 4666cab3a1bSJed Brown associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 4676cab3a1bSJed Brown not. If DM took a more central role at some later date, this could become the primary method of setting the Jacobian. 4686cab3a1bSJed Brown 4696cab3a1bSJed Brown .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESGetJacobian(), SNESSetJacobian() 4706cab3a1bSJed Brown @*/ 4716cab3a1bSJed Brown PetscErrorCode DMSNESSetJacobian(DM dm,PetscErrorCode (*func)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *ctx) 4726cab3a1bSJed Brown { 4736cab3a1bSJed Brown PetscErrorCode ierr; 474942e3340SBarry Smith DMSNES sdm; 4756cab3a1bSJed Brown 4766cab3a1bSJed Brown PetscFunctionBegin; 4776cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 4781fdfe764SBarry Smith if (func || ctx) { 479942e3340SBarry Smith ierr = DMGetDMSNESWrite(dm,&sdm);CHKERRQ(ierr); 4801fdfe764SBarry Smith } 48122c6f798SBarry Smith if (func) sdm->ops->computejacobian = func; 4826cab3a1bSJed Brown if (ctx) sdm->jacobianctx = ctx; 4836cab3a1bSJed Brown PetscFunctionReturn(0); 4846cab3a1bSJed Brown } 4856cab3a1bSJed Brown 4866cab3a1bSJed Brown #undef __FUNCT__ 4876cab3a1bSJed Brown #define __FUNCT__ "DMSNESGetJacobian" 4886cab3a1bSJed Brown /*@C 489ecfdb398SPeter Brune DMSNESGetJacobian - get SNES Jacobian evaluation function 4906cab3a1bSJed Brown 4916cab3a1bSJed Brown Not Collective 4926cab3a1bSJed Brown 4936cab3a1bSJed Brown Input Argument: 4946cab3a1bSJed Brown . dm - DM to be used with SNES 4956cab3a1bSJed Brown 4966cab3a1bSJed Brown Output Arguments: 4976cab3a1bSJed Brown + func - Jacobian evaluation function, see SNESSetJacobian() for calling sequence 4986cab3a1bSJed Brown - ctx - context for residual evaluation 4996cab3a1bSJed Brown 5006cab3a1bSJed Brown Level: advanced 5016cab3a1bSJed Brown 5026cab3a1bSJed Brown Note: 5036cab3a1bSJed Brown SNESGetJacobian() is normally used, but it calls this function internally because the user context is actually 5046cab3a1bSJed Brown associated with the DM. This makes the interface consistent regardless of whether the user interacts with a DM or 5056cab3a1bSJed Brown not. If DM took a more central role at some later date, this could become the primary method of setting the Jacobian. 5066cab3a1bSJed Brown 5076cab3a1bSJed Brown .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESSetJacobian() 5086cab3a1bSJed Brown @*/ 5096cab3a1bSJed Brown PetscErrorCode DMSNESGetJacobian(DM dm,PetscErrorCode (**func)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void **ctx) 5106cab3a1bSJed Brown { 5116cab3a1bSJed Brown PetscErrorCode ierr; 512942e3340SBarry Smith DMSNES sdm; 5136cab3a1bSJed Brown 5146cab3a1bSJed Brown PetscFunctionBegin; 5156cab3a1bSJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 516942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 51722c6f798SBarry Smith if (func) *func = sdm->ops->computejacobian; 5186cab3a1bSJed Brown if (ctx) *ctx = sdm->jacobianctx; 5196cab3a1bSJed Brown PetscFunctionReturn(0); 5206cab3a1bSJed Brown } 5216cab3a1bSJed Brown 5226cab3a1bSJed Brown #undef __FUNCT__ 523e03ab78fSPeter Brune #define __FUNCT__ "DMSNESSetPicard" 524e03ab78fSPeter Brune /*@C 525e03ab78fSPeter Brune DMSNESSetPicard - set SNES Picard iteration matrix and RHS evaluation functions. 526e03ab78fSPeter Brune 527e03ab78fSPeter Brune Not Collective 528e03ab78fSPeter Brune 529e03ab78fSPeter Brune Input Argument: 530e03ab78fSPeter Brune + dm - DM to be used with SNES 531e03ab78fSPeter Brune . func - RHS evaluation function, see SNESSetFunction() for calling sequence 532e03ab78fSPeter Brune . pjac - Picard matrix evaluation function, see SNESSetJacobian() for calling sequence 533e03ab78fSPeter Brune - ctx - context for residual evaluation 534e03ab78fSPeter Brune 535e03ab78fSPeter Brune Level: advanced 536e03ab78fSPeter Brune 537e03ab78fSPeter Brune .seealso: SNESSetPicard(), DMSNESSetFunction(), DMSNESSetJacobian() 538e03ab78fSPeter Brune @*/ 539e03ab78fSPeter Brune PetscErrorCode DMSNESSetPicard(DM dm,PetscErrorCode (*pfunc)(SNES,Vec,Vec,void*),PetscErrorCode (*pjac)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *ctx) 540e03ab78fSPeter Brune { 541e03ab78fSPeter Brune PetscErrorCode ierr; 542942e3340SBarry Smith DMSNES sdm; 543e03ab78fSPeter Brune 544e03ab78fSPeter Brune PetscFunctionBegin; 545e03ab78fSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 546942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 54722c6f798SBarry Smith if (pfunc) sdm->ops->computepfunction = pfunc; 54822c6f798SBarry Smith if (pjac) sdm->ops->computepjacobian = pjac; 549e03ab78fSPeter Brune if (ctx) sdm->pctx = ctx; 550e03ab78fSPeter Brune PetscFunctionReturn(0); 551e03ab78fSPeter Brune } 552e03ab78fSPeter Brune 5537971a8bfSPeter Brune 5547971a8bfSPeter Brune #undef __FUNCT__ 5557971a8bfSPeter Brune #define __FUNCT__ "DMSNESGetPicard" 5567971a8bfSPeter Brune /*@C 5577971a8bfSPeter Brune DMSNESGetPicard - get SNES Picard iteration evaluation functions 5587971a8bfSPeter Brune 5597971a8bfSPeter Brune Not Collective 5607971a8bfSPeter Brune 5617971a8bfSPeter Brune Input Argument: 5627971a8bfSPeter Brune . dm - DM to be used with SNES 5637971a8bfSPeter Brune 5647971a8bfSPeter Brune Output Arguments: 5657971a8bfSPeter Brune + pfunc - Jacobian evaluation function, see SNESSetJacobian() for calling sequence 5667971a8bfSPeter Brune . pjac - RHS evaluation function, see SNESSetFunction() for calling sequence 5677971a8bfSPeter Brune - ctx - context for residual evaluation 5687971a8bfSPeter Brune 5697971a8bfSPeter Brune Level: advanced 5707971a8bfSPeter Brune 5717971a8bfSPeter Brune .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESSetJacobian() 5727971a8bfSPeter Brune @*/ 5737971a8bfSPeter Brune PetscErrorCode DMSNESGetPicard(DM dm,PetscErrorCode (**pfunc)(SNES,Vec,Vec,void*),PetscErrorCode (**pjac)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void **ctx) 5747971a8bfSPeter Brune { 5757971a8bfSPeter Brune PetscErrorCode ierr; 576942e3340SBarry Smith DMSNES sdm; 5777971a8bfSPeter Brune 5787971a8bfSPeter Brune PetscFunctionBegin; 5797971a8bfSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 580942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 58122c6f798SBarry Smith if (pfunc) *pfunc = sdm->ops->computepfunction; 58222c6f798SBarry Smith if (pjac) *pjac = sdm->ops->computepjacobian; 5837971a8bfSPeter Brune if (ctx) *ctx = sdm->pctx; 5847971a8bfSPeter Brune PetscFunctionReturn(0); 5857971a8bfSPeter Brune } 5867971a8bfSPeter Brune 5876427ad5bSPeter Brune /* block functions */ 5886427ad5bSPeter Brune 5896427ad5bSPeter Brune #undef __FUNCT__ 5906427ad5bSPeter Brune #define __FUNCT__ "DMSNESSetBlockFunction" 5916427ad5bSPeter Brune /*@C 5926427ad5bSPeter Brune DMSNESSetBlockFunction - set SNES residual evaluation function 5936427ad5bSPeter Brune 5946427ad5bSPeter Brune Not Collective 5956427ad5bSPeter Brune 5966427ad5bSPeter Brune Input Arguments: 5976427ad5bSPeter Brune + dm - DM to be used with SNES 5986427ad5bSPeter Brune . func - residual evaluation function, see SNESSetFunction() for calling sequence 5996427ad5bSPeter Brune - ctx - context for residual evaluation 6006427ad5bSPeter Brune 6016427ad5bSPeter Brune Level: developer 6026427ad5bSPeter Brune 6036427ad5bSPeter Brune Note: 6046427ad5bSPeter Brune Mostly for use in DM implementations and transferred to a block function rather than being called from here. 6056427ad5bSPeter Brune 6066427ad5bSPeter Brune .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESSetJacobian() 6076427ad5bSPeter Brune @*/ 6086427ad5bSPeter Brune PetscErrorCode DMSNESSetBlockFunction(DM dm,PetscErrorCode (*func)(SNES,Vec,Vec,void*),void *ctx) 6096427ad5bSPeter Brune { 6106427ad5bSPeter Brune PetscErrorCode ierr; 611942e3340SBarry Smith DMSNES sdm; 6126427ad5bSPeter Brune 6136427ad5bSPeter Brune PetscFunctionBegin; 6146427ad5bSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 615fdaff8d6SPeter Brune if (func || ctx) { 616942e3340SBarry Smith ierr = DMGetDMSNESWrite(dm,&sdm);CHKERRQ(ierr); 617fdaff8d6SPeter Brune } 61822c6f798SBarry Smith if (func) sdm->ops->computeblockfunction = func; 6196427ad5bSPeter Brune if (ctx) sdm->blockfunctionctx = ctx; 6206427ad5bSPeter Brune PetscFunctionReturn(0); 6216427ad5bSPeter Brune } 6226427ad5bSPeter Brune 6236427ad5bSPeter Brune #undef __FUNCT__ 6246427ad5bSPeter Brune #define __FUNCT__ "DMSNESGetBlockFunction" 6256427ad5bSPeter Brune /*@C 6266427ad5bSPeter Brune DMSNESGetBlockFunction - get SNES residual evaluation function 6276427ad5bSPeter Brune 6286427ad5bSPeter Brune Not Collective 6296427ad5bSPeter Brune 6306427ad5bSPeter Brune Input Argument: 6316427ad5bSPeter Brune . dm - DM to be used with SNES 6326427ad5bSPeter Brune 6336427ad5bSPeter Brune Output Arguments: 6346427ad5bSPeter Brune + func - residual evaluation function, see SNESSetFunction() for calling sequence 6356427ad5bSPeter Brune - ctx - context for residual evaluation 6366427ad5bSPeter Brune 6376427ad5bSPeter Brune Level: developer 6386427ad5bSPeter Brune 6396427ad5bSPeter Brune .seealso: DMSNESSetContext(), DMSNESSetFunction(), SNESSetFunction() 6406427ad5bSPeter Brune @*/ 6416427ad5bSPeter Brune PetscErrorCode DMSNESGetBlockFunction(DM dm,PetscErrorCode (**func)(SNES,Vec,Vec,void*),void **ctx) 6426427ad5bSPeter Brune { 6436427ad5bSPeter Brune PetscErrorCode ierr; 644942e3340SBarry Smith DMSNES sdm; 6456427ad5bSPeter Brune 6466427ad5bSPeter Brune PetscFunctionBegin; 6476427ad5bSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 648942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 64922c6f798SBarry Smith if (func) *func = sdm->ops->computeblockfunction; 6506427ad5bSPeter Brune if (ctx) *ctx = sdm->blockfunctionctx; 6516427ad5bSPeter Brune PetscFunctionReturn(0); 6526427ad5bSPeter Brune } 6536427ad5bSPeter Brune 6546427ad5bSPeter Brune 6556427ad5bSPeter Brune #undef __FUNCT__ 6566427ad5bSPeter Brune #define __FUNCT__ "DMSNESSetBlockJacobian" 6576427ad5bSPeter Brune /*@C 6586427ad5bSPeter Brune DMSNESSetJacobian - set SNES Jacobian evaluation function 6596427ad5bSPeter Brune 6606427ad5bSPeter Brune Not Collective 6616427ad5bSPeter Brune 6626427ad5bSPeter Brune Input Argument: 6636427ad5bSPeter Brune + dm - DM to be used with SNES 6646427ad5bSPeter Brune . func - Jacobian evaluation function, see SNESSetJacobian() for calling sequence 6656427ad5bSPeter Brune - ctx - context for residual evaluation 6666427ad5bSPeter Brune 6676427ad5bSPeter Brune Level: advanced 6686427ad5bSPeter Brune 6696427ad5bSPeter Brune Note: 6706427ad5bSPeter Brune Mostly for use in DM implementations and transferred to a block function rather than being called from here. 6716427ad5bSPeter Brune 6726427ad5bSPeter Brune .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESGetJacobian(), SNESSetJacobian() 6736427ad5bSPeter Brune @*/ 6746427ad5bSPeter Brune PetscErrorCode DMSNESSetBlockJacobian(DM dm,PetscErrorCode (*func)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *ctx) 6756427ad5bSPeter Brune { 6766427ad5bSPeter Brune PetscErrorCode ierr; 677942e3340SBarry Smith DMSNES sdm; 6786427ad5bSPeter Brune 6796427ad5bSPeter Brune PetscFunctionBegin; 6806427ad5bSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 681fdaff8d6SPeter Brune if (func || ctx) { 682942e3340SBarry Smith ierr = DMGetDMSNESWrite(dm,&sdm);CHKERRQ(ierr); 683fdaff8d6SPeter Brune } 68422c6f798SBarry Smith if (func) sdm->ops->computeblockjacobian = func; 6856427ad5bSPeter Brune if (ctx) sdm->blockjacobianctx = ctx; 6866427ad5bSPeter Brune PetscFunctionReturn(0); 6876427ad5bSPeter Brune } 6886427ad5bSPeter Brune 6896427ad5bSPeter Brune #undef __FUNCT__ 6906427ad5bSPeter Brune #define __FUNCT__ "DMSNESGetBlockJacobian" 6916427ad5bSPeter Brune /*@C 6926427ad5bSPeter Brune DMSNESGetBlockJacobian - get SNES Jacobian evaluation function 6936427ad5bSPeter Brune 6946427ad5bSPeter Brune Not Collective 6956427ad5bSPeter Brune 6966427ad5bSPeter Brune Input Argument: 6976427ad5bSPeter Brune . dm - DM to be used with SNES 6986427ad5bSPeter Brune 6996427ad5bSPeter Brune Output Arguments: 7006427ad5bSPeter Brune + func - Jacobian evaluation function, see SNESSetJacobian() for calling sequence 7016427ad5bSPeter Brune - ctx - context for residual evaluation 7026427ad5bSPeter Brune 7036427ad5bSPeter Brune Level: advanced 7046427ad5bSPeter Brune 7056427ad5bSPeter Brune .seealso: DMSNESSetContext(), SNESSetFunction(), DMSNESSetJacobian() 7066427ad5bSPeter Brune @*/ 7076427ad5bSPeter Brune PetscErrorCode DMSNESGetBlockJacobian(DM dm,PetscErrorCode (**func)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void **ctx) 7086427ad5bSPeter Brune { 7096427ad5bSPeter Brune PetscErrorCode ierr; 710942e3340SBarry Smith DMSNES sdm; 7116427ad5bSPeter Brune 7126427ad5bSPeter Brune PetscFunctionBegin; 7136427ad5bSPeter Brune PetscValidHeaderSpecific(dm,DM_CLASSID,1); 714942e3340SBarry Smith ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr); 71522c6f798SBarry Smith if (func) *func = sdm->ops->computeblockjacobian; 7166427ad5bSPeter Brune if (ctx) *ctx = sdm->blockjacobianctx; 7176427ad5bSPeter Brune PetscFunctionReturn(0); 7186427ad5bSPeter Brune } 719