1af0996ceSBarry Smith #include <petsc/private/dmpatchimpl.h> /*I "petscdmpatch.h" I*/ 23a19ef87SMatthew G Knepley #include <petscdmda.h> 33a19ef87SMatthew G Knepley 49371c9d4SSatish Balay PetscErrorCode DMSetFromOptions_Patch(DM dm, PetscOptionItems *PetscOptionsObject) { 56fbb21edSJed Brown /* DM_Patch *mesh = (DM_Patch*) dm->data; */ 63a19ef87SMatthew G Knepley 73a19ef87SMatthew G Knepley PetscFunctionBegin; 8d0609cedSBarry Smith PetscOptionsHeadBegin(PetscOptionsObject, "DMPatch Options"); 93a19ef87SMatthew G Knepley /* Handle associated vectors */ 103a19ef87SMatthew G Knepley /* Handle viewing */ 11d0609cedSBarry Smith PetscOptionsHeadEnd(); 123a19ef87SMatthew G Knepley PetscFunctionReturn(0); 133a19ef87SMatthew G Knepley } 143a19ef87SMatthew G Knepley 153a19ef87SMatthew G Knepley /* External function declarations here */ 163a19ef87SMatthew G Knepley extern PetscErrorCode DMSetUp_Patch(DM dm); 173a19ef87SMatthew G Knepley extern PetscErrorCode DMView_Patch(DM dm, PetscViewer viewer); 183a19ef87SMatthew G Knepley extern PetscErrorCode DMCreateGlobalVector_Patch(DM dm, Vec *g); 193a19ef87SMatthew G Knepley extern PetscErrorCode DMCreateLocalVector_Patch(DM dm, Vec *l); 203a19ef87SMatthew G Knepley extern PetscErrorCode DMDestroy_Patch(DM dm); 21276c5506SMatthew G. Knepley extern PetscErrorCode DMCreateSubDM_Patch(DM dm, PetscInt numFields, const PetscInt fields[], IS *is, DM *subdm); 223a19ef87SMatthew G Knepley 239371c9d4SSatish Balay PetscErrorCode DMInitialize_Patch(DM dm) { 243a19ef87SMatthew G Knepley PetscFunctionBegin; 253a19ef87SMatthew G Knepley dm->ops->view = DMView_Patch; 263a19ef87SMatthew G Knepley dm->ops->setfromoptions = DMSetFromOptions_Patch; 273a19ef87SMatthew G Knepley dm->ops->setup = DMSetUp_Patch; 283a19ef87SMatthew G Knepley dm->ops->createglobalvector = DMCreateGlobalVector_Patch; 293a19ef87SMatthew G Knepley dm->ops->createlocalvector = DMCreateLocalVector_Patch; 30184d77edSJed Brown dm->ops->getlocaltoglobalmapping = NULL; 310298fd71SBarry Smith dm->ops->createfieldis = NULL; 32ea78f98cSLisandro Dalcin dm->ops->getcoloring = NULL; 33ea78f98cSLisandro Dalcin dm->ops->creatematrix = NULL; 34ea78f98cSLisandro Dalcin dm->ops->createinterpolation = NULL; 35ea78f98cSLisandro Dalcin dm->ops->createinjection = NULL; 36ea78f98cSLisandro Dalcin dm->ops->refine = NULL; 37ea78f98cSLisandro Dalcin dm->ops->coarsen = NULL; 38ea78f98cSLisandro Dalcin dm->ops->refinehierarchy = NULL; 39ea78f98cSLisandro Dalcin dm->ops->coarsenhierarchy = NULL; 400298fd71SBarry Smith dm->ops->globaltolocalbegin = NULL; 410298fd71SBarry Smith dm->ops->globaltolocalend = NULL; 420298fd71SBarry Smith dm->ops->localtoglobalbegin = NULL; 430298fd71SBarry Smith dm->ops->localtoglobalend = NULL; 443a19ef87SMatthew G Knepley dm->ops->destroy = DMDestroy_Patch; 453a19ef87SMatthew G Knepley dm->ops->createsubdm = DMCreateSubDM_Patch; 463a19ef87SMatthew G Knepley PetscFunctionReturn(0); 473a19ef87SMatthew G Knepley } 483a19ef87SMatthew G Knepley 499371c9d4SSatish Balay PETSC_EXTERN PetscErrorCode DMCreate_Patch(DM dm) { 503a19ef87SMatthew G Knepley DM_Patch *mesh; 513a19ef87SMatthew G Knepley 523a19ef87SMatthew G Knepley PetscFunctionBegin; 533a19ef87SMatthew G Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 54*4dfa11a4SJacob Faibussowitsch PetscCall(PetscNew(&mesh)); 553a19ef87SMatthew G Knepley dm->data = mesh; 563a19ef87SMatthew G Knepley 573a19ef87SMatthew G Knepley mesh->refct = 1; 580298fd71SBarry Smith mesh->dmCoarse = NULL; 59392fa6c6SMatthew G Knepley mesh->patchSize.i = 0; 60392fa6c6SMatthew G Knepley mesh->patchSize.j = 0; 61392fa6c6SMatthew G Knepley mesh->patchSize.k = 0; 62392fa6c6SMatthew G Knepley mesh->patchSize.c = 0; 633a19ef87SMatthew G Knepley 649566063dSJacob Faibussowitsch PetscCall(DMInitialize_Patch(dm)); 653a19ef87SMatthew G Knepley PetscFunctionReturn(0); 663a19ef87SMatthew G Knepley } 673a19ef87SMatthew G Knepley 683a19ef87SMatthew G Knepley /*@ 693a19ef87SMatthew G Knepley DMPatchCreate - Creates a DMPatch object, which is a collections of DMs called patches. 703a19ef87SMatthew G Knepley 71d083f849SBarry Smith Collective 723a19ef87SMatthew G Knepley 733a19ef87SMatthew G Knepley Input Parameter: 743a19ef87SMatthew G Knepley . comm - The communicator for the DMPatch object 753a19ef87SMatthew G Knepley 763a19ef87SMatthew G Knepley Output Parameter: 773a19ef87SMatthew G Knepley . mesh - The DMPatch object 783a19ef87SMatthew G Knepley 7960c22052SBarry Smith Notes: 8060c22052SBarry Smith 8160c22052SBarry Smith This code is incomplete and not used by other parts of PETSc. 8260c22052SBarry Smith 833a19ef87SMatthew G Knepley Level: beginner 843a19ef87SMatthew G Knepley 85db781477SPatrick Sanan .seealso: `DMPatchZoom()` 8660c22052SBarry Smith 873a19ef87SMatthew G Knepley @*/ 889371c9d4SSatish Balay PetscErrorCode DMPatchCreate(MPI_Comm comm, DM *mesh) { 893a19ef87SMatthew G Knepley PetscFunctionBegin; 903a19ef87SMatthew G Knepley PetscValidPointer(mesh, 2); 919566063dSJacob Faibussowitsch PetscCall(DMCreate(comm, mesh)); 929566063dSJacob Faibussowitsch PetscCall(DMSetType(*mesh, DMPATCH)); 933a19ef87SMatthew G Knepley PetscFunctionReturn(0); 943a19ef87SMatthew G Knepley } 953a19ef87SMatthew G Knepley 969371c9d4SSatish Balay PetscErrorCode DMPatchCreateGrid(MPI_Comm comm, PetscInt dim, MatStencil patchSize, MatStencil commSize, MatStencil gridSize, DM *dm) { 973a19ef87SMatthew G Knepley DM_Patch *mesh; 98392fa6c6SMatthew G Knepley DM da; 99392fa6c6SMatthew G Knepley PetscInt dof = 1, width = 1; 1003a19ef87SMatthew G Knepley 1013a19ef87SMatthew G Knepley PetscFunctionBegin; 1029566063dSJacob Faibussowitsch PetscCall(DMPatchCreate(comm, dm)); 1033a19ef87SMatthew G Knepley mesh = (DM_Patch *)(*dm)->data; 1043a19ef87SMatthew G Knepley if (dim < 2) { 1053a19ef87SMatthew G Knepley gridSize.j = 1; 1063a19ef87SMatthew G Knepley patchSize.j = 1; 1073a19ef87SMatthew G Knepley } 1083a19ef87SMatthew G Knepley if (dim < 3) { 1093a19ef87SMatthew G Knepley gridSize.k = 1; 1103a19ef87SMatthew G Knepley patchSize.k = 1; 1113a19ef87SMatthew G Knepley } 1129566063dSJacob Faibussowitsch PetscCall(DMCreate(comm, &da)); 1139566063dSJacob Faibussowitsch PetscCall(DMSetType(da, DMDA)); 1149566063dSJacob Faibussowitsch PetscCall(DMSetDimension(da, dim)); 1159566063dSJacob Faibussowitsch PetscCall(DMDASetSizes(da, gridSize.i, gridSize.j, gridSize.k)); 1169566063dSJacob Faibussowitsch PetscCall(DMDASetBoundaryType(da, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE)); 1179566063dSJacob Faibussowitsch PetscCall(DMDASetDof(da, dof)); 1189566063dSJacob Faibussowitsch PetscCall(DMDASetStencilType(da, DMDA_STENCIL_BOX)); 1199566063dSJacob Faibussowitsch PetscCall(DMDASetStencilWidth(da, width)); 1208865f1eaSKarl Rupp 1213a19ef87SMatthew G Knepley mesh->dmCoarse = da; 1228865f1eaSKarl Rupp 1239566063dSJacob Faibussowitsch PetscCall(DMPatchSetPatchSize(*dm, patchSize)); 1249566063dSJacob Faibussowitsch PetscCall(DMPatchSetCommSize(*dm, commSize)); 1253a19ef87SMatthew G Knepley PetscFunctionReturn(0); 1263a19ef87SMatthew G Knepley } 127