1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecLoad.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>VecLoad</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.14.5 2021-03-03</b></div>
<div id="bugreport" align=right><a href="mailto:petsc-maint@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: petsc-3.14.5 v3.14.5 docs/manualpages/Vec/VecLoad.html "><small>Report Typos and Errors</small></a></div>
<A NAME="VecLoad"><H1>VecLoad</H1></A>
Loads a vector that has been stored in binary or HDF5 format with <A HREF="../Vec/VecView.html#VecView">VecView</A>().
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#include "petscvec.h"
<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> <A HREF="../Vec/VecLoad.html#VecLoad">VecLoad</A>(<A HREF="../Vec/Vec.html#Vec">Vec</A> vec, <A HREF="../Viewer/PetscViewer.html#PetscViewer">PetscViewer</A> viewer)
</PRE>
Collective on <A HREF="../Viewer/PetscViewer.html#PetscViewer">PetscViewer</A>
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>vec </B></TD><TD>- the newly loaded vector, this needs to have been created with <A HREF="../Vec/VecCreate.html#VecCreate">VecCreate</A>() or
some related function before a call to <A HREF="../Vec/VecLoad.html#VecLoad">VecLoad</A>().
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>viewer </B></TD><TD>- binary file viewer, obtained from <A HREF="../Viewer/PetscViewerBinaryOpen.html#PetscViewerBinaryOpen">PetscViewerBinaryOpen</A>() or
HDF5 file viewer, obtained from <A HREF="../Viewer/PetscViewerHDF5Open.html#PetscViewerHDF5Open">PetscViewerHDF5Open</A>()
</TD></TR></TABLE>
<P>
<P>
<H3><FONT COLOR="#CC3333">Notes</FONT></H3>
Defaults to the standard Seq or MPI <A HREF="../Vec/Vec.html#Vec">Vec</A>, if you want some other type of <A HREF="../Vec/Vec.html#Vec">Vec</A> call <A HREF="../Vec/VecSetFromOptions.html#VecSetFromOptions">VecSetFromOptions</A>()
before calling this.
<P>
The input file must contain the full global vector, as
written by the routine <A HREF="../Vec/VecView.html#VecView">VecView</A>().
<P>
If the type or size of vec is not set before a call to <A HREF="../Vec/VecLoad.html#VecLoad">VecLoad</A>, PETSc
sets the type and the local and global sizes. If type and/or
sizes are already set, then the same are used.
<P>
If using the binary viewer and the blocksize of the vector is greater than one then you must provide a unique prefix to
the vector with <A HREF="../Sys/PetscObjectSetOptionsPrefix.html#PetscObjectSetOptionsPrefix">PetscObjectSetOptionsPrefix</A>((<A HREF="../Sys/PetscObject.html#PetscObject">PetscObject</A>)vec,"uniqueprefix"); BEFORE calling <A HREF="../Vec/VecView.html#VecView">VecView</A>() on the
vector to be stored and then set that same unique prefix on the vector that you pass to <A HREF="../Vec/VecLoad.html#VecLoad">VecLoad</A>(). The blocksize
information is stored in an ASCII file with the same name as the binary file plus a ".info" appended to the
filename. If you copy the binary file, make sure you copy the associated .info file with it.
<P>
If using HDF5, you must assign the <A HREF="../Vec/Vec.html#Vec">Vec</A> the same name as was used in the <A HREF="../Vec/Vec.html#Vec">Vec</A>
that was stored in the file using <A HREF="../Sys/PetscObjectSetName.html#PetscObjectSetName">PetscObjectSetName</A>(). Otherwise you will
get the error message: "Cannot H5DOpen2() with <A HREF="../Vec/Vec.html#Vec">Vec</A> name NAMEOFOBJECT".
<P>
If the HDF5 file contains a two dimensional array the first dimension is treated as the block size
in loading the vector. Hence, for example, using Matlab notation h5create('vector.dat','/Test_Vec',[27 1]);
will load a vector of size 27 and block size 27 thus resulting in all 27 entries being on the first process of
vectors communicator and the rest of the processes having zero entries
<P>
<H3><FONT COLOR="#CC3333">Notes for advanced users when using the binary viewer</FONT></H3>
Most users should not need to know the details of the binary storage
format, since <A HREF="../Vec/VecLoad.html#VecLoad">VecLoad</A>() and <A HREF="../Vec/VecView.html#VecView">VecView</A>() completely hide these details.
But for anyone who's interested, the standard binary vector storage
format is
<PRE>
<A HREF="../Sys/PetscInt.html#PetscInt">PetscInt</A> VEC_FILE_CLASSID
<A HREF="../Sys/PetscInt.html#PetscInt">PetscInt</A> number of rows
<A HREF="../Sys/PetscScalar.html#PetscScalar">PetscScalar</A> *values of all entries
</PRE>
<P>
In addition, PETSc automatically uses byte swapping to work on all machines; the files
are written ALWAYS using big-endian ordering. On small-endian machines the numbers
are converted to the small-endian format when they are read in from the file.
See <A HREF="../Sys/PetscBinaryRead.html#PetscBinaryRead">PetscBinaryRead</A>() and <A HREF="../Sys/PetscBinaryWrite.html#PetscBinaryWrite">PetscBinaryWrite</A>() to see how this may be done.
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../Viewer/PetscViewerBinaryOpen.html#PetscViewerBinaryOpen">PetscViewerBinaryOpen</A>(), <A HREF="../Vec/VecView.html#VecView">VecView</A>(), <A HREF="../Mat/MatLoad.html#MatLoad">MatLoad</A>(), <A HREF="../Vec/VecLoad.html#VecLoad">VecLoad</A>()
<BR><P><B></B><H3><FONT COLOR="#CC3333">Level</FONT></H3>intermediate<BR>
<H3><FONT COLOR="#CC3333">Location</FONT></H3>
</B><A HREF="../../../src/vec/vec/interface/vector.c.html#VecLoad">src/vec/vec/interface/vector.c</A>
<P><H3><FONT COLOR="#CC3333">Examples</FONT></H3>
<A HREF="../../../src/vec/vec/tutorials/ex5.c.html">src/vec/vec/tutorials/ex5.c.html</A><BR>
<A HREF="../../../src/vec/vec/tutorials/ex6.c.html">src/vec/vec/tutorials/ex6.c.html</A><BR>
<A HREF="../../../src/vec/vec/tutorials/ex10.c.html">src/vec/vec/tutorials/ex10.c.html</A><BR>
<A HREF="../../../src/vec/vec/tutorials/ex19.c.html">src/vec/vec/tutorials/ex19.c.html</A><BR>
<A HREF="../../../src/vec/vec/tutorials/ex42.c.html">src/vec/vec/tutorials/ex42.c.html</A><BR>
<A HREF="../../../src/vec/vec/tutorials/ex42a.c.html">src/vec/vec/tutorials/ex42a.c.html</A><BR>
<A HREF="../../../src/vec/vec/tutorials/ex5f.F90.html">src/vec/vec/tutorials/ex5f.F90.html</A><BR>
<A HREF="../../../src/mat/tutorials/ex12.c.html">src/mat/tutorials/ex12.c.html</A><BR>
<A HREF="../../../src/dm/tutorials/ex9.c.html">src/dm/tutorials/ex9.c.html</A><BR>
<A HREF="../../../src/dm/tutorials/ex10.c.html">src/dm/tutorials/ex10.c.html</A><BR>
<A HREF="../../../src/dm/tutorials/ex15.c.html">src/dm/tutorials/ex15.c.html</A><BR>
<P><H3><FONT COLOR="CC3333">Implementations</FONT></H3><A HREF="../../../src/dm/impls/da/gr2.c.html#VecLoad_HDF5_DA">VecLoad_HDF5_DA in src/dm/impls/da/gr2.c</A><BR>
<A HREF="../../../src/dm/impls/da/gr2.c.html#VecLoad_Binary_DA">VecLoad_Binary_DA in src/dm/impls/da/gr2.c</A><BR>
<A HREF="../../../src/dm/impls/da/gr2.c.html#VecLoad_Default_DA">VecLoad_Default_DA in src/dm/impls/da/gr2.c</A><BR>
<A HREF="../../../src/dm/impls/forest/p4est/pforest.c.html#VecLoad_pforest">VecLoad_pforest in src/dm/impls/forest/p4est/pforest.c</A><BR>
<A HREF="../../../src/dm/impls/forest/p4est/pforest.c.html#VecLoad_pforest_Native">VecLoad_pforest_Native in src/dm/impls/forest/p4est/pforest.c</A><BR>
<A HREF="../../../src/dm/impls/plex/plex.c.html#VecLoad_Plex_Local">VecLoad_Plex_Local in src/dm/impls/plex/plex.c</A><BR>
<A HREF="../../../src/dm/impls/plex/plex.c.html#VecLoad_Plex">VecLoad_Plex in src/dm/impls/plex/plex.c</A><BR>
<A HREF="../../../src/dm/impls/plex/plex.c.html#VecLoad_Plex_Native">VecLoad_Plex_Native in src/dm/impls/plex/plex.c</A><BR>
<A HREF="../../../src/dm/impls/plex/plexhdf5.c.html#VecLoad_Plex_HDF5_Internal">VecLoad_Plex_HDF5_Internal in src/dm/impls/plex/plexhdf5.c</A><BR>
<A HREF="../../../src/dm/impls/plex/plexhdf5.c.html#VecLoad_Plex_HDF5_Native_Internal">VecLoad_Plex_HDF5_Native_Internal in src/dm/impls/plex/plexhdf5.c</A><BR>
<BR><A HREF="./index.html">Index of all Vec routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
</BODY></HTML>
|