xref: /petsc/src/dm/impls/moab/dmmoab.cxx (revision 032b8ab68d4668ecf17e7ef7c62e7a29937bca10)
1 #include <petsc-private/dmmbimpl.h> /*I  "petscdm.h"   I*/
2 #include <petsc-private/vecimpl.h> /*I  "petscdm.h"   I*/
3 
4 #include <petscdmmoab.h>
5 #include <MBTagConventions.hpp>
6 #include <sstream>
7 
8 
9 #undef __FUNCT__
10 #define __FUNCT__ "DMGlobalToLocalBegin_Moab"
11 PetscErrorCode  DMGlobalToLocalBegin_Moab(DM dm,Vec g,InsertMode mode,Vec l)
12 {
13   PetscErrorCode    ierr;
14   DM_Moab         *dmmoab = (DM_Moab*)dm->data;
15 
16   PetscFunctionBegin;
17   ierr = VecScatterBegin(dmmoab->ltog_sendrecv,g,l,mode,SCATTER_FORWARD/*SCATTER_FORWARD*/);CHKERRQ(ierr);
18   PetscFunctionReturn(0);
19 }
20 
21 
22 #undef __FUNCT__
23 #define __FUNCT__ "DMGlobalToLocalEnd_Moab"
24 PetscErrorCode  DMGlobalToLocalEnd_Moab(DM dm,Vec g,InsertMode mode,Vec l)
25 {
26   PetscErrorCode    ierr;
27   DM_Moab         *dmmoab = (DM_Moab*)dm->data;
28 
29   PetscFunctionBegin;
30   ierr = VecScatterEnd(dmmoab->ltog_sendrecv,g,l,mode,SCATTER_FORWARD/*SCATTER_FORWARD*/);CHKERRQ(ierr);
31   PetscFunctionReturn(0);
32 }
33 
34 
35 #undef __FUNCT__
36 #define __FUNCT__ "DMLocalToGlobalBegin_Moab"
37 PetscErrorCode  DMLocalToGlobalBegin_Moab(DM dm,Vec l,InsertMode mode,Vec g)
38 {
39   PetscErrorCode    ierr;
40   DM_Moab         *dmmoab = (DM_Moab*)dm->data;
41 
42   PetscFunctionBegin;
43 //  PetscPrintf(PETSC_COMM_WORLD,"\n Inside local-global begin. Printing global and local vecs.\n");
44 //  ierr = VecView(g, PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
45 //  ierr = VecView(l, PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
46   ierr = VecScatterBegin(dmmoab->ltog_sendrecv,l,g,mode,SCATTER_REVERSE);CHKERRQ(ierr);
47   PetscFunctionReturn(0);
48 }
49 
50 
51 #undef __FUNCT__
52 #define __FUNCT__ "DMLocalToGlobalEnd_Moab"
53 PetscErrorCode  DMLocalToGlobalEnd_Moab(DM dm,Vec l,InsertMode mode,Vec g)
54 {
55   PetscErrorCode    ierr;
56   DM_Moab         *dmmoab = (DM_Moab*)dm->data;
57 
58   PetscFunctionBegin;
59   ierr = VecScatterEnd(dmmoab->ltog_sendrecv,l,g,mode,SCATTER_REVERSE);CHKERRQ(ierr);
60   PetscFunctionReturn(0);
61 }
62 
63 
64 #undef __FUNCT__
65 #define __FUNCT__ "DMDestroy_Moab"
66 PetscErrorCode DMDestroy_Moab(DM dm)
67 {
68   PetscErrorCode ierr;
69   DM_Moab         *dmmoab = (DM_Moab*)dm->data;
70 
71   PetscFunctionBegin;
72   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
73   if (dmmoab->icreatedinstance) {
74     delete dmmoab->mbiface;
75   }
76   dmmoab->mbiface = NULL;
77   dmmoab->pcomm = NULL;
78   delete dmmoab->vlocal;
79   delete dmmoab->vowned;
80   delete dmmoab->vghost;
81   delete dmmoab->elocal;
82   delete dmmoab->eghost;
83   ierr = VecScatterDestroy(&dmmoab->ltog_sendrecv);CHKERRQ(ierr);
84   ierr = ISLocalToGlobalMappingDestroy(&dmmoab->ltog_map);CHKERRQ(ierr);
85   ierr = PetscFree(dm->data);CHKERRQ(ierr);
86   PetscFunctionReturn(0);
87 }
88 
89 #undef __FUNCT__
90 #define __FUNCT__ "DMSetUp_Moab"
91 PetscErrorCode DMSetUp_Moab(DM dm)
92 {
93   PetscErrorCode          ierr;
94   moab::ErrorCode         merr;
95   Vec                     local, global;
96   IS                      from;
97   moab::Range::iterator   iter;
98   PetscInt                bs, *gsindices;
99   DM_Moab                *dmmoab = (DM_Moab*)dm->data;
100   PetscInt                count,dof,totsize;
101 
102   PetscFunctionBegin;
103   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
104   /* Get the local and shared vertices and cache it */
105   if (dmmoab->mbiface == PETSC_NULL || dmmoab->pcomm == PETSC_NULL) SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ORDER, "Set the MOAB Interface and ParallelComm objects before calling SetUp.");
106 
107   /* store the current mesh dimension */
108   merr = dmmoab->mbiface->get_dimension(dmmoab->dim);MBERRNM(merr);
109 
110   /* Get the entities recursively in the current part of the mesh */
111   if (dmmoab->vlocal->empty()) {
112     merr = dmmoab->mbiface->get_entities_by_type(0,moab::MBVERTEX,*dmmoab->vlocal,true);MBERRNM(merr);
113     *dmmoab->vowned = *dmmoab->vlocal;
114 
115     /* filter based on parallel status */
116     merr = dmmoab->pcomm->filter_pstatus(*dmmoab->vowned,PSTATUS_NOT_OWNED,PSTATUS_NOT);MBERRNM(merr);
117     *dmmoab->vghost = moab::subtract(*dmmoab->vlocal, *dmmoab->vowned);
118 
119     dmmoab->nloc = dmmoab->vowned->size();
120     dmmoab->nghost = dmmoab->vghost->size();
121     ierr = MPI_Allreduce(&dmmoab->nloc, &dmmoab->n, 1, MPI_INTEGER, MPI_SUM, ((PetscObject)dm)->comm);CHKERRQ(ierr);
122   }
123 
124 //  PetscPrintf(PETSC_COMM_SELF, "\n Local vertices size = %D and shared vertices = %D", dmmoab->vowned->size(), dmmoab->vghost->size());
125 //  PetscPrintf(PETSC_COMM_SELF, "\n Global vertices size = %D and local vertices = %D", dmmoab->n, dmmoab->nloc);
126 
127   /* get the information about the local elements in the mesh */
128   {
129     dmmoab->elocal->clear();
130     dmmoab->eghost->clear();
131 //    PetscPrintf(PETSC_COMM_SELF, "\n Getting all elements of dimension = %D", dmmoab->dim);
132     merr = dmmoab->mbiface->get_entities_by_dimension(0, dmmoab->dim, *dmmoab->elocal, true);CHKERRQ(merr);
133     *dmmoab->eghost = *dmmoab->elocal;
134     merr = dmmoab->pcomm->filter_pstatus(*dmmoab->elocal,PSTATUS_NOT_OWNED,PSTATUS_NOT);MBERRNM(merr);
135     *dmmoab->eghost = moab::subtract(*dmmoab->eghost, *dmmoab->elocal);
136 
137     dmmoab->neleloc = dmmoab->elocal->size();
138     ierr = MPI_Allreduce(&dmmoab->neleloc, &dmmoab->nele, 1, MPI_INTEGER, MPI_SUM, ((PetscObject)dm)->comm);CHKERRQ(ierr);
139 //    PetscPrintf(PETSC_COMM_SELF, "\n Global elements = %D and local elements = %D", dmmoab->nele, dmmoab->neleloc);
140   }
141 
142   bs = dmmoab->bs;
143   if (!dmmoab->ltog_tag) {
144     // Get the global ID tag. The global ID tag is applied to each
145     // vertex. It acts as an global identifier which MOAB uses to
146     // assemble the individual pieces of the mesh:
147     merr = dmmoab->mbiface->tag_get_handle(GLOBAL_ID_TAG_NAME, dmmoab->ltog_tag);MBERRNM(merr);
148   }
149 
150   {
151     count=0;
152     totsize=dmmoab->vlocal->size();
153     ierr = PetscMalloc(totsize*sizeof(PetscInt), &gsindices);CHKERRQ(ierr);
154     /* first get the local indices */
155     for(iter = dmmoab->vowned->begin(); iter != dmmoab->vowned->end(); iter++) {
156       merr = dmmoab->mbiface->tag_get_data(dmmoab->ltog_tag,&(*iter),1,&dof);MBERRNM(merr);
157       gsindices[count++] = (dof);
158     }
159     /* now get the ghosted indices */
160     for(iter = dmmoab->vghost->begin(); iter != dmmoab->vghost->end(); iter++) {
161       merr = dmmoab->mbiface->tag_get_data(dmmoab->ltog_tag,&(*iter),1,&dof);MBERRNM(merr);
162       gsindices[count++] = (dof);
163     }
164 
165     /* Create Global to Local Vector Scatter Context */
166     ierr = DMCreateGlobalVector_Moab(dm, &global);CHKERRQ(ierr);
167     ierr = DMCreateLocalVector_Moab(dm, &local);CHKERRQ(ierr);
168 
169     /* global to local must retrieve ghost points */
170     ierr = ISCreateBlock(((PetscObject)dm)->comm,bs,totsize,gsindices,PETSC_COPY_VALUES,&from);CHKERRQ(ierr);
171 //    ierr = ISCreateGeneral(((PetscObject)dm)->comm,totsize*bs,gsindices,PETSC_COPY_VALUES,&from);CHKERRQ(ierr);
172 
173     PetscInt gsiz, lsiz;
174     VecGetLocalSize(global,&gsiz);
175     VecGetLocalSize(local,&lsiz);
176 //    PetscPrintf(PETSC_COMM_SELF, "\n Global vec size = %D and local vec size = %D; Local=%D; Ghosted=%D; Start=%D\n Printing From and To IS \n", gsiz, lsiz, dmmoab->nloc, dmmoab->nghost, gsindices[0]);
177 //    ISView(from, PETSC_VIEWER_STDOUT_WORLD);
178 
179     ierr = VecScatterCreate(local,from,global,from,&dmmoab->ltog_sendrecv);CHKERRQ(ierr);
180     ierr = ISDestroy(&from);CHKERRQ(ierr);
181     ierr = VecDestroy(&local);CHKERRQ(ierr);
182     ierr = VecDestroy(&global);CHKERRQ(ierr);
183     ierr = PetscFree(gsindices);CHKERRQ(ierr);
184 
185     /* create the local to global mapping for all indices */
186 //    ierr = ISLocalToGlobalMappingCreate(((PetscObject)dm)->comm,dmmoab->nghost*bs,gsindices,PETSC_OWN_POINTER,&dmmoab->ltog_map);CHKERRQ(ierr);
187   }
188 
189   PetscFunctionReturn(0);
190 }
191 
192 #undef __FUNCT__
193 #define __FUNCT__ "DMCreate_Moab"
194 PETSC_EXTERN PetscErrorCode DMCreate_Moab(DM dm)
195 {
196   PetscErrorCode ierr;
197 
198   PetscFunctionBegin;
199   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
200   ierr = PetscNewLog(dm,&dm->data);CHKERRQ(ierr);
201 
202   ((DM_Moab*)dm->data)->bs = 1;
203   ((DM_Moab*)dm->data)->n = 0;
204   ((DM_Moab*)dm->data)->nloc = 0;
205   ((DM_Moab*)dm->data)->nele = 0;
206   ((DM_Moab*)dm->data)->neleloc = 0;
207   ((DM_Moab*)dm->data)->nghost = 0;
208   ((DM_Moab*)dm->data)->ltog_map = PETSC_NULL;
209   ((DM_Moab*)dm->data)->ltog_sendrecv = PETSC_NULL;
210 
211   ((DM_Moab*)dm->data)->vlocal = new moab::Range();
212   ((DM_Moab*)dm->data)->vowned = new moab::Range();
213   ((DM_Moab*)dm->data)->vghost = new moab::Range();
214   ((DM_Moab*)dm->data)->elocal = new moab::Range();
215   ((DM_Moab*)dm->data)->eghost = new moab::Range();
216 
217   dm->ops->createglobalvector              = DMCreateGlobalVector_Moab;
218   dm->ops->createlocalvector               = DMCreateLocalVector_Moab;
219   dm->ops->creatematrix                    = DMCreateMatrix_Moab;
220   dm->ops->setup                           = DMSetUp_Moab;
221   dm->ops->destroy                         = DMDestroy_Moab;
222   dm->ops->globaltolocalbegin              = DMGlobalToLocalBegin_Moab;
223   dm->ops->globaltolocalend                = DMGlobalToLocalEnd_Moab;
224   dm->ops->localtoglobalbegin              = DMLocalToGlobalBegin_Moab;
225   dm->ops->localtoglobalend                = DMLocalToGlobalEnd_Moab;
226   PetscFunctionReturn(0);
227 }
228 
229 #undef __FUNCT__
230 #define __FUNCT__ "DMMoabCreate"
231 /*@
232   DMMoabCreate - Creates a DMMoab object, which encapsulates a moab instance
233 
234   Collective on MPI_Comm
235 
236   Input Parameter:
237 . comm - The communicator for the DMMoab object
238 
239   Output Parameter:
240 . dmb  - The DMMoab object
241 
242   Level: beginner
243 
244 .keywords: DMMoab, create
245 @*/
246 PetscErrorCode DMMoabCreate(MPI_Comm comm, DM *dmb)
247 {
248   PetscErrorCode ierr;
249 
250   PetscFunctionBegin;
251   PetscValidPointer(dmb,2);
252   ierr = DMCreate(comm, dmb);CHKERRQ(ierr);
253   ierr = DMSetType(*dmb, DMMOAB);CHKERRQ(ierr);
254   PetscFunctionReturn(0);
255 }
256 
257 #undef __FUNCT__
258 #define __FUNCT__ "DMMoabCreateMoab"
259 /*@
260   DMMoabCreate - Creates a DMMoab object, optionally from an instance and other data
261 
262   Collective on MPI_Comm
263 
264   Input Parameter:
265 . comm - The communicator for the DMMoab object
266 . mbiface - (ptr to) the MOAB Instance; if passed in NULL, MOAB instance is created inside PETSc, and destroyed
267          along with the DMMoab
268 . pcomm - (ptr to) a ParallelComm; if NULL, creates one internally for the whole communicator
269 . ltog_tag - A tag to use to retrieve global id for an entity; if 0, will use GLOBAL_ID_TAG_NAME/tag
270 . range - If non-NULL, contains range of entities to which DOFs will be assigned
271 
272   Output Parameter:
273 . dmb  - The DMMoab object
274 
275   Level: intermediate
276 
277 .keywords: DMMoab, create
278 @*/
279 PetscErrorCode DMMoabCreateMoab(MPI_Comm comm, moab::Interface *mbiface, moab::ParallelComm *pcomm, moab::Tag *ltog_tag, moab::Range *range, DM *dmb)
280 {
281   PetscErrorCode ierr;
282   moab::ErrorCode merr;
283   DM_Moab        *dmmoab;
284 
285   PetscFunctionBegin;
286   PetscValidPointer(dmb,6);
287   ierr = DMMoabCreate(comm, dmb);CHKERRQ(ierr);
288   dmmoab = (DM_Moab*)(*dmb)->data;
289 
290   if (!mbiface) {
291     mbiface = new moab::Core();
292     dmmoab->icreatedinstance = PETSC_TRUE;
293   }
294   else
295     dmmoab->icreatedinstance = PETSC_FALSE;
296 
297   if (!pcomm) {
298     moab::EntityHandle rootset,partnset;
299     PetscInt rank, nprocs;
300     ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr);
301     ierr = MPI_Comm_size(comm, &nprocs);CHKERRQ(ierr);
302 
303     // Create root sets for each mesh.  Then pass these
304     // to the load_file functions to be populated.
305     merr = mbiface->create_meshset(moab::MESHSET_SET, rootset);
306     MBERR("Creating root set failed", merr);
307     merr = mbiface->create_meshset(moab::MESHSET_SET, partnset);
308     MBERR("Creating partition set failed", merr);
309 
310     // Create the parallel communicator object with the partition handle associated with MOAB
311     pcomm = moab::ParallelComm::get_pcomm(mbiface, partnset, &comm);
312   }
313 
314   if (!ltog_tag) {
315     merr = mbiface->tag_get_handle(GLOBAL_ID_TAG_NAME, *ltog_tag);MBERRNM(merr);
316   }
317   else {
318     ierr = DMMoabSetLocalToGlobalTag(*dmb, *ltog_tag);CHKERRQ(ierr);
319   }
320 
321     // do the initialization of the DM
322   dmmoab->bs       = 1;
323   ierr = DMMoabSetParallelComm(*dmb, pcomm);CHKERRQ(ierr);
324   dmmoab->ltog_tag = *ltog_tag;
325   if (range) {
326     ierr = DMMoabSetRange(*dmb, range);CHKERRQ(ierr);
327   }
328   PetscFunctionReturn(0);
329 }
330 
331 #undef __FUNCT__
332 #define __FUNCT__ "DMMoabSetParallelComm"
333 /*@
334   DMMoabSetParallelComm - Set the ParallelComm used with this DMMoab
335 
336   Collective on MPI_Comm
337 
338   Input Parameter:
339 . dm    - The DMMoab object being set
340 . pcomm - The ParallelComm being set on the DMMoab
341 
342   Level: beginner
343 
344 .keywords: DMMoab, create
345 @*/
346 PetscErrorCode DMMoabSetParallelComm(DM dm,moab::ParallelComm *pcomm)
347 {
348   DM_Moab        *dmmoab = (DM_Moab*)(dm)->data;
349 
350   PetscFunctionBegin;
351   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
352   dmmoab->pcomm = pcomm;
353   dmmoab->mbiface = pcomm->get_moab();
354   dmmoab->icreatedinstance = PETSC_FALSE;
355   PetscFunctionReturn(0);
356 }
357 
358 
359 #undef __FUNCT__
360 #define __FUNCT__ "DMMoabGetParallelComm"
361 /*@
362   DMMoabGetParallelComm - Get the ParallelComm used with this DMMoab
363 
364   Collective on MPI_Comm
365 
366   Input Parameter:
367 . dm    - The DMMoab object being set
368 
369   Output Parameter:
370 . pcomm - The ParallelComm for the DMMoab
371 
372   Level: beginner
373 
374 .keywords: DMMoab, create
375 @*/
376 PetscErrorCode DMMoabGetParallelComm(DM dm,moab::ParallelComm **pcomm)
377 {
378   PetscFunctionBegin;
379   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
380   *pcomm = ((DM_Moab*)(dm)->data)->pcomm;
381   PetscFunctionReturn(0);
382 }
383 
384 
385 #undef __FUNCT__
386 #define __FUNCT__ "DMMoabSetInterface"
387 /*@
388   DMMoabSetInterface - Set the MOAB instance used with this DMMoab
389 
390   Collective on MPI_Comm
391 
392   Input Parameter:
393 . dm      - The DMMoab object being set
394 . mbiface - The MOAB instance being set on this DMMoab
395 
396   Level: beginner
397 
398 .keywords: DMMoab, create
399 @*/
400 PetscErrorCode DMMoabSetInterface(DM dm,moab::Interface *mbiface)
401 {
402   DM_Moab        *dmmoab = (DM_Moab*)(dm)->data;
403 
404   PetscFunctionBegin;
405   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
406   dmmoab->pcomm = NULL;
407   dmmoab->mbiface = mbiface;
408   dmmoab->icreatedinstance = PETSC_FALSE;
409   PetscFunctionReturn(0);
410 }
411 
412 
413 #undef __FUNCT__
414 #define __FUNCT__ "DMMoabGetInterface"
415 /*@
416   DMMoabGetInterface - Get the MOAB instance used with this DMMoab
417 
418   Collective on MPI_Comm
419 
420   Input Parameter:
421 . dm      - The DMMoab object being set
422 
423   Output Parameter:
424 . mbiface - The MOAB instance set on this DMMoab
425 
426   Level: beginner
427 
428 .keywords: DMMoab, create
429 @*/
430 PetscErrorCode DMMoabGetInterface(DM dm,moab::Interface **mbiface)
431 {
432   PetscErrorCode   ierr;
433   static PetscBool cite = PETSC_FALSE;
434 
435   PetscFunctionBegin;
436   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
437   ierr = PetscCitationsRegister("@techreport{tautges_moab:_2004,\n  type = {{SAND2004-1592}},\n  title = {{MOAB:} A Mesh-Oriented Database},  institution = {Sandia National Laboratories},\n  author = {Tautges, T. J. and Meyers, R. and Merkley, K. and Stimpson, C. and Ernst, C.},\n  year = {2004},  note = {Report}\n}\n",&cite);CHKERRQ(ierr);
438   *mbiface = ((DM_Moab*)dm->data)->mbiface;
439   PetscFunctionReturn(0);
440 }
441 
442 
443 #undef __FUNCT__
444 #define __FUNCT__ "DMMoabSetRange"
445 /*@
446   DMMoabSetRange - Set the entities having DOFs on this DMMoab
447 
448   Collective on MPI_Comm
449 
450   Input Parameter:
451 . dm    - The DMMoab object being set
452 . range - The entities treated by this DMMoab
453 
454   Level: beginner
455 
456 .keywords: DMMoab, create
457 @*/
458 PetscErrorCode DMMoabSetRange(DM dm,moab::Range *range)
459 {
460   moab::ErrorCode merr;
461   PetscErrorCode  ierr;
462   DM_Moab        *dmmoab = (DM_Moab*)(dm)->data;
463 
464   PetscFunctionBegin;
465   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
466   dmmoab->vlocal->clear();
467   dmmoab->vowned->clear();
468   dmmoab->vlocal->insert(range->begin(), range->end());
469   *dmmoab->vowned = *dmmoab->vlocal;
470   merr = dmmoab->pcomm->filter_pstatus(*dmmoab->vowned,PSTATUS_NOT_OWNED,PSTATUS_NOT);MBERRNM(merr);
471   *dmmoab->vghost = moab::subtract(*range, *dmmoab->vowned);
472   dmmoab->nloc=dmmoab->vowned->size();
473   dmmoab->nghost=dmmoab->vghost->size();
474   ierr = MPI_Allreduce(&dmmoab->nloc, &dmmoab->n, 1, MPI_INTEGER, MPI_SUM, ((PetscObject)dm)->comm);CHKERRQ(ierr);
475   PetscFunctionReturn(0);
476 }
477 
478 
479 #undef __FUNCT__
480 #define __FUNCT__ "DMMoabGetRange"
481 /*@
482   DMMoabGetRange - Get the entities having DOFs on this DMMoab
483 
484   Collective on MPI_Comm
485 
486   Input Parameter:
487 . dm    - The DMMoab object being set
488 
489   Output Parameter:
490 . range - The entities treated by this DMMoab
491 
492   Level: beginner
493 
494 .keywords: DMMoab, create
495 @*/
496 PetscErrorCode DMMoabGetRange(DM dm,moab::Range **range)
497 {
498   PetscFunctionBegin;
499   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
500   *range = ((DM_Moab*)dm->data)->vowned;
501   PetscFunctionReturn(0);
502 }
503 
504 #undef __FUNCT__
505 #define __FUNCT__ "DMMoabSetLocalToGlobalTag"
506 /*@
507   DMMoabSetLocalToGlobalTag - Set the tag used for local to global numbering
508 
509   Collective on MPI_Comm
510 
511   Input Parameter:
512 . dm      - The DMMoab object being set
513 . ltogtag - The MOAB tag used for local to global ids
514 
515   Level: beginner
516 
517 .keywords: DMMoab, create
518 @*/
519 PetscErrorCode DMMoabSetLocalToGlobalTag(DM dm,moab::Tag ltogtag)
520 {
521   PetscFunctionBegin;
522   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
523   ((DM_Moab*)dm->data)->ltog_tag = ltogtag;
524   PetscFunctionReturn(0);
525 }
526 
527 
528 #undef __FUNCT__
529 #define __FUNCT__ "DMMoabGetLocalToGlobalTag"
530 /*@
531   DMMoabGetLocalToGlobalTag - Get the tag used for local to global numbering
532 
533   Collective on MPI_Comm
534 
535   Input Parameter:
536 . dm      - The DMMoab object being set
537 
538   Output Parameter:
539 . ltogtag - The MOAB tag used for local to global ids
540 
541   Level: beginner
542 
543 .keywords: DMMoab, create
544 @*/
545 PetscErrorCode DMMoabGetLocalToGlobalTag(DM dm,moab::Tag *ltog_tag)
546 {
547   PetscFunctionBegin;
548   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
549   *ltog_tag = ((DM_Moab*)dm->data)->ltog_tag;
550   PetscFunctionReturn(0);
551 }
552 
553 
554 #undef __FUNCT__
555 #define __FUNCT__ "DMMoabSetBlockSize"
556 /*@
557   DMMoabSetBlockSize - Set the block size used with this DMMoab
558 
559   Collective on MPI_Comm
560 
561   Input Parameter:
562 . dm - The DMMoab object being set
563 . bs - The block size used with this DMMoab
564 
565   Level: beginner
566 
567 .keywords: DMMoab, create
568 @*/
569 PetscErrorCode DMMoabSetBlockSize(DM dm,PetscInt bs)
570 {
571   PetscFunctionBegin;
572   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
573   ((DM_Moab*)dm->data)->bs = bs;
574   PetscFunctionReturn(0);
575 }
576 
577 
578 #undef __FUNCT__
579 #define __FUNCT__ "DMMoabGetBlockSize"
580 /*@
581   DMMoabGetBlockSize - Get the block size used with this DMMoab
582 
583   Collective on MPI_Comm
584 
585   Input Parameter:
586 . dm - The DMMoab object being set
587 
588   Output Parameter:
589 . bs - The block size used with this DMMoab
590 
591   Level: beginner
592 
593 .keywords: DMMoab, create
594 @*/
595 PetscErrorCode DMMoabGetBlockSize(DM dm,PetscInt *bs)
596 {
597   PetscFunctionBegin;
598   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
599   *bs = ((DM_Moab*)dm->data)->bs;
600   PetscFunctionReturn(0);
601 }
602 
603