xref: /petsc/src/sys/classes/viewer/impls/draw/drawv.c (revision d083f849a86f1f43e18d534ee43954e2786cb29a)
15c6c1daeSBarry Smith 
25c6c1daeSBarry Smith #include <../src/sys/classes/viewer/impls/draw/vdraw.h> /*I "petscdraw.h" I*/
3665c2dedSJed Brown #include <petscviewer.h>                                /*I "petscviewer.h" I*/
45c6c1daeSBarry Smith 
5e0877f53SBarry Smith static PetscErrorCode PetscViewerDestroy_Draw(PetscViewer v)
65c6c1daeSBarry Smith {
75c6c1daeSBarry Smith   PetscErrorCode   ierr;
85c6c1daeSBarry Smith   PetscInt         i;
95c6c1daeSBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data;
105c6c1daeSBarry Smith 
115c6c1daeSBarry Smith   PetscFunctionBegin;
125c6c1daeSBarry Smith   if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Destroying PetscViewer without first restoring singleton");
135c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
145c6c1daeSBarry Smith     ierr = PetscDrawAxisDestroy(&vdraw->drawaxis[i]);CHKERRQ(ierr);
155c6c1daeSBarry Smith     ierr = PetscDrawLGDestroy(&vdraw->drawlg[i]);CHKERRQ(ierr);
165c6c1daeSBarry Smith     ierr = PetscDrawDestroy(&vdraw->draw[i]);CHKERRQ(ierr);
175c6c1daeSBarry Smith   }
185c6c1daeSBarry Smith   ierr = PetscFree(vdraw->display);CHKERRQ(ierr);
195c6c1daeSBarry Smith   ierr = PetscFree(vdraw->title);CHKERRQ(ierr);
205c6c1daeSBarry Smith   ierr = PetscFree3(vdraw->draw,vdraw->drawlg,vdraw->drawaxis);CHKERRQ(ierr);
215c6c1daeSBarry Smith   ierr = PetscFree(vdraw->bounds);CHKERRQ(ierr);
22d1da0b69SBarry Smith   ierr = PetscFree(vdraw->drawtype);CHKERRQ(ierr);
23e5ab1681SLisandro Dalcin   ierr = PetscFree(v->data);CHKERRQ(ierr);
245c6c1daeSBarry Smith   PetscFunctionReturn(0);
255c6c1daeSBarry Smith }
265c6c1daeSBarry Smith 
27e0877f53SBarry Smith static PetscErrorCode PetscViewerFlush_Draw(PetscViewer v)
285c6c1daeSBarry Smith {
295c6c1daeSBarry Smith   PetscErrorCode   ierr;
305c6c1daeSBarry Smith   PetscInt         i;
315c6c1daeSBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data;
325c6c1daeSBarry Smith 
335c6c1daeSBarry Smith   PetscFunctionBegin;
345c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
355b399a63SLisandro Dalcin     if (vdraw->draw[i]) {ierr = PetscDrawFlush(vdraw->draw[i]);CHKERRQ(ierr);}
365c6c1daeSBarry Smith   }
375c6c1daeSBarry Smith   PetscFunctionReturn(0);
385c6c1daeSBarry Smith }
395c6c1daeSBarry Smith 
405c6c1daeSBarry Smith /*@C
415c6c1daeSBarry Smith     PetscViewerDrawGetDraw - Returns PetscDraw object from PetscViewer object.
425c6c1daeSBarry Smith     This PetscDraw object may then be used to perform graphics using
435c6c1daeSBarry Smith     PetscDrawXXX() commands.
445c6c1daeSBarry Smith 
45d94959e9SLisandro Dalcin     Collective on PetscViewer
465c6c1daeSBarry Smith 
475c6c1daeSBarry Smith     Input Parameters:
485c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
495c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
505c6c1daeSBarry Smith 
515c6c1daeSBarry Smith     Ouput Parameter:
525c6c1daeSBarry Smith .   draw - the draw object
535c6c1daeSBarry Smith 
545c6c1daeSBarry Smith     Level: intermediate
555c6c1daeSBarry Smith 
565c6c1daeSBarry Smith 
575c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
585c6c1daeSBarry Smith @*/
595c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDraw(PetscViewer viewer,PetscInt windownumber,PetscDraw *draw)
605c6c1daeSBarry Smith {
61e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
625c6c1daeSBarry Smith   PetscErrorCode   ierr;
635c6c1daeSBarry Smith   PetscBool        isdraw;
645c6c1daeSBarry Smith 
655c6c1daeSBarry Smith   PetscFunctionBegin;
665c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
67e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
685c6c1daeSBarry Smith   if (draw) PetscValidPointer(draw,3);
695c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
705c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
715c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
72e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
73e5ab1681SLisandro Dalcin 
745c6c1daeSBarry Smith   windownumber += vdraw->draw_base;
755c6c1daeSBarry Smith   if (windownumber >= vdraw->draw_max) {
765c6c1daeSBarry Smith     /* allocate twice as many slots as needed */
775c6c1daeSBarry Smith     PetscInt      draw_max  = vdraw->draw_max;
785c6c1daeSBarry Smith     PetscDraw     *tdraw    = vdraw->draw;
795c6c1daeSBarry Smith     PetscDrawLG   *drawlg   = vdraw->drawlg;
805c6c1daeSBarry Smith     PetscDrawAxis *drawaxis = vdraw->drawaxis;
815c6c1daeSBarry Smith 
825c6c1daeSBarry Smith     vdraw->draw_max = 2*windownumber;
83a297a907SKarl Rupp 
841795a4d1SJed Brown     ierr = PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis);CHKERRQ(ierr);
855c6c1daeSBarry Smith 
865c6c1daeSBarry Smith     ierr = PetscMemcpy(vdraw->draw,tdraw,draw_max*sizeof(PetscDraw));CHKERRQ(ierr);
875c6c1daeSBarry Smith     ierr = PetscMemcpy(vdraw->drawlg,drawlg,draw_max*sizeof(PetscDrawLG));CHKERRQ(ierr);
885c6c1daeSBarry Smith     ierr = PetscMemcpy(vdraw->drawaxis,drawaxis,draw_max*sizeof(PetscDrawAxis));CHKERRQ(ierr);
895c6c1daeSBarry Smith 
905c6c1daeSBarry Smith     ierr = PetscFree3(tdraw,drawlg,drawaxis);CHKERRQ(ierr);
915c6c1daeSBarry Smith   }
925c6c1daeSBarry Smith 
935c6c1daeSBarry Smith   if (!vdraw->draw[windownumber]) {
94e5ab1681SLisandro Dalcin     char *title = vdraw->title, tmp_str[128];
9510f3a0f4SLisandro Dalcin     if (windownumber) {
9610f3a0f4SLisandro Dalcin       ierr = PetscSNPrintf(tmp_str,sizeof(tmp_str),"%s:%d",vdraw->title?vdraw->title:"",windownumber);CHKERRQ(ierr);
975c6c1daeSBarry Smith       title = tmp_str;
985c6c1daeSBarry Smith     }
99ce94432eSBarry Smith     ierr = PetscDrawCreate(PetscObjectComm((PetscObject)viewer),vdraw->display,title,PETSC_DECIDE,PETSC_DECIDE,vdraw->w,vdraw->h,&vdraw->draw[windownumber]);CHKERRQ(ierr);
100e5ab1681SLisandro Dalcin     ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->draw[windownumber]);CHKERRQ(ierr);
101d1da0b69SBarry Smith     if (vdraw->drawtype) {
102d1da0b69SBarry Smith       ierr = PetscDrawSetType(vdraw->draw[windownumber],vdraw->drawtype);CHKERRQ(ierr);
103d1da0b69SBarry Smith     }
104afe78b3cSBarry Smith     ierr = PetscDrawSetPause(vdraw->draw[windownumber],vdraw->pause);CHKERRQ(ierr);
105d94959e9SLisandro Dalcin     ierr = PetscDrawSetOptionsPrefix(vdraw->draw[windownumber],((PetscObject)viewer)->prefix);CHKERRQ(ierr);
1065c6c1daeSBarry Smith     ierr = PetscDrawSetFromOptions(vdraw->draw[windownumber]);CHKERRQ(ierr);
1075c6c1daeSBarry Smith   }
1085c6c1daeSBarry Smith   if (draw) *draw = vdraw->draw[windownumber];
1095c6c1daeSBarry Smith   if (draw) PetscValidHeaderSpecific(*draw,PETSC_DRAW_CLASSID,-1);
1105c6c1daeSBarry Smith   PetscFunctionReturn(0);
1115c6c1daeSBarry Smith }
1125c6c1daeSBarry Smith 
1135c6c1daeSBarry Smith /*@C
1145c6c1daeSBarry Smith     PetscViewerDrawBaseAdd - add to the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw()
1155c6c1daeSBarry Smith 
116d94959e9SLisandro Dalcin     Logically Collective on PetscViewer
1175c6c1daeSBarry Smith 
1185c6c1daeSBarry Smith     Input Parameters:
1195c6c1daeSBarry Smith +  viewer - the PetscViewer (created with PetscViewerDrawOpen())
1205c6c1daeSBarry Smith -   windownumber - how much to add to the base
1215c6c1daeSBarry Smith 
1225c6c1daeSBarry Smith     Level: developer
1235c6c1daeSBarry Smith 
1245c6c1daeSBarry Smith 
1255c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseSet()
1265c6c1daeSBarry Smith @*/
1275c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawBaseAdd(PetscViewer viewer,PetscInt windownumber)
1285c6c1daeSBarry Smith {
129e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1305c6c1daeSBarry Smith   PetscErrorCode   ierr;
1315c6c1daeSBarry Smith   PetscBool        isdraw;
1325c6c1daeSBarry Smith 
1335c6c1daeSBarry Smith   PetscFunctionBegin;
1345c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
135e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1365c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
1375c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
138e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
139e5ab1681SLisandro Dalcin 
1405c6c1daeSBarry Smith   if (windownumber + vdraw->draw_base < 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %D cannot be negative",windownumber+vdraw->draw_base);
1415c6c1daeSBarry Smith   vdraw->draw_base += windownumber;
1425c6c1daeSBarry Smith   PetscFunctionReturn(0);
1435c6c1daeSBarry Smith }
1445c6c1daeSBarry Smith 
1455c6c1daeSBarry Smith /*@C
1465c6c1daeSBarry Smith     PetscViewerDrawBaseSet - sets the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw()
1475c6c1daeSBarry Smith 
148d94959e9SLisandro Dalcin     Logically Collective on PetscViewer
1495c6c1daeSBarry Smith 
1505c6c1daeSBarry Smith     Input Parameters:
1515c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
1525c6c1daeSBarry Smith -   windownumber - value to set the base
1535c6c1daeSBarry Smith 
1545c6c1daeSBarry Smith     Level: developer
1555c6c1daeSBarry Smith 
1565c6c1daeSBarry Smith 
1575c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseAdd()
1585c6c1daeSBarry Smith @*/
1595c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawBaseSet(PetscViewer viewer,PetscInt windownumber)
1605c6c1daeSBarry Smith {
161e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1625c6c1daeSBarry Smith   PetscErrorCode   ierr;
1635c6c1daeSBarry Smith   PetscBool        isdraw;
1645c6c1daeSBarry Smith 
1655c6c1daeSBarry Smith   PetscFunctionBegin;
1665c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
167e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1685c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
1695c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
170e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
171e5ab1681SLisandro Dalcin 
1725c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %D cannot be negative",windownumber);
1735c6c1daeSBarry Smith   vdraw->draw_base = windownumber;
1745c6c1daeSBarry Smith   PetscFunctionReturn(0);
1755c6c1daeSBarry Smith }
1765c6c1daeSBarry Smith 
1775c6c1daeSBarry Smith /*@C
1785c6c1daeSBarry Smith     PetscViewerDrawGetDrawLG - Returns PetscDrawLG object from PetscViewer object.
1795c6c1daeSBarry Smith     This PetscDrawLG object may then be used to perform graphics using
1805c6c1daeSBarry Smith     PetscDrawLGXXX() commands.
1815c6c1daeSBarry Smith 
182d94959e9SLisandro Dalcin     Collective on PetscViewer
1835c6c1daeSBarry Smith 
1845c6c1daeSBarry Smith     Input Parameter:
1855c6c1daeSBarry Smith +   PetscViewer - the PetscViewer (created with PetscViewerDrawOpen())
1865c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
1875c6c1daeSBarry Smith 
1885c6c1daeSBarry Smith     Ouput Parameter:
1895c6c1daeSBarry Smith .   draw - the draw line graph object
1905c6c1daeSBarry Smith 
1915c6c1daeSBarry Smith     Level: intermediate
1925c6c1daeSBarry Smith 
1935c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
1945c6c1daeSBarry Smith @*/
1955c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDrawLG(PetscViewer viewer,PetscInt windownumber,PetscDrawLG *drawlg)
1965c6c1daeSBarry Smith {
1975c6c1daeSBarry Smith   PetscErrorCode   ierr;
1985c6c1daeSBarry Smith   PetscBool        isdraw;
199e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
2005c6c1daeSBarry Smith 
2015c6c1daeSBarry Smith   PetscFunctionBegin;
2025c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
203e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
2045c6c1daeSBarry Smith   PetscValidPointer(drawlg,3);
2055c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
2065c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
2075c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
208e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
2095c6c1daeSBarry Smith 
2105c6c1daeSBarry Smith   if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) {
2110298fd71SBarry Smith     ierr = PetscViewerDrawGetDraw(viewer,windownumber,NULL);CHKERRQ(ierr);
2125c6c1daeSBarry Smith   }
2135c6c1daeSBarry Smith   if (!vdraw->drawlg[windownumber+vdraw->draw_base]) {
2145c6c1daeSBarry Smith     ierr = PetscDrawLGCreate(vdraw->draw[windownumber+vdraw->draw_base],1,&vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2153bb1ff40SBarry Smith     ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
216de1a4edeSLisandro Dalcin     ierr = PetscDrawLGSetFromOptions(vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2175c6c1daeSBarry Smith   }
2185c6c1daeSBarry Smith   *drawlg = vdraw->drawlg[windownumber+vdraw->draw_base];
2195c6c1daeSBarry Smith   PetscFunctionReturn(0);
2205c6c1daeSBarry Smith }
2215c6c1daeSBarry Smith 
2225c6c1daeSBarry Smith /*@C
2235c6c1daeSBarry Smith     PetscViewerDrawGetDrawAxis - Returns PetscDrawAxis object from PetscViewer object.
2245c6c1daeSBarry Smith     This PetscDrawAxis object may then be used to perform graphics using
2255c6c1daeSBarry Smith     PetscDrawAxisXXX() commands.
2265c6c1daeSBarry Smith 
227d94959e9SLisandro Dalcin     Collective on PetscViewer
2285c6c1daeSBarry Smith 
2295c6c1daeSBarry Smith     Input Parameter:
2305c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen()
2315c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
2325c6c1daeSBarry Smith 
2335c6c1daeSBarry Smith     Ouput Parameter:
2345c6c1daeSBarry Smith .   drawaxis - the draw axis object
2355c6c1daeSBarry Smith 
2365c6c1daeSBarry Smith     Level: advanced
2375c6c1daeSBarry Smith 
2385c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetLG(), PetscViewerDrawOpen()
2395c6c1daeSBarry Smith @*/
2405c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDrawAxis(PetscViewer viewer,PetscInt windownumber,PetscDrawAxis *drawaxis)
2415c6c1daeSBarry Smith {
2425c6c1daeSBarry Smith   PetscErrorCode   ierr;
2435c6c1daeSBarry Smith   PetscBool        isdraw;
244e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
2455c6c1daeSBarry Smith 
2465c6c1daeSBarry Smith   PetscFunctionBegin;
2475c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
248e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
2495c6c1daeSBarry Smith   PetscValidPointer(drawaxis,3);
2505c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
2515c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
2525c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
253e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
2545c6c1daeSBarry Smith 
2555c6c1daeSBarry Smith   if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) {
2560298fd71SBarry Smith     ierr = PetscViewerDrawGetDraw(viewer,windownumber,NULL);CHKERRQ(ierr);
2575c6c1daeSBarry Smith   }
2585c6c1daeSBarry Smith   if (!vdraw->drawaxis[windownumber+vdraw->draw_base]) {
2595c6c1daeSBarry Smith     ierr = PetscDrawAxisCreate(vdraw->draw[windownumber+vdraw->draw_base],&vdraw->drawaxis[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2603bb1ff40SBarry Smith     ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawaxis[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2615c6c1daeSBarry Smith   }
2625c6c1daeSBarry Smith   *drawaxis = vdraw->drawaxis[windownumber+vdraw->draw_base];
2635c6c1daeSBarry Smith   PetscFunctionReturn(0);
2645c6c1daeSBarry Smith }
2655c6c1daeSBarry Smith 
2665c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawResize(PetscViewer v,int w,int h)
2675c6c1daeSBarry Smith {
268e5ab1681SLisandro Dalcin   PetscErrorCode   ierr;
269e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
270e5ab1681SLisandro Dalcin   PetscBool        isdraw;
2715c6c1daeSBarry Smith 
2725c6c1daeSBarry Smith   PetscFunctionBegin;
273e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
274e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
275e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
276e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
277e5ab1681SLisandro Dalcin 
278e5ab1681SLisandro Dalcin   if (w >= 1) vdraw->w = w;
279e5ab1681SLisandro Dalcin   if (h >= 1) vdraw->h = h;
2805c6c1daeSBarry Smith   PetscFunctionReturn(0);
2815c6c1daeSBarry Smith }
2825c6c1daeSBarry Smith 
2835c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetInfo(PetscViewer v,const char display[],const char title[],int x,int y,int w,int h)
2845c6c1daeSBarry Smith {
2855c6c1daeSBarry Smith   PetscErrorCode   ierr;
286e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
287e5ab1681SLisandro Dalcin   PetscBool        isdraw;
2885c6c1daeSBarry Smith 
2895c6c1daeSBarry Smith   PetscFunctionBegin;
290e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
291e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
292e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
293e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
294e5ab1681SLisandro Dalcin 
2955c6c1daeSBarry Smith   ierr = PetscStrallocpy(display,&vdraw->display);CHKERRQ(ierr);
2965c6c1daeSBarry Smith   ierr = PetscStrallocpy(title,&vdraw->title);CHKERRQ(ierr);
297e5ab1681SLisandro Dalcin   if (w >= 1) vdraw->w = w;
298e5ab1681SLisandro Dalcin   if (h >= 1) vdraw->h = h;
2995c6c1daeSBarry Smith   PetscFunctionReturn(0);
3005c6c1daeSBarry Smith }
3015c6c1daeSBarry Smith 
302d1da0b69SBarry Smith PetscErrorCode  PetscViewerDrawSetDrawType(PetscViewer v,PetscDrawType drawtype)
303d1da0b69SBarry Smith {
304d1da0b69SBarry Smith   PetscErrorCode   ierr;
305e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
306e5ab1681SLisandro Dalcin   PetscBool        isdraw;
307d1da0b69SBarry Smith 
308d1da0b69SBarry Smith   PetscFunctionBegin;
309e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
310e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
311e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
312e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
313e5ab1681SLisandro Dalcin 
314d1da0b69SBarry Smith   ierr = PetscFree(vdraw->drawtype);CHKERRQ(ierr);
315d1da0b69SBarry Smith   ierr = PetscStrallocpy(drawtype,(char**)&vdraw->drawtype);CHKERRQ(ierr);
316d1da0b69SBarry Smith   PetscFunctionReturn(0);
317d1da0b69SBarry Smith }
318d1da0b69SBarry Smith 
3191f49e1f7SLisandro Dalcin PetscErrorCode PetscViewerDrawGetDrawType(PetscViewer v,PetscDrawType *drawtype)
3201f49e1f7SLisandro Dalcin {
3211f49e1f7SLisandro Dalcin   PetscErrorCode   ierr;
3221f49e1f7SLisandro Dalcin   PetscViewer_Draw *vdraw;
3231f49e1f7SLisandro Dalcin   PetscBool        isdraw;
3241f49e1f7SLisandro Dalcin 
3251f49e1f7SLisandro Dalcin   PetscFunctionBegin;
3261f49e1f7SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
3271f49e1f7SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
3281f49e1f7SLisandro Dalcin   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
3291f49e1f7SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
3301f49e1f7SLisandro Dalcin 
3311f49e1f7SLisandro Dalcin   *drawtype = vdraw->drawtype;
3321f49e1f7SLisandro Dalcin   PetscFunctionReturn(0);
3331f49e1f7SLisandro Dalcin }
3341f49e1f7SLisandro Dalcin 
335f55236e4SLisandro Dalcin PetscErrorCode PetscViewerDrawSetTitle(PetscViewer v,const char title[])
336f55236e4SLisandro Dalcin {
337f55236e4SLisandro Dalcin   PetscErrorCode   ierr;
338f55236e4SLisandro Dalcin   PetscViewer_Draw *vdraw;
339f55236e4SLisandro Dalcin   PetscBool        isdraw;
340f55236e4SLisandro Dalcin 
341f55236e4SLisandro Dalcin   PetscFunctionBegin;
342f55236e4SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
343f55236e4SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
344f55236e4SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
345f55236e4SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
346f55236e4SLisandro Dalcin 
347f55236e4SLisandro Dalcin   ierr = PetscFree(vdraw->title);CHKERRQ(ierr);
348f55236e4SLisandro Dalcin   ierr = PetscStrallocpy(title,&vdraw->title);CHKERRQ(ierr);
349f55236e4SLisandro Dalcin   PetscFunctionReturn(0);
350f55236e4SLisandro Dalcin }
351f55236e4SLisandro Dalcin 
352f55236e4SLisandro Dalcin PetscErrorCode PetscViewerDrawGetTitle(PetscViewer v,const char *title[])
353f55236e4SLisandro Dalcin {
354f55236e4SLisandro Dalcin   PetscErrorCode   ierr;
355f55236e4SLisandro Dalcin   PetscViewer_Draw *vdraw;
356f55236e4SLisandro Dalcin   PetscBool        isdraw;
357f55236e4SLisandro Dalcin 
358f55236e4SLisandro Dalcin   PetscFunctionBegin;
359f55236e4SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
360f55236e4SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
361f55236e4SLisandro Dalcin   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
362f55236e4SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
363f55236e4SLisandro Dalcin 
364f55236e4SLisandro Dalcin   *title = vdraw->title;
365f55236e4SLisandro Dalcin   PetscFunctionReturn(0);
366f55236e4SLisandro Dalcin }
367f55236e4SLisandro Dalcin 
3685c6c1daeSBarry Smith /*@C
3695c6c1daeSBarry Smith    PetscViewerDrawOpen - Opens a window for use as a PetscViewer. If you want to
3705c6c1daeSBarry Smith    do graphics in this window, you must call PetscViewerDrawGetDraw() and
3715c6c1daeSBarry Smith    perform the graphics on the PetscDraw object.
3725c6c1daeSBarry Smith 
373*d083f849SBarry Smith    Collective
3745c6c1daeSBarry Smith 
3755c6c1daeSBarry Smith    Input Parameters:
3765c6c1daeSBarry Smith +  comm - communicator that will share window
3775c6c1daeSBarry Smith .  display - the X display on which to open, or null for the local machine
3785c6c1daeSBarry Smith .  title - the title to put in the title bar, or null for no title
3795c6c1daeSBarry Smith .  x, y - the screen coordinates of the upper left corner of window, or use PETSC_DECIDE
3805c6c1daeSBarry Smith -  w, h - window width and height in pixels, or may use PETSC_DECIDE or PETSC_DRAW_FULL_SIZE, PETSC_DRAW_HALF_SIZE,
3815c6c1daeSBarry Smith           PETSC_DRAW_THIRD_SIZE, PETSC_DRAW_QUARTER_SIZE
3825c6c1daeSBarry Smith 
3835c6c1daeSBarry Smith    Output Parameters:
3845c6c1daeSBarry Smith . viewer - the PetscViewer
3855c6c1daeSBarry Smith 
3865c6c1daeSBarry Smith    Format Options:
3875c6c1daeSBarry Smith +  PETSC_VIEWER_DRAW_BASIC - displays with basic format
3885c6c1daeSBarry Smith -  PETSC_VIEWER_DRAW_LG    - displays using a line graph
3895c6c1daeSBarry Smith 
3905c6c1daeSBarry Smith    Options Database Keys:
3915c6c1daeSBarry Smith    PetscViewerDrawOpen() calls PetscDrawCreate(), so see the manual page for
3925c6c1daeSBarry Smith    PetscDrawCreate() for runtime options, including
3935c6c1daeSBarry Smith +  -draw_type x or null
3945c6c1daeSBarry Smith .  -nox - Disables all x-windows output
3955c6c1daeSBarry Smith .  -display <name> - Specifies name of machine for the X display
3965c6c1daeSBarry Smith .  -geometry <x,y,w,h> - allows setting the window location and size
3975c6c1daeSBarry Smith -  -draw_pause <pause> - Sets time (in seconds) that the
3985c6c1daeSBarry Smith      program pauses after PetscDrawPause() has been called
3995c6c1daeSBarry Smith      (0 is default, -1 implies until user input).
4005c6c1daeSBarry Smith 
4015c6c1daeSBarry Smith    Level: beginner
4025c6c1daeSBarry Smith 
4035c6c1daeSBarry Smith    Note for Fortran Programmers:
4045c6c1daeSBarry Smith    Whenever indicating null character data in a Fortran code,
405cf90aa19SBarry Smith    PETSC_NULL_CHARACTER must be employed; using NULL is not
406cf90aa19SBarry Smith    correct for character data!  Thus, PETSC_NULL_CHARACTER can be
4075c6c1daeSBarry Smith    used for the display and title input parameters.
4085c6c1daeSBarry Smith 
4095c6c1daeSBarry Smith 
4105c6c1daeSBarry Smith 
4115c6c1daeSBarry Smith .seealso: PetscDrawCreate(), PetscViewerDestroy(), PetscViewerDrawGetDraw(), PetscViewerCreate(), PETSC_VIEWER_DRAW_,
4125c6c1daeSBarry Smith           PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF
4135c6c1daeSBarry Smith @*/
4145c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawOpen(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscViewer *viewer)
4155c6c1daeSBarry Smith {
4165c6c1daeSBarry Smith   PetscErrorCode ierr;
4175c6c1daeSBarry Smith 
4185c6c1daeSBarry Smith   PetscFunctionBegin;
4195c6c1daeSBarry Smith   ierr = PetscViewerCreate(comm,viewer);CHKERRQ(ierr);
4205c6c1daeSBarry Smith   ierr = PetscViewerSetType(*viewer,PETSCVIEWERDRAW);CHKERRQ(ierr);
4215c6c1daeSBarry Smith   ierr = PetscViewerDrawSetInfo(*viewer,display,title,x,y,w,h);CHKERRQ(ierr);
4225c6c1daeSBarry Smith   PetscFunctionReturn(0);
4235c6c1daeSBarry Smith }
4245c6c1daeSBarry Smith 
4253f08860eSBarry Smith PetscErrorCode PetscViewerGetSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer)
4265c6c1daeSBarry Smith {
4275c6c1daeSBarry Smith   PetscErrorCode   ierr;
4285c6c1daeSBarry Smith   PetscMPIInt      rank;
4295c6c1daeSBarry Smith   PetscInt         i;
430c6228bbaSLisandro Dalcin   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw;
4315c6c1daeSBarry Smith 
4325c6c1daeSBarry Smith   PetscFunctionBegin;
4333f08860eSBarry Smith   if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to get SubViewer without first restoring previous");
4345c6c1daeSBarry Smith   /* only processor zero can use the PetscViewer draw singleton */
435fefe69c3SStefano Zampini   if (sviewer) *sviewer = NULL;
436ce94432eSBarry Smith   ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr);
4375c6c1daeSBarry Smith   if (!rank) {
438e5afcf28SBarry Smith     PetscMPIInt flg;
439e5afcf28SBarry Smith 
440e5afcf28SBarry Smith     ierr = MPI_Comm_compare(PETSC_COMM_SELF,comm,&flg);CHKERRQ(ierr);
441e5afcf28SBarry Smith     if (flg != MPI_IDENT && flg != MPI_CONGRUENT) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"PetscViewerGetSubViewer() for PETSCVIEWERDRAW requires a singleton MPI_Comm");
442e5afcf28SBarry Smith     ierr = PetscViewerCreate(comm,sviewer);CHKERRQ(ierr);
4435c6c1daeSBarry Smith     ierr = PetscViewerSetType(*sviewer,PETSCVIEWERDRAW);CHKERRQ(ierr);
444c6228bbaSLisandro Dalcin     svdraw = (PetscViewer_Draw*)(*sviewer)->data;
445c6228bbaSLisandro Dalcin     (*sviewer)->format = viewer->format;
446c6228bbaSLisandro Dalcin     for (i=0; i<vdraw->draw_max; i++) { /* XXX this is wrong if svdraw->draw_max (initially 5) < vdraw->draw_max */
447c6228bbaSLisandro Dalcin       if (vdraw->draw[i]) {ierr = PetscDrawGetSingleton(vdraw->draw[i],&svdraw->draw[i]);CHKERRQ(ierr);}
4485c6c1daeSBarry Smith     }
4495c6c1daeSBarry Smith   }
4505c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_TRUE;
4515c6c1daeSBarry Smith   PetscFunctionReturn(0);
4525c6c1daeSBarry Smith }
4535c6c1daeSBarry Smith 
4543f08860eSBarry Smith PetscErrorCode PetscViewerRestoreSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer)
4555c6c1daeSBarry Smith {
4565c6c1daeSBarry Smith   PetscErrorCode   ierr;
4575c6c1daeSBarry Smith   PetscMPIInt      rank;
4585c6c1daeSBarry Smith   PetscInt         i;
459c6228bbaSLisandro Dalcin   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw;
4605c6c1daeSBarry Smith 
4615c6c1daeSBarry Smith   PetscFunctionBegin;
4625c6c1daeSBarry Smith   if (!vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to restore a singleton that was not gotten");
463ce94432eSBarry Smith   ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr);
4645c6c1daeSBarry Smith   if (!rank) {
465c6228bbaSLisandro Dalcin     svdraw = (PetscViewer_Draw*)(*sviewer)->data;
4665c6c1daeSBarry Smith     for (i=0; i<vdraw->draw_max; i++) {
467c6228bbaSLisandro Dalcin       if (vdraw->draw[i] && svdraw->draw[i]) {
468c6228bbaSLisandro Dalcin         ierr = PetscDrawRestoreSingleton(vdraw->draw[i],&svdraw->draw[i]);CHKERRQ(ierr);
4695c6c1daeSBarry Smith       }
4705c6c1daeSBarry Smith     }
471c6228bbaSLisandro Dalcin     ierr = PetscFree3(svdraw->draw,svdraw->drawlg,svdraw->drawaxis);CHKERRQ(ierr);
4725c6c1daeSBarry Smith     ierr = PetscFree((*sviewer)->data);CHKERRQ(ierr);
4735c6c1daeSBarry Smith     ierr = PetscHeaderDestroy(sviewer);CHKERRQ(ierr);
4745c6c1daeSBarry Smith   }
4755c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_FALSE;
4765c6c1daeSBarry Smith   PetscFunctionReturn(0);
4775c6c1daeSBarry Smith }
4785c6c1daeSBarry Smith 
4794416b707SBarry Smith PetscErrorCode PetscViewerSetFromOptions_Draw(PetscOptionItems *PetscOptionsObject,PetscViewer v)
480e9457bf7SBarry Smith {
481e9457bf7SBarry Smith   PetscErrorCode ierr;
482e9457bf7SBarry Smith   PetscReal      bounds[16];
483e9457bf7SBarry Smith   PetscInt       nbounds = 16;
484e9457bf7SBarry Smith   PetscBool      flg;
485e9457bf7SBarry Smith 
486e9457bf7SBarry Smith   PetscFunctionBegin;
487e55864a3SBarry Smith   ierr = PetscOptionsHead(PetscOptionsObject,"Draw PetscViewer Options");CHKERRQ(ierr);
488e9457bf7SBarry Smith   ierr = PetscOptionsRealArray("-draw_bounds","Bounds to put on plots axis","PetscViewerDrawSetBounds",bounds,&nbounds,&flg);CHKERRQ(ierr);
489e9457bf7SBarry Smith   if (flg) {
490e9457bf7SBarry Smith     ierr = PetscViewerDrawSetBounds(v,nbounds/2,bounds);CHKERRQ(ierr);
491e9457bf7SBarry Smith   }
492e9457bf7SBarry Smith   ierr = PetscOptionsTail();CHKERRQ(ierr);
493e9457bf7SBarry Smith   PetscFunctionReturn(0);
494e9457bf7SBarry Smith }
495e9457bf7SBarry Smith 
4960076e027SBarry Smith PetscErrorCode PetscViewerView_Draw(PetscViewer viewer,PetscViewer v)
4970076e027SBarry Smith {
4980076e027SBarry Smith   PetscErrorCode   ierr;
4990076e027SBarry Smith   PetscDraw        draw;
5000076e027SBarry Smith   PetscInt         i;
5010076e027SBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data;
5020076e027SBarry Smith 
5030076e027SBarry Smith   PetscFunctionBegin;
5040076e027SBarry Smith   /*  If the PetscViewer has just been created then no vdraw->draw yet
5050076e027SBarry Smith       exists so this will not actually call the viewer on any draws. */
5060076e027SBarry Smith   for (i=0; i<vdraw->draw_base; i++) {
5070076e027SBarry Smith     if (vdraw->draw[i]) {
5080076e027SBarry Smith       ierr = PetscViewerDrawGetDraw(viewer,i,&draw);CHKERRQ(ierr);
5090076e027SBarry Smith       ierr = PetscDrawView(draw,v);CHKERRQ(ierr);
5100076e027SBarry Smith     }
5110076e027SBarry Smith   }
5120076e027SBarry Smith   PetscFunctionReturn(0);
5130076e027SBarry Smith }
5140076e027SBarry Smith 
5158556b5ebSBarry Smith /*MC
5168556b5ebSBarry Smith    PETSCVIEWERDRAW - A viewer that generates graphics, either to the screen or a file
5178556b5ebSBarry Smith 
5188556b5ebSBarry Smith 
5198556b5ebSBarry Smith .seealso:  PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PETSC_VIEWER_DRAW_(),PETSC_VIEWER_DRAW_SELF, PETSC_VIEWER_DRAW_WORLD,
5208556b5ebSBarry Smith            PetscViewerCreate(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), PETSCVIEWERBINARY,
5218556b5ebSBarry Smith            PetscViewerMatlabOpen(), VecView(), DMView(), PetscViewerMatlabPutArray(), PETSCVIEWERASCII, PETSCVIEWERMATLAB,
5228556b5ebSBarry Smith            PetscViewerFileSetName(), PetscViewerFileSetMode(), PetscViewerFormat, PetscViewerType, PetscViewerSetType()
5238556b5ebSBarry Smith 
5241b266c99SBarry Smith   Level: beginner
5251b266c99SBarry Smith 
5268556b5ebSBarry Smith M*/
5278cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate_Draw(PetscViewer viewer)
5285c6c1daeSBarry Smith {
5295c6c1daeSBarry Smith   PetscErrorCode   ierr;
5305c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
5315c6c1daeSBarry Smith 
5325c6c1daeSBarry Smith   PetscFunctionBegin;
533b00a9115SJed Brown   ierr = PetscNewLog(viewer,&vdraw);CHKERRQ(ierr);
5345c6c1daeSBarry Smith   viewer->data = (void*)vdraw;
5355c6c1daeSBarry Smith 
5365c6c1daeSBarry Smith   viewer->ops->flush            = PetscViewerFlush_Draw;
5370076e027SBarry Smith   viewer->ops->view             = PetscViewerView_Draw;
5385c6c1daeSBarry Smith   viewer->ops->destroy          = PetscViewerDestroy_Draw;
539e9457bf7SBarry Smith   viewer->ops->setfromoptions   = PetscViewerSetFromOptions_Draw;
540559f443fSBarry Smith   viewer->ops->getsubviewer     = PetscViewerGetSubViewer_Draw;
541559f443fSBarry Smith   viewer->ops->restoresubviewer = PetscViewerRestoreSubViewer_Draw;
5425c6c1daeSBarry Smith 
5435c6c1daeSBarry Smith   /* these are created on the fly if requested */
5445c6c1daeSBarry Smith   vdraw->draw_max  = 5;
5455c6c1daeSBarry Smith   vdraw->draw_base = 0;
546ccad63c3SBarry Smith   vdraw->w         = PETSC_DECIDE;
547ccad63c3SBarry Smith   vdraw->h         = PETSC_DECIDE;
548a297a907SKarl Rupp 
5491795a4d1SJed Brown   ierr = PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis);CHKERRQ(ierr);
5505c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_FALSE;
5515c6c1daeSBarry Smith   PetscFunctionReturn(0);
5525c6c1daeSBarry Smith }
5535c6c1daeSBarry Smith 
5545c6c1daeSBarry Smith /*@
5555c6c1daeSBarry Smith     PetscViewerDrawClear - Clears a PetscDraw graphic associated with a PetscViewer.
5565c6c1daeSBarry Smith 
5575c6c1daeSBarry Smith     Not Collective
5585c6c1daeSBarry Smith 
5595c6c1daeSBarry Smith     Input Parameter:
5605c6c1daeSBarry Smith .  viewer - the PetscViewer
5615c6c1daeSBarry Smith 
5625c6c1daeSBarry Smith     Level: intermediate
5635c6c1daeSBarry Smith 
5645c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
5655c6c1daeSBarry Smith 
5665c6c1daeSBarry Smith @*/
5675c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawClear(PetscViewer viewer)
5685c6c1daeSBarry Smith {
5695c6c1daeSBarry Smith   PetscErrorCode   ierr;
5705c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
571e5ab1681SLisandro Dalcin   PetscBool        isdraw;
572e5ab1681SLisandro Dalcin   PetscInt         i;
5735c6c1daeSBarry Smith 
5745c6c1daeSBarry Smith   PetscFunctionBegin;
575e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
5765c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
577e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
5785c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
579e5ab1681SLisandro Dalcin 
5805c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
5815c6c1daeSBarry Smith     if (vdraw->draw[i]) {ierr = PetscDrawClear(vdraw->draw[i]);CHKERRQ(ierr);}
5825c6c1daeSBarry Smith   }
5835c6c1daeSBarry Smith   PetscFunctionReturn(0);
5845c6c1daeSBarry Smith }
5855c6c1daeSBarry Smith 
5865c6c1daeSBarry Smith /*@
5875c6c1daeSBarry Smith     PetscViewerDrawGetPause - Gets a pause for the first present draw
5885c6c1daeSBarry Smith 
5895c6c1daeSBarry Smith     Not Collective
5905c6c1daeSBarry Smith 
5915c6c1daeSBarry Smith     Input Parameter:
5925c6c1daeSBarry Smith .  viewer - the PetscViewer
5935c6c1daeSBarry Smith 
5945c6c1daeSBarry Smith     Output Parameter:
5955c6c1daeSBarry Smith .  pause - the pause value
5965c6c1daeSBarry Smith 
5975c6c1daeSBarry Smith     Level: intermediate
5985c6c1daeSBarry Smith 
5995c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6005c6c1daeSBarry Smith 
6015c6c1daeSBarry Smith @*/
6025c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetPause(PetscViewer viewer,PetscReal *pause)
6035c6c1daeSBarry Smith {
6045c6c1daeSBarry Smith   PetscErrorCode   ierr;
6055c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
606e5ab1681SLisandro Dalcin   PetscBool        isdraw;
607e5ab1681SLisandro Dalcin   PetscInt         i;
6085c6c1daeSBarry Smith   PetscDraw        draw;
6095c6c1daeSBarry Smith 
6105c6c1daeSBarry Smith   PetscFunctionBegin;
611e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6125c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
613e5ab1681SLisandro Dalcin   if (!isdraw) {*pause = 0.0; PetscFunctionReturn(0);}
6145c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
615e5ab1681SLisandro Dalcin 
6165c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
6175c6c1daeSBarry Smith     if (vdraw->draw[i]) {
6185c6c1daeSBarry Smith       ierr = PetscDrawGetPause(vdraw->draw[i],pause);CHKERRQ(ierr);
6195c6c1daeSBarry Smith       PetscFunctionReturn(0);
6205c6c1daeSBarry Smith     }
6215c6c1daeSBarry Smith   }
6225c6c1daeSBarry Smith   /* none exist yet so create one and get its pause */
6235c6c1daeSBarry Smith   ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr);
624e5ab1681SLisandro Dalcin   ierr = PetscDrawGetPause(draw,pause);CHKERRQ(ierr);
6255c6c1daeSBarry Smith   PetscFunctionReturn(0);
6265c6c1daeSBarry Smith }
6275c6c1daeSBarry Smith 
6285c6c1daeSBarry Smith /*@
6295c6c1daeSBarry Smith     PetscViewerDrawSetPause - Sets a pause for each PetscDraw in the viewer
6305c6c1daeSBarry Smith 
6315c6c1daeSBarry Smith     Not Collective
6325c6c1daeSBarry Smith 
6335c6c1daeSBarry Smith     Input Parameters:
6345c6c1daeSBarry Smith +  viewer - the PetscViewer
6355c6c1daeSBarry Smith -  pause - the pause value
6365c6c1daeSBarry Smith 
6375c6c1daeSBarry Smith     Level: intermediate
6385c6c1daeSBarry Smith 
6395c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6405c6c1daeSBarry Smith 
6415c6c1daeSBarry Smith @*/
6425c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetPause(PetscViewer viewer,PetscReal pause)
6435c6c1daeSBarry Smith {
6445c6c1daeSBarry Smith   PetscErrorCode   ierr;
645e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
6465c6c1daeSBarry Smith   PetscBool        isdraw;
647e5ab1681SLisandro Dalcin   PetscInt         i;
6485c6c1daeSBarry Smith 
6495c6c1daeSBarry Smith   PetscFunctionBegin;
650e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6515c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
652e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
653e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
654afe78b3cSBarry Smith 
655afe78b3cSBarry Smith   vdraw->pause = pause;
6565c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
6575c6c1daeSBarry Smith     if (vdraw->draw[i]) {ierr = PetscDrawSetPause(vdraw->draw[i],pause);CHKERRQ(ierr);}
6585c6c1daeSBarry Smith   }
6595c6c1daeSBarry Smith   PetscFunctionReturn(0);
6605c6c1daeSBarry Smith }
6615c6c1daeSBarry Smith 
6625c6c1daeSBarry Smith 
6635c6c1daeSBarry Smith /*@
6645c6c1daeSBarry Smith     PetscViewerDrawSetHold - Holds previous image when drawing new image
6655c6c1daeSBarry Smith 
6665c6c1daeSBarry Smith     Not Collective
6675c6c1daeSBarry Smith 
6685c6c1daeSBarry Smith     Input Parameters:
6695c6c1daeSBarry Smith +  viewer - the PetscViewer
6705c6c1daeSBarry Smith -  hold - indicates to hold or not
6715c6c1daeSBarry Smith 
6725c6c1daeSBarry Smith     Level: intermediate
6735c6c1daeSBarry Smith 
6745c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6755c6c1daeSBarry Smith 
6765c6c1daeSBarry Smith @*/
6775c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetHold(PetscViewer viewer,PetscBool hold)
6785c6c1daeSBarry Smith {
6795c6c1daeSBarry Smith   PetscErrorCode   ierr;
6805c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
6815c6c1daeSBarry Smith   PetscBool        isdraw;
6825c6c1daeSBarry Smith 
6835c6c1daeSBarry Smith   PetscFunctionBegin;
684e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6855c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
686e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
6875c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
688e5ab1681SLisandro Dalcin 
6895c6c1daeSBarry Smith   vdraw->hold = hold;
6905c6c1daeSBarry Smith   PetscFunctionReturn(0);
6915c6c1daeSBarry Smith }
6925c6c1daeSBarry Smith 
6935c6c1daeSBarry Smith /*@
694d97d059aSBarry Smith     PetscViewerDrawGetHold - Checks if holds previous image when drawing new image
6955c6c1daeSBarry Smith 
6965c6c1daeSBarry Smith     Not Collective
6975c6c1daeSBarry Smith 
6985c6c1daeSBarry Smith     Input Parameter:
6995c6c1daeSBarry Smith .  viewer - the PetscViewer
7005c6c1daeSBarry Smith 
7015c6c1daeSBarry Smith     Output Parameter:
7025c6c1daeSBarry Smith .  hold - indicates to hold or not
7035c6c1daeSBarry Smith 
7045c6c1daeSBarry Smith     Level: intermediate
7055c6c1daeSBarry Smith 
7065c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
7075c6c1daeSBarry Smith 
7085c6c1daeSBarry Smith @*/
7095c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetHold(PetscViewer viewer,PetscBool *hold)
7105c6c1daeSBarry Smith {
7115c6c1daeSBarry Smith   PetscErrorCode   ierr;
7125c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
7135c6c1daeSBarry Smith   PetscBool        isdraw;
7145c6c1daeSBarry Smith 
7155c6c1daeSBarry Smith   PetscFunctionBegin;
716e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
7175c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
718e5ab1681SLisandro Dalcin   if (!isdraw) {*hold = PETSC_FALSE; PetscFunctionReturn(0);}
7195c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
720e5ab1681SLisandro Dalcin 
7215c6c1daeSBarry Smith   *hold = vdraw->hold;
7225c6c1daeSBarry Smith   PetscFunctionReturn(0);
7235c6c1daeSBarry Smith }
7245c6c1daeSBarry Smith 
7255c6c1daeSBarry Smith /* ---------------------------------------------------------------------*/
7265c6c1daeSBarry Smith /*
7275c6c1daeSBarry Smith     The variable Petsc_Viewer_Draw_keyval is used to indicate an MPI attribute that
7285c6c1daeSBarry Smith   is attached to a communicator, in this case the attribute is a PetscViewer.
7295c6c1daeSBarry Smith */
730d4c7638eSBarry Smith PetscMPIInt Petsc_Viewer_Draw_keyval = MPI_KEYVAL_INVALID;
7315c6c1daeSBarry Smith 
7325c6c1daeSBarry Smith /*@C
7335c6c1daeSBarry Smith     PETSC_VIEWER_DRAW_ - Creates a window PetscViewer shared by all processors
7345c6c1daeSBarry Smith                      in a communicator.
7355c6c1daeSBarry Smith 
736*d083f849SBarry Smith      Collective
7375c6c1daeSBarry Smith 
7385c6c1daeSBarry Smith      Input Parameter:
7395c6c1daeSBarry Smith .    comm - the MPI communicator to share the window PetscViewer
7405c6c1daeSBarry Smith 
7415c6c1daeSBarry Smith      Level: intermediate
7425c6c1daeSBarry Smith 
7435c6c1daeSBarry Smith      Notes:
7445c6c1daeSBarry Smith      Unlike almost all other PETSc routines, PETSC_VIEWER_DRAW_ does not return
7455c6c1daeSBarry Smith      an error code.  The window is usually used in the form
7465c6c1daeSBarry Smith $       XXXView(XXX object,PETSC_VIEWER_DRAW_(comm));
7475c6c1daeSBarry Smith 
7485c6c1daeSBarry Smith .seealso: PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF, PetscViewerDrawOpen(),
7495c6c1daeSBarry Smith @*/
7505c6c1daeSBarry Smith PetscViewer  PETSC_VIEWER_DRAW_(MPI_Comm comm)
7515c6c1daeSBarry Smith {
7525c6c1daeSBarry Smith   PetscErrorCode ierr;
7535c6c1daeSBarry Smith   PetscMPIInt    flag;
7545c6c1daeSBarry Smith   PetscViewer    viewer;
7555c6c1daeSBarry Smith   MPI_Comm       ncomm;
7565c6c1daeSBarry Smith 
7575c6c1daeSBarry Smith   PetscFunctionBegin;
758efca3c55SSatish Balay   ierr = PetscCommDuplicate(comm,&ncomm,NULL);if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7595c6c1daeSBarry Smith   if (Petsc_Viewer_Draw_keyval == MPI_KEYVAL_INVALID) {
76012801b39SBarry Smith     ierr = MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN,MPI_COMM_NULL_DELETE_FN,&Petsc_Viewer_Draw_keyval,0);
761efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7625c6c1daeSBarry Smith   }
76347435625SJed Brown   ierr = MPI_Comm_get_attr(ncomm,Petsc_Viewer_Draw_keyval,(void**)&viewer,&flag);
764efca3c55SSatish Balay   if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7655c6c1daeSBarry Smith   if (!flag) { /* PetscViewer not yet created */
7665c6c1daeSBarry Smith     ierr = PetscViewerDrawOpen(ncomm,0,0,PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
767efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7685c6c1daeSBarry Smith     ierr = PetscObjectRegisterDestroy((PetscObject)viewer);
769efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
77047435625SJed Brown     ierr = MPI_Comm_set_attr(ncomm,Petsc_Viewer_Draw_keyval,(void*)viewer);
771efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7725c6c1daeSBarry Smith   }
7735c6c1daeSBarry Smith   ierr = PetscCommDestroy(&ncomm);
774efca3c55SSatish Balay   if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7755c6c1daeSBarry Smith   PetscFunctionReturn(viewer);
7765c6c1daeSBarry Smith }
7775c6c1daeSBarry Smith 
7785c6c1daeSBarry Smith /*@
7795c6c1daeSBarry Smith     PetscViewerDrawSetBounds - sets the upper and lower bounds to be used in plotting
7805c6c1daeSBarry Smith 
7815c6c1daeSBarry Smith     Collective on PetscViewer
7825c6c1daeSBarry Smith 
7835c6c1daeSBarry Smith     Input Parameters:
7845c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
7855c6c1daeSBarry Smith .   nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate()
7865c6c1daeSBarry Smith -   bounds - the actual bounds, the size of this is 2*nbounds, the values are stored in the order min F_0, max F_0, min F_1, max F_1, .....
7875c6c1daeSBarry Smith 
788e9457bf7SBarry Smith 
789e9457bf7SBarry Smith     Options Database:
790e9457bf7SBarry Smith .   -draw_bounds  minF0,maxF0,minF1,maxF1
791e9457bf7SBarry Smith 
7925c6c1daeSBarry Smith     Level: intermediate
7935c6c1daeSBarry Smith 
79495452b02SPatrick Sanan     Notes:
79595452b02SPatrick Sanan     this determines the colors used in 2d contour plots generated with VecView() for DMDA in 2d. Any values in the vector below or above the
796f3f0eb19SBarry Smith       bounds are moved to the bound value before plotting. In this way the color index from color to physical value remains the same for all plots generated with
797f3f0eb19SBarry Smith       this viewer. Otherwise the color to physical value meaning changes with each new image if this is not set.
798f3f0eb19SBarry Smith 
7995c6c1daeSBarry Smith 
8005c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
8015c6c1daeSBarry Smith @*/
8025c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetBounds(PetscViewer viewer,PetscInt nbounds,const PetscReal *bounds)
8035c6c1daeSBarry Smith {
804e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
805e5ab1681SLisandro Dalcin   PetscBool        isdraw;
8065c6c1daeSBarry Smith   PetscErrorCode   ierr;
8075c6c1daeSBarry Smith 
8085c6c1daeSBarry Smith 
8095c6c1daeSBarry Smith   PetscFunctionBegin;
8105c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
811e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
812e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
813e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
814a297a907SKarl Rupp 
815e5ab1681SLisandro Dalcin   vdraw->nbounds = nbounds;
816e5ab1681SLisandro Dalcin   ierr = PetscFree(vdraw->bounds);CHKERRQ(ierr);
817785e854fSJed Brown   ierr = PetscMalloc1(2*nbounds,&vdraw->bounds);CHKERRQ(ierr);
8185c6c1daeSBarry Smith   ierr = PetscMemcpy(vdraw->bounds,bounds,2*nbounds*sizeof(PetscReal));CHKERRQ(ierr);
8195c6c1daeSBarry Smith   PetscFunctionReturn(0);
8205c6c1daeSBarry Smith }
8215c6c1daeSBarry Smith 
8225c6c1daeSBarry Smith /*@C
8235c6c1daeSBarry Smith     PetscViewerDrawGetBounds - gets the upper and lower bounds to be used in plotting set with PetscViewerDrawSetBounds()
8245c6c1daeSBarry Smith 
8255c6c1daeSBarry Smith     Collective on PetscViewer
8265c6c1daeSBarry Smith 
8275c6c1daeSBarry Smith     Input Parameter:
8285c6c1daeSBarry Smith .   viewer - the PetscViewer (created with PetscViewerDrawOpen())
8295c6c1daeSBarry Smith 
8305c6c1daeSBarry Smith     Output Paramters:
8315c6c1daeSBarry Smith +   nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate()
8325c6c1daeSBarry Smith -   bounds - the actual bounds, the size of this is 2*nbounds, the values are stored in the order min F_0, max F_0, min F_1, max F_1, .....
8335c6c1daeSBarry Smith 
8345c6c1daeSBarry Smith     Level: intermediate
8355c6c1daeSBarry Smith 
8365c6c1daeSBarry Smith 
837f3f0eb19SBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawSetBounds()
8385c6c1daeSBarry Smith @*/
8395c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetBounds(PetscViewer viewer,PetscInt *nbounds,const PetscReal **bounds)
8405c6c1daeSBarry Smith {
841e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
842e5ab1681SLisandro Dalcin   PetscBool        isdraw;
843e5ab1681SLisandro Dalcin   PetscErrorCode   ierr;
8445c6c1daeSBarry Smith 
8455c6c1daeSBarry Smith   PetscFunctionBegin;
8465c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
847e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
848e5ab1681SLisandro Dalcin   if (!isdraw) {if (nbounds) *nbounds = 0; if (bounds) *bounds = NULL; PetscFunctionReturn(0);}
849e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
850e5ab1681SLisandro Dalcin 
851e5ab1681SLisandro Dalcin   if (nbounds) *nbounds = vdraw->nbounds;
852e5ab1681SLisandro Dalcin   if (bounds)  *bounds  = vdraw->bounds;
8535c6c1daeSBarry Smith   PetscFunctionReturn(0);
8545c6c1daeSBarry Smith }
855