Actual source code: patchcreate.c
1: #include <petsc/private/dmpatchimpl.h>
2: #include <petscdmda.h>
4: PetscErrorCode DMSetFromOptions_Patch(PetscOptionItems *PetscOptionsObject,DM dm)
5: {
6: /* DM_Patch *mesh = (DM_Patch*) dm->data; */
11: PetscOptionsHead(PetscOptionsObject,"DMPatch Options");
12: /* Handle associated vectors */
13: /* Handle viewing */
14: PetscOptionsTail();
15: return(0);
16: }
18: /* External function declarations here */
19: extern PetscErrorCode DMSetUp_Patch(DM dm);
20: extern PetscErrorCode DMView_Patch(DM dm, PetscViewer viewer);
21: extern PetscErrorCode DMCreateGlobalVector_Patch(DM dm, Vec *g);
22: extern PetscErrorCode DMCreateLocalVector_Patch(DM dm, Vec *l);
23: extern PetscErrorCode DMDestroy_Patch(DM dm);
24: extern PetscErrorCode DMCreateSubDM_Patch(DM dm, PetscInt numFields, const PetscInt fields[], IS *is, DM *subdm);
26: PetscErrorCode DMInitialize_Patch(DM dm)
27: {
29: dm->ops->view = DMView_Patch;
30: dm->ops->setfromoptions = DMSetFromOptions_Patch;
31: dm->ops->setup = DMSetUp_Patch;
32: dm->ops->createglobalvector = DMCreateGlobalVector_Patch;
33: dm->ops->createlocalvector = DMCreateLocalVector_Patch;
34: dm->ops->getlocaltoglobalmapping = NULL;
35: dm->ops->createfieldis = NULL;
36: dm->ops->getcoloring = NULL;
37: dm->ops->creatematrix = NULL;
38: dm->ops->createinterpolation = NULL;
39: dm->ops->createinjection = NULL;
40: dm->ops->refine = NULL;
41: dm->ops->coarsen = NULL;
42: dm->ops->refinehierarchy = NULL;
43: dm->ops->coarsenhierarchy = NULL;
44: dm->ops->globaltolocalbegin = NULL;
45: dm->ops->globaltolocalend = NULL;
46: dm->ops->localtoglobalbegin = NULL;
47: dm->ops->localtoglobalend = NULL;
48: dm->ops->destroy = DMDestroy_Patch;
49: dm->ops->createsubdm = DMCreateSubDM_Patch;
50: return(0);
51: }
53: PETSC_EXTERN PetscErrorCode DMCreate_Patch(DM dm)
54: {
55: DM_Patch *mesh;
60: PetscNewLog(dm,&mesh);
61: dm->data = mesh;
63: mesh->refct = 1;
64: mesh->dmCoarse = NULL;
65: mesh->patchSize.i = 0;
66: mesh->patchSize.j = 0;
67: mesh->patchSize.k = 0;
68: mesh->patchSize.c = 0;
70: DMInitialize_Patch(dm);
71: return(0);
72: }
74: /*@
75: DMPatchCreate - Creates a DMPatch object, which is a collections of DMs called patches.
77: Collective
79: Input Parameter:
80: . comm - The communicator for the DMPatch object
82: Output Parameter:
83: . mesh - The DMPatch object
85: Notes:
87: This code is incomplete and not used by other parts of PETSc.
89: Level: beginner
91: .seealso: DMPatchZoom()
93: @*/
94: PetscErrorCode DMPatchCreate(MPI_Comm comm, DM *mesh)
95: {
100: DMCreate(comm, mesh);
101: DMSetType(*mesh, DMPATCH);
102: return(0);
103: }
105: PetscErrorCode DMPatchCreateGrid(MPI_Comm comm, PetscInt dim, MatStencil patchSize, MatStencil commSize, MatStencil gridSize, DM *dm)
106: {
107: DM_Patch *mesh;
108: DM da;
109: PetscInt dof = 1, width = 1;
113: DMPatchCreate(comm, dm);
114: mesh = (DM_Patch*) (*dm)->data;
115: if (dim < 2) {
116: gridSize.j = 1;
117: patchSize.j = 1;
118: }
119: if (dim < 3) {
120: gridSize.k = 1;
121: patchSize.k = 1;
122: }
123: DMCreate(comm, &da);
124: DMSetType(da, DMDA);
125: DMSetDimension(da, dim);
126: DMDASetSizes(da, gridSize.i, gridSize.j, gridSize.k);
127: DMDASetBoundaryType(da, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE);
128: DMDASetDof(da, dof);
129: DMDASetStencilType(da, DMDA_STENCIL_BOX);
130: DMDASetStencilWidth(da, width);
132: mesh->dmCoarse = da;
134: DMPatchSetPatchSize(*dm, patchSize);
135: DMPatchSetCommSize(*dm, commSize);
136: return(0);
137: }