xref: /petsc/src/sys/objects/inherit.c (revision c457296d466dd3de681344323ebedaf97eb226ba)
1 #define PETSC_DLL
2 /*
3      Provides utility routines for manipulating any type of PETSc object.
4 */
5 #include "petscsys.h"  /*I   "petscsys.h"    I*/
6 
7 EXTERN PetscErrorCode PetscObjectGetComm_Petsc(PetscObject,MPI_Comm *);
8 EXTERN PetscErrorCode PetscObjectCompose_Petsc(PetscObject,const char[],PetscObject);
9 EXTERN PetscErrorCode PetscObjectQuery_Petsc(PetscObject,const char[],PetscObject *);
10 EXTERN PetscErrorCode PetscObjectComposeFunction_Petsc(PetscObject,const char[],const char[],void (*)(void));
11 EXTERN PetscErrorCode PetscObjectQueryFunction_Petsc(PetscObject,const char[],void (**)(void));
12 
13 #undef __FUNCT__
14 #define __FUNCT__ "PetscHeaderCreate_Private"
15 /*
16    PetscHeaderCreate_Private - Creates a base PETSc object header and fills
17    in the default values.  Called by the macro PetscHeaderCreate().
18 */
19 PetscErrorCode PETSCSYS_DLLEXPORT PetscHeaderCreate_Private(PetscObject h,PetscClassId classid,PetscInt type,const char class_name[],MPI_Comm comm,
20                                          PetscErrorCode (*des)(PetscObject),PetscErrorCode (*vie)(PetscObject,PetscViewer))
21 {
22   static PetscInt idcnt = 1;
23   PetscErrorCode  ierr;
24 
25   PetscFunctionBegin;
26   h->classid                = classid;
27   h->type                   = type;
28   h->class_name             = (char*)class_name;
29   h->prefix                 = 0;
30   h->refct                  = 1;
31   h->amem                   = -1;
32   h->id                     = idcnt++;
33   h->parentid               = 0;
34   h->qlist                  = 0;
35   h->olist                  = 0;
36   h->bops->destroy          = des;
37   h->bops->view             = vie;
38   h->bops->getcomm          = PetscObjectGetComm_Petsc;
39   h->bops->compose          = PetscObjectCompose_Petsc;
40   h->bops->query            = PetscObjectQuery_Petsc;
41   h->bops->composefunction  = PetscObjectComposeFunction_Petsc;
42   h->bops->queryfunction    = PetscObjectQueryFunction_Petsc;
43   ierr = PetscCommDuplicate(comm,&h->comm,&h->tag);CHKERRQ(ierr);
44 #if defined(PETSC_HAVE_AMS)
45   if (PetscAMSPublishAll && classid != PETSC_VIEWER_CLASSID) {
46     ierr = PetscObjectPublish((PetscObject)h);CHKERRQ(ierr);
47   }
48 #endif
49 
50   PetscFunctionReturn(0);
51 }
52 
53 extern PetscTruth     PetscMemoryCollectMaximumUsage;
54 extern PetscLogDouble PetscMemoryMaximumUsage;
55 
56 #undef __FUNCT__
57 #define __FUNCT__ "PetscHeaderDestroy_Private"
58 /*
59     PetscHeaderDestroy_Private - Destroys a base PETSc object header. Called by
60     the macro PetscHeaderDestroy().
61 */
62 PetscErrorCode PETSCSYS_DLLEXPORT PetscHeaderDestroy_Private(PetscObject h)
63 {
64   PetscErrorCode ierr;
65 
66   PetscFunctionBegin;
67 #if defined(PETSC_HAVE_AMS)
68   if (PetscAMSPublishAll && h->classid != PETSC_VIEWER_CLASSID) {
69     ierr = PetscObjectUnPublish((PetscObject)h);CHKERRQ(ierr);
70   }
71 #endif
72   if (PetscMemoryCollectMaximumUsage) {
73     PetscLogDouble usage;
74     ierr = PetscMemoryGetCurrentUsage(&usage);CHKERRQ(ierr);
75     if (usage > PetscMemoryMaximumUsage) PetscMemoryMaximumUsage = usage;
76   }
77   /* first destroy things that could execute arbitrary code */
78   if (h->python_destroy) {
79     void           *python_context          = h->python_context;
80     PetscErrorCode (*python_destroy)(void*) = h->python_destroy;
81     h->python_context = 0;
82     h->python_destroy = 0;
83     ierr = (*python_destroy)(python_context);CHKERRQ(ierr);
84   }
85   ierr = PetscOListDestroy(h->olist);CHKERRQ(ierr);
86   ierr = PetscCommDestroy(&h->comm);CHKERRQ(ierr);
87   /* next destroy other things */
88   h->classid = PETSCFREEDHEADER;
89   ierr = PetscFree(h->bops);CHKERRQ(ierr);
90   ierr = PetscFListDestroy(&h->qlist);CHKERRQ(ierr);
91   ierr = PetscFree(h->type_name);CHKERRQ(ierr);
92   ierr = PetscFree(h->name);CHKERRQ(ierr);
93   ierr = PetscFree(h->prefix);CHKERRQ(ierr);
94   ierr = PetscFree(h->fortran_func_pointers);CHKERRQ(ierr);
95   ierr = PetscFree(h->intcomposeddata);CHKERRQ(ierr);
96   ierr = PetscFree(h->intcomposedstate);CHKERRQ(ierr);
97   ierr = PetscFree(h->realcomposeddata);CHKERRQ(ierr);
98   ierr = PetscFree(h->realcomposedstate);CHKERRQ(ierr);
99   ierr = PetscFree(h->scalarcomposeddata);CHKERRQ(ierr);
100   ierr = PetscFree(h->scalarcomposedstate);CHKERRQ(ierr);
101   PetscFunctionReturn(0);
102 }
103 
104 #undef __FUNCT__
105 #define __FUNCT__ "PetscObjectAddOptionsHandler"
106 /*@C
107     PetscObjectAddOptionsHandler - Adds an additional function to check for options when XXXSetFromOptions() is called.
108 
109     Not Collective
110 
111     Input Parameter:
112 +   obj - the PETSc object
113 .   handle - function that checks for options
114 .   destroy - function to destroy context if provided
115 -   ctx - optional context for check function
116 
117     Level: developer
118 
119 
120 .seealso: KSPSetFromOptions(), PCSetFromOptions(), SNESSetFromOptions(), PetscObjectProcessOptionsHandlers(), PetscObjectDestroyOptionsHandlers()
121 
122 @*/
123 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectAddOptionsHandler(PetscObject obj,PetscErrorCode (*handle)(PetscObject,void*),PetscErrorCode (*destroy)(PetscObject,void*),void *ctx)
124 {
125   PetscFunctionBegin;
126   if (obj->noptionhandler >= PETSC_MAX_OPTIONS_HANDLER) SETERRQ(obj->comm,PETSC_ERR_ARG_OUTOFRANGE,"To many options handlers added");
127   obj->optionhandler[obj->noptionhandler]   = handle;
128   obj->optiondestroy[obj->noptionhandler]   = destroy;
129   obj->optionctx[obj->noptionhandler++]     = ctx;
130   PetscFunctionReturn(0);
131 }
132 
133 #undef __FUNCT__
134 #define __FUNCT__ "PetscObjectProcessOptionsHandlers"
135 /*@C
136     PetscObjectProcessOptionsHandlers - Calls all the options handler attached to an object
137 
138     Not Collective
139 
140     Input Parameter:
141 .   obj - the PETSc object
142 
143     Level: developer
144 
145 
146 .seealso: KSPSetFromOptions(), PCSetFromOptions(), SNESSetFromOptions(), PetscObjectAddOptionsHandler(), PetscObjectDestroyOptionsHandlers()
147 
148 @*/
149 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectProcessOptionsHandlers(PetscObject obj)
150 {
151   PetscInt       i;
152   PetscErrorCode ierr;
153 
154   PetscFunctionBegin;
155   for (i=0; i<obj->noptionhandler; i++) {
156     ierr = (*obj->optionhandler[i])(obj,obj->optionctx[i]);CHKERRQ(ierr);
157   }
158   PetscFunctionReturn(0);
159 }
160 
161 #undef __FUNCT__
162 #define __FUNCT__ "PetscObjectDestroyOptionsHandlers"
163 /*@C
164     PetscObjectDestroyOptionsHandlers - Destroys all the option handlers attached to an objeft
165 
166     Not Collective
167 
168     Input Parameter:
169 .   obj - the PETSc object
170 
171     Level: developer
172 
173 
174 .seealso: KSPSetFromOptions(), PCSetFromOptions(), SNESSetFromOptions(), PetscObjectAddOptionsHandler(), PetscObjectProcessOptionsHandlers()
175 
176 @*/
177 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectDestroyOptionsHandlers(PetscObject obj)
178 {
179   PetscInt       i;
180   PetscErrorCode ierr;
181 
182   PetscFunctionBegin;
183   for (i=0; i<obj->noptionhandler; i++) {
184     ierr = (*obj->optiondestroy[i])(obj,obj->optionctx[i]);CHKERRQ(ierr);
185   }
186   obj->noptionhandler = 0;
187   PetscFunctionReturn(0);
188 }
189 
190 
191 #undef __FUNCT__
192 #define __FUNCT__ "PetscObjectReference"
193 /*@
194    PetscObjectReference - Indicates to any PetscObject that it is being
195    referenced by another PetscObject. This increases the reference
196    count for that object by one.
197 
198    Logically Collective on PetscObject
199 
200    Input Parameter:
201 .  obj - the PETSc object. This must be cast with (PetscObject), for example,
202          PetscObjectReference((PetscObject)mat);
203 
204    Level: advanced
205 
206 .seealso: PetscObjectCompose(), PetscObjectDereference()
207 @*/
208 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectReference(PetscObject obj)
209 {
210   PetscFunctionBegin;
211   PetscValidHeader(obj,1);
212   obj->refct++;
213   PetscFunctionReturn(0);
214 }
215 
216 #undef __FUNCT__
217 #define __FUNCT__ "PetscObjectGetReference"
218 /*@
219    PetscObjectGetReference - Gets the current reference count for
220    any PETSc object.
221 
222    Not Collective
223 
224    Input Parameter:
225 .  obj - the PETSc object; this must be cast with (PetscObject), for example,
226          PetscObjectGetReference((PetscObject)mat,&cnt);
227 
228    Output Parameter:
229 .  cnt - the reference count
230 
231    Level: advanced
232 
233 .seealso: PetscObjectCompose(), PetscObjectDereference(), PetscObjectReference()
234 @*/
235 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectGetReference(PetscObject obj,PetscInt *cnt)
236 {
237   PetscFunctionBegin;
238   PetscValidHeader(obj,1);
239   PetscValidIntPointer(cnt,2);
240   *cnt = obj->refct;
241   PetscFunctionReturn(0);
242 }
243 
244 #undef __FUNCT__
245 #define __FUNCT__ "PetscObjectDereference"
246 /*@
247    PetscObjectDereference - Indicates to any PetscObject that it is being
248    referenced by one less PetscObject. This decreases the reference
249    count for that object by one.
250 
251    Collective on PetscObject if reference reaches 0 otherwise Logically Collective
252 
253    Input Parameter:
254 .  obj - the PETSc object; this must be cast with (PetscObject), for example,
255          PetscObjectDereference((PetscObject)mat);
256 
257    Level: advanced
258 
259 .seealso: PetscObjectCompose(), PetscObjectReference()
260 @*/
261 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectDereference(PetscObject obj)
262 {
263   PetscErrorCode ierr;
264 
265   PetscFunctionBegin;
266   PetscValidHeader(obj,1);
267   if (obj->bops->destroy) {
268     ierr = (*obj->bops->destroy)(obj);CHKERRQ(ierr);
269   } else if (!--obj->refct) {
270     SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This PETSc object does not have a generic destroy routine");
271   }
272   PetscFunctionReturn(0);
273 }
274 
275 /* ----------------------------------------------------------------------- */
276 /*
277      The following routines are the versions private to the PETSc object
278      data structures.
279 */
280 #undef __FUNCT__
281 #define __FUNCT__ "PetscObjectGetComm_Petsc"
282 PetscErrorCode PetscObjectGetComm_Petsc(PetscObject obj,MPI_Comm *comm)
283 {
284   PetscFunctionBegin;
285   *comm = obj->comm;
286   PetscFunctionReturn(0);
287 }
288 
289 #undef __FUNCT__
290 #define __FUNCT__ "PetscObjectCompose_Petsc"
291 PetscErrorCode PetscObjectCompose_Petsc(PetscObject obj,const char name[],PetscObject ptr)
292 {
293   PetscErrorCode ierr;
294   char           *tname;
295 
296   PetscFunctionBegin;
297   if (ptr) {
298     ierr = PetscOListReverseFind(ptr->olist,obj,&tname);CHKERRQ(ierr);
299     if (tname) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"An object cannot be composed with an object that was compose with it");
300   }
301   ierr = PetscOListAdd(&obj->olist,name,ptr);CHKERRQ(ierr);
302   PetscFunctionReturn(0);
303 }
304 
305 #undef __FUNCT__
306 #define __FUNCT__ "PetscObjectQuery_Petsc"
307 PetscErrorCode PetscObjectQuery_Petsc(PetscObject obj,const char name[],PetscObject *ptr)
308 {
309   PetscErrorCode ierr;
310 
311   PetscFunctionBegin;
312   ierr = PetscOListFind(obj->olist,name,ptr);CHKERRQ(ierr);
313   PetscFunctionReturn(0);
314 }
315 
316 #undef __FUNCT__
317 #define __FUNCT__ "PetscObjectComposeFunction_Petsc"
318 PetscErrorCode PetscObjectComposeFunction_Petsc(PetscObject obj,const char name[],const char fname[],void (*ptr)(void))
319 {
320   PetscErrorCode ierr;
321 
322   PetscFunctionBegin;
323   ierr = PetscFListAdd(&obj->qlist,name,fname,ptr);CHKERRQ(ierr);
324   PetscFunctionReturn(0);
325 }
326 
327 #undef __FUNCT__
328 #define __FUNCT__ "PetscObjectQueryFunction_Petsc"
329 PetscErrorCode PetscObjectQueryFunction_Petsc(PetscObject obj,const char name[],void (**ptr)(void))
330 {
331   PetscErrorCode ierr;
332 
333   PetscFunctionBegin;
334   ierr = PetscFListFind(obj->qlist,obj->comm,name,ptr);CHKERRQ(ierr);
335   PetscFunctionReturn(0);
336 }
337 
338 /*
339         These are the versions that are usable to any CCA compliant objects
340 */
341 #undef __FUNCT__
342 #define __FUNCT__ "PetscObjectCompose"
343 /*@C
344    PetscObjectCompose - Associates another PETSc object with a given PETSc object.
345 
346    Not Collective
347 
348    Input Parameters:
349 +  obj - the PETSc object; this must be cast with (PetscObject), for example,
350          PetscObjectCompose((PetscObject)mat,...);
351 .  name - name associated with the child object
352 -  ptr - the other PETSc object to associate with the PETSc object; this must also be
353          cast with (PetscObject)
354 
355    Level: advanced
356 
357    Notes:
358    The second objects reference count is automatically increased by one when it is
359    composed.
360 
361    Replaces any previous object that had the same name.
362 
363    If ptr is null and name has previously been composed using an object, then that
364    entry is removed from the obj.
365 
366    PetscObjectCompose() can be used with any PETSc object (such as
367    Mat, Vec, KSP, SNES, etc.) or any user-provided object.  See
368    PetscContainerCreate() for info on how to create an object from a
369    user-provided pointer that may then be composed with PETSc objects.
370 
371    Concepts: objects^composing
372    Concepts: composing objects
373 
374 .seealso: PetscObjectQuery(), PetscContainerCreate()
375 @*/
376 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectCompose(PetscObject obj,const char name[],PetscObject ptr)
377 {
378   PetscErrorCode ierr;
379 
380   PetscFunctionBegin;
381   PetscValidHeader(obj,1);
382   PetscValidCharPointer(name,2);
383   if (ptr) PetscValidHeader(ptr,3);
384   ierr = (*obj->bops->compose)(obj,name,ptr);CHKERRQ(ierr);
385   PetscFunctionReturn(0);
386 }
387 
388 
389 
390 #undef __FUNCT__
391 #define __FUNCT__ "PetscObjectQuery"
392 /*@C
393    PetscObjectQuery  - Gets a PETSc object associated with a given object.
394 
395    Not Collective
396 
397    Input Parameters:
398 +  obj - the PETSc object
399          Thus must be cast with a (PetscObject), for example,
400          PetscObjectCompose((PetscObject)mat,...);
401 .  name - name associated with child object
402 -  ptr - the other PETSc object associated with the PETSc object, this must also be
403          cast with (PetscObject)
404 
405    Level: advanced
406 
407    Concepts: objects^composing
408    Concepts: composing objects
409    Concepts: objects^querying
410    Concepts: querying objects
411 
412 .seealso: PetscObjectQuery()
413 @*/
414 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectQuery(PetscObject obj,const char name[],PetscObject *ptr)
415 {
416   PetscErrorCode ierr;
417 
418   PetscFunctionBegin;
419   PetscValidHeader(obj,1);
420   PetscValidCharPointer(name,2);
421   PetscValidPointer(ptr,3);
422   ierr = (*obj->bops->query)(obj,name,ptr);CHKERRQ(ierr);
423   PetscFunctionReturn(0);
424 }
425 
426 #undef __FUNCT__
427 #define __FUNCT__ "PetscObjectComposeFunction"
428 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectComposeFunction(PetscObject obj,const char name[],const char fname[],void (*ptr)(void))
429 {
430   PetscErrorCode ierr;
431 
432   PetscFunctionBegin;
433   PetscValidHeader(obj,1);
434   PetscValidCharPointer(name,2);
435   PetscValidCharPointer(fname,2);
436   ierr = (*obj->bops->composefunction)(obj,name,fname,ptr);CHKERRQ(ierr);
437   PetscFunctionReturn(0);
438 }
439 
440 #undef __FUNCT__
441 #define __FUNCT__ "PetscObjectQueryFunction"
442 /*@C
443    PetscObjectQueryFunction - Gets a function associated with a given object.
444 
445    Logically Collective on PetscObject
446 
447    Input Parameters:
448 +  obj - the PETSc object; this must be cast with (PetscObject), for example,
449          PetscObjectQueryFunction((PetscObject)ksp,...);
450 -  name - name associated with the child function
451 
452    Output Parameter:
453 .  ptr - function pointer
454 
455    Level: advanced
456 
457    Concepts: objects^composing functions
458    Concepts: composing functions
459    Concepts: functions^querying
460    Concepts: objects^querying
461    Concepts: querying objects
462 
463 .seealso: PetscObjectComposeFunctionDynamic()
464 @*/
465 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectQueryFunction(PetscObject obj,const char name[],void (**ptr)(void))
466 {
467   PetscErrorCode ierr;
468 
469   PetscFunctionBegin;
470   PetscValidHeader(obj,1);
471   PetscValidCharPointer(name,2);
472   ierr = (*obj->bops->queryfunction)(obj,name,ptr);CHKERRQ(ierr);
473   PetscFunctionReturn(0);
474 }
475 
476 struct _p_PetscContainer {
477   PETSCHEADER(int);
478   void   *ptr;
479   PetscErrorCode (*userdestroy)(void*);
480 };
481 
482 #undef __FUNCT__
483 #define __FUNCT__ "PetscContainerGetPointer"
484 /*@C
485    PetscContainerGetPointer - Gets the pointer value contained in the container.
486 
487    Not Collective
488 
489    Input Parameter:
490 .  obj - the object created with PetscContainerCreate()
491 
492    Output Parameter:
493 .  ptr - the pointer value
494 
495    Level: advanced
496 
497 .seealso: PetscContainerCreate(), PetscContainerDestroy(),
498           PetscContainerSetPointer()
499 @*/
500 PetscErrorCode PETSCSYS_DLLEXPORT PetscContainerGetPointer(PetscContainer obj,void **ptr)
501 {
502   PetscFunctionBegin;
503   PetscValidHeaderSpecific(obj,PETSC_CONTAINER_CLASSID,1);
504   PetscValidPointer(ptr,2);
505   *ptr = obj->ptr;
506   PetscFunctionReturn(0);
507 }
508 
509 
510 #undef __FUNCT__
511 #define __FUNCT__ "PetscContainerSetPointer"
512 /*@C
513    PetscContainerSetPointer - Sets the pointer value contained in the container.
514 
515    Logically Collective on PetscContainer
516 
517    Input Parameters:
518 +  obj - the object created with PetscContainerCreate()
519 -  ptr - the pointer value
520 
521    Level: advanced
522 
523 .seealso: PetscContainerCreate(), PetscContainerDestroy(),
524           PetscContainerGetPointer()
525 @*/
526 PetscErrorCode PETSCSYS_DLLEXPORT PetscContainerSetPointer(PetscContainer obj,void *ptr)
527 {
528   PetscFunctionBegin;
529   PetscValidHeaderSpecific(obj,PETSC_CONTAINER_CLASSID,1);
530   if (ptr) PetscValidPointer(ptr,2);
531   obj->ptr = ptr;
532   PetscFunctionReturn(0);
533 }
534 
535 #undef __FUNCT__
536 #define __FUNCT__ "PetscContainerDestroy"
537 /*@C
538    PetscContainerDestroy - Destroys a PETSc container object.
539 
540    Collective on PetscContainer
541 
542    Input Parameter:
543 .  obj - an object that was created with PetscContainerCreate()
544 
545    Level: advanced
546 
547 .seealso: PetscContainerCreate()
548 @*/
549 PetscErrorCode PETSCSYS_DLLEXPORT PetscContainerDestroy(PetscContainer obj)
550 {
551   PetscErrorCode ierr;
552   PetscFunctionBegin;
553   PetscValidHeaderSpecific(obj,PETSC_CONTAINER_CLASSID,1);
554   if (--((PetscObject)obj)->refct > 0) PetscFunctionReturn(0);
555   if (obj->userdestroy) (*obj->userdestroy)(obj->ptr);
556   ierr = PetscHeaderDestroy(obj);CHKERRQ(ierr);
557   PetscFunctionReturn(0);
558 }
559 
560 #undef __FUNCT__
561 #define __FUNCT__ "PetscContainerSetUserDestroy"
562 /*@C
563    PetscContainerSetUserDestroy - Sets name of the user destroy function.
564 
565    Logically Collective on PetscContainer
566 
567    Input Parameter:
568 +  obj - an object that was created with PetscContainerCreate()
569 -  des - name of the user destroy function
570 
571    Level: advanced
572 
573 .seealso: PetscContainerDestroy()
574 @*/
575 PetscErrorCode PETSCSYS_DLLEXPORT PetscContainerSetUserDestroy(PetscContainer obj, PetscErrorCode (*des)(void*))
576 {
577   PetscFunctionBegin;
578   PetscValidHeaderSpecific(obj,PETSC_CONTAINER_CLASSID,1);
579   obj->userdestroy = des;
580   PetscFunctionReturn(0);
581 }
582 
583 PetscClassId PETSCSYS_DLLEXPORT PETSC_CONTAINER_CLASSID;
584 
585 #undef __FUNCT__
586 #define __FUNCT__ "PetscContainerCreate"
587 /*@C
588    PetscContainerCreate - Creates a PETSc object that has room to hold
589    a single pointer. This allows one to attach any type of data (accessible
590    through a pointer) with the PetscObjectCompose() function to a PetscObject.
591    The data item itself is attached by a call to PetscContainerSetPointer.
592 
593    Collective on MPI_Comm
594 
595    Input Parameters:
596 .  comm - MPI communicator that shares the object
597 
598    Output Parameters:
599 .  container - the container created
600 
601    Level: advanced
602 
603 .seealso: PetscContainerDestroy(), PetscContainerSetPointer(), PetscContainerGetPointer()
604 @*/
605 PetscErrorCode PETSCSYS_DLLEXPORT PetscContainerCreate(MPI_Comm comm,PetscContainer *container)
606 {
607   PetscErrorCode ierr;
608   PetscContainer contain;
609 
610   PetscFunctionBegin;
611   PetscValidPointer(container,2);
612   ierr = PetscHeaderCreate(contain,_p_PetscContainer,PetscInt,PETSC_CONTAINER_CLASSID,0,"PetscContainer",comm,PetscContainerDestroy,0);CHKERRQ(ierr);
613   *container = contain;
614   PetscFunctionReturn(0);
615 }
616 
617 #undef __FUNCT__
618 #define __FUNCT__ "PetscObjectSetFromOptions"
619 /*@
620    PetscObjectSetFromOptions - Sets generic parameters from user options.
621 
622    Collective on obj
623 
624    Input Parameter:
625 .  obj - the PetscObjcet
626 
627    Options Database Keys:
628 
629    Notes:
630    We have no generic options at present, so this does nothing
631 
632    Level: beginner
633 
634 .keywords: set, options, database
635 .seealso: PetscObjectSetOptionsPrefix(), PetscObjectGetOptionsPrefix()
636 @*/
637 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectSetFromOptions(PetscObject obj)
638 {
639   PetscFunctionBegin;
640   PetscValidHeader(obj,1);
641   PetscFunctionReturn(0);
642 }
643 
644 #undef __FUNCT__
645 #define __FUNCT__ "PetscObjectSetUp"
646 /*@
647    PetscObjectSetUp - Sets up the internal data structures for the later use.
648 
649    Collective on PetscObject
650 
651    Input Parameters:
652 .  obj - the PetscObject
653 
654    Notes:
655    This does nothing at present.
656 
657    Level: advanced
658 
659 .keywords: setup
660 .seealso: PetscObjectDestroy()
661 @*/
662 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectSetUp(PetscObject obj)
663 {
664   PetscFunctionBegin;
665   PetscValidHeader(obj,1);
666   PetscFunctionReturn(0);
667 }
668