[petsc-users] PetscViewerBinaryMatlab example for petsc-3.4.1

Bishesh Khanal bisheshkh at gmail.com
Fri Jun 28 03:10:57 CDT 2013


Yes, it works now. Thanks!


On Fri, Jun 28, 2013 at 6:16 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
>   Bishesh,
>
>     Thanks for reporting this problem. I did not fix this example when
> removing PetscViewerBinaryMatlabOpen() nor did I test it well before the
> release.  I have updated the example and made other needed changes to PETSc
> code in the maint branch of the PETSc repository.   All the fixes will in
> the next patch release of PETSc 3.4 If you would like to try the fixed code
> now you can follow the instructions at
> http://www.mcs.anl.gov/petsc/download/index.html and follow the
> instructions that say use
>
> git clone -b maint https://bitbucket.org/petsc/petsc petsc
>
> with this copy ex7.c should work correctly and
> bin/matlab/PetscReadBinaryMatlab.m should read the data into Matlab.
>
>   Please let us know of any difficulties.
>
>    Barry
>
>
>
>
>
> On Jun 26, 2013, at 8:44 AM, Bishesh Khanal <bisheshkh at gmail.com> wrote:
>
> > Dear all,
> > I'm just starting to learn using Petsc. I was trying the example
> (../src/dm/examples/tutorials/ex7.c)
> > for petsc-3.4.1 . However it seems this file has not been updated for
> the 3.4.1 version since it uses
> > PetscViewerBinaryMatlabOpen() and friends which have been removed from
> this newer version.
> > Now I tried to change them but I have some questions:
> >
> > The lines I wanted to change are the ones that use following funcitons:
> > 1. PetscViewerBinaryMatlabOpen(PETSC_COMM_WORLD,params->filename,&viewer)
> > 2. PetscViewerBinaryMatlabOutputBag(viewer,"params",bag)
> > 3. PetscViewerBinaryMatlabOutputVecDA(viewer,"da1",global,da)
> >
> > For 1, it seems I can change it with:
> >
> PetscViewerBinaryOpen(PETSC_COMM_WORLD,params->filename,FILE_MODE_WRITE,&viewer)
> > PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_MATLAB)
> >
> > Now, for the 2 and 3 I thought I need to use:
> > PetscViewerBinaryWrite(PetscViewer viewer,void *data,PetscInt
> count,PetscDataType dtype,PetscBool istemp)
> > but I'm not sure what exactly to provide as argument for count and dtype
> to have the same functionality as intended in ex7.c
> > I tried (for 2) using:
> > ierr = PetscViewerBinaryWrite(viewer,&bag,1,PETSC_OBJECT,PETSC_FALSE);
> > but it results in an error when running the executable.
> > How should I count the no. of items for count variable in this case for
> the bag object ?
> > And what should be the dtype ?
> >
> > Thanks,
> > Bishesh
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130628/0d74f590/attachment.html>


More information about the petsc-users mailing list