Commits

BarryFSmith  committed 9bb5e83

fixed src/dm/examples/tutorials/ex7.c to use replacement for PetscViewerBinaryMatlabOpen()
also needed to fix bin/matlab/PetscBagRead.m for new location of bagimpl.h
and put bagimpl.h into the appropriate public place

  • Participants
  • Parent commits a3afe2d

Comments (0)

Files changed (8)

File bin/matlab/PetscBagRead.m

    
 function [n, h] = ParsePetscBagDotH
    
-   petscbagh = [GetPetscDir,'/src/sys/bag/bagimpl.h'];
+   petscbagh = [GetPetscDir,'/include/petsc-private/bagimpl.h'];
    fid = fopen(petscbagh,'rt');
    if (fid<0)
       errstr = sprintf('Could not open %s.',petscbagh);

File include/petsc-private/bagimpl.h

+#if !defined(__BAGIMPL)
+#define __BAGIMPL
+#include <petscbag.h>
+
+#define PETSC_BAG_NAME_LENGTH 64
+#define PETSC_BAG_HELP_LENGTH 128
+
+struct _n_PetscBagItem {
+  PetscDataType dtype;
+  PetscInt      offset;
+  PetscInt      msize;
+  char          name[PETSC_BAG_NAME_LENGTH],help[PETSC_BAG_HELP_LENGTH];
+  char          **list;
+  PetscBool     freelist;
+  PetscBagItem  next;
+};
+
+struct _n_PetscBag {
+  MPI_Comm     bagcomm;
+  PetscInt     bagsize;
+  void         *structlocation;
+  PetscInt     count;
+  char         bagname[PETSC_BAG_NAME_LENGTH];
+  char         baghelp[PETSC_BAG_HELP_LENGTH];
+  char         *bagprefix;
+  PetscBagItem bagitems;
+};
+
+
+#endif

File src/dm/examples/tutorials/ex7.c

-static char help[] = "Demonstrates using the PetscViewerBinaryMatlab viewer\n\n";
+static char help[] = "Demonstrates using PetscViewerSetFormat(viewer,PETSC_FORMAT_BINARY_MATLAB)\n\n";
 
 /*T
    Concepts: viewers
   ierr = PetscBagRegisterBool (bag,&params->ta,PETSC_TRUE,"do_output","Write output file (true/false)");CHKERRQ(ierr);
 
   /*
-     Write output file with PetscViewerBinaryMatlab viewer.
+     Write output file with PETSC_VIEWER_BINARY_MATLAB format
      NOTE: the output generated with this viewer can be loaded into
-     matlab using bin/matlab/PetscBinaryReadMatlab.m
+     MATLAB using $PETSC_DIR/bin/matlab/PetscReadBinaryMatlab.m
   */
-  ierr = PetscViewerBinaryMatlabOpen(PETSC_COMM_WORLD,params->filename,&viewer);CHKERRQ(ierr);
-  ierr = PetscViewerBinaryMatlabOutputBag(viewer,"params",bag);CHKERRQ(ierr);
+  ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,params->filename,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
+  ierr = PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_MATLAB);CHKERRQ(ierr);
+  ierr = PetscBagView(bag,viewer);CHKERRQ(ierr);
   ierr = DMDASetFieldName(da,0,"field1");CHKERRQ(ierr);
   ierr = DMDASetFieldName(da,1,"field2");CHKERRQ(ierr);
-  ierr = PetscViewerBinaryMatlabOutputVecDA(viewer,"da1",global,da);CHKERRQ(ierr);
-  ierr = PetscViewerBinaryMatlabDestroy(&viewer);CHKERRQ(ierr);
+  ierr = PetscObjectSetName((PetscObject)global,"da1");CHKERRQ(ierr);
+  ierr = VecView(global,viewer);CHKERRQ(ierr);
+  ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
 
   /* clean up and exit */
   ierr = PetscBagDestroy(&bag);CHKERRQ(ierr);

File src/docs/website/documentation/changes/34.html

       <h4>General:</h4>
       <ul>
         <li>PetscGetTime() is replaced with PetscTime(), in C you must include petsctime.h to use</li>
-        <li>PetscViewerBinaryMatlabOpen() and friends are all removed, simply use PetscViewerBinaryOpen() followed by PetscViewerSetFormat(viewer,PETSC_FORMAT_BINARY_MATLAB)</li>
+        <li>PetscViewerBinaryMatlabOpen() and friends are all removed, simply use PetscViewerBinaryOpen() followed by PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_MATLAB)</li>
         <li>Users should use new <tt>PetscFunctionBeginUser</tt> in there code instead of <tt>PetscFunctionBegin</tt> to get more relevant diagnostics.</li>
         <li>Replaced the hodge-podge of -xxx_view -xxx_view_yyy with a single consistent scheme: -xxx_view [ascii,binary,draw,socket,matlab,vtk][:filename][:ascii_info,ascii_info_detail,ascii_matlab,draw_contour,etc].</li>
         <li>In PETSc options files, the comment characters <tt>!</tt> and <tt>%</tt> are no longer supported, use <tt>#</tt>.</li>

File src/sys/classes/bag/bag.c

 
-#include <../src/sys/classes/bag/bagimpl.h>     /*I  "petscbag.h"   I*/
+#include <petsc-private/bagimpl.h>     /*I  "petscbag.h"   I*/
 #include <petscviewer.h>
 
 #undef __FUNCT__

File src/sys/classes/bag/bagimpl.h

-#if !defined(__BAGIMPL)
-#define __BAGIMPL
-#include <petscbag.h>
-
-#define PETSC_BAG_NAME_LENGTH 64
-#define PETSC_BAG_HELP_LENGTH 128
-
-struct _n_PetscBagItem {
-  PetscDataType dtype;
-  PetscInt      offset;
-  PetscInt      msize;
-  char          name[PETSC_BAG_NAME_LENGTH],help[PETSC_BAG_HELP_LENGTH];
-  char          **list;
-  PetscBool     freelist;
-  PetscBagItem  next;
-};
-
-struct _n_PetscBag {
-  MPI_Comm     bagcomm;
-  PetscInt     bagsize;
-  void         *structlocation;
-  PetscInt     count;
-  char         bagname[PETSC_BAG_NAME_LENGTH];
-  char         baghelp[PETSC_BAG_HELP_LENGTH];
-  char         *bagprefix;
-  PetscBagItem bagitems;
-};
-
-
-#endif

File src/sys/classes/bag/f90-custom/zbagf90.c

 #include <../src/sys/f90-src/f90impl.h>
 #include <petsc-private/fortranimpl.h>
 #include <petscbag.h>
-#include <../src/sys/classes/bag/bagimpl.h>
+#include <petsc-private/bagimpl.h>
 #include <petscviewer.h>
 
 #if defined(PETSC_HAVE_FORTRAN_CAPS)

File src/sys/classes/bag/makefile

 CPPFLAGS  =
 SOURCEC	  = bag.c
 SOURCEF	  =
-SOURCEH	  = ../../../../include/petscbag.h
+SOURCEH	  = ../../../../include/petscbag.h ../../../../include/petsc-private/petscbagimpl.h
 MANSEC	  = Sys
 LIBBASE	  = libpetscsys
 DIRS	  = f2003-src