Actual source code: pams.c
petsc-3.3-p7 2013-05-11
2: #include <petscsys.h> /*I "petscsys.h" I*/
4: /*
5: If true then every PETSc object will be published with the AMS
6: */
7: PetscBool PetscAMSPublishAll;
11: /*@C
12: PetscObjectAMSPublish - Publish an object
14: Collective on PetscObject
16: Input Parameters:
17: . obj - the Petsc variable
18: Thus must be cast with a (PetscObject), for example,
19: PetscObjectSetName((PetscObject)mat,name);
21: Notes: PetscViewer objects are not published
23: Level: advanced
25: Concepts: publishing object
27: .seealso: PetscObjectSetName(), PetscObjectUnPublish()
29: @*/
30: PetscErrorCode PetscObjectAMSPublish(PetscObject obj)
31: {
33: AMS_Memory amem;
34: AMS_Comm acomm;
38: if (obj->classid == PETSC_VIEWER_CLASSID) return(0);
39: if (obj->amem != -1) return(0);
40: PetscObjectName(obj);
42: PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(PETSC_COMM_WORLD),&acomm);
43: /* Really want to attach to correct communicator but then browser needs to access multiple communicators
44: PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(obj->comm),&acomm); */
45:
46: AMS_Memory_create(acomm,obj->name,&amem);
47: obj->amem = (int)amem;
49: AMS_Memory_take_access(amem);
50: AMS_Memory_add_field(amem,"Class",&obj->class_name,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);
51: AMS_Memory_add_field(amem,"Type",&obj->type_name,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);
52: AMS_Memory_add_field(amem,"Id",&obj->id,1,AMS_INT,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);
53: AMS_Memory_add_field(amem,"ParentId",&obj->parentid,1,AMS_INT,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);
54: AMS_Memory_add_field(amem,"Name",&obj->name,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);
55: if (obj->bops->publish) {
56: (*obj->bops->publish)(obj);
57: }
58: AMS_Memory_publish(amem);
59: AMS_Memory_grant_access(amem);
60: return(0);
61: }
65: PetscErrorCode PetscObjectUnPublish(PetscObject obj)
66: {
67: AMS_Comm acomm;
71: if (obj->classid == PETSC_VIEWER_CLASSID) return(0);
72: if (obj->amem == -1) return(0);
73: PetscViewerAMSGetAMSComm(PETSC_VIEWER_AMS_(obj->comm),&acomm);
74: AMS_Memory_destroy(obj->amem);
75: obj->amem = -1;
76: return(0);
77: }