/*@C PetscViewerSetFromOptions - Sets the graphics type from the options database. Defaults to a PETSc X windows graphics. Collective on PetscViewer Input Parameter: . PetscViewer - the graphics context Level: intermediate Notes: Must be called after PetscViewerCreate() before the PetscViewer is used. Concepts: PetscViewer^setting options .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType @*/ PetscErrorCode PetscViewerSetFromOptions(PetscViewer viewer) { PetscErrorCode ierr; char vtype[256]; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); if (!PetscViewerList) { ierr = PetscViewerRegisterAll();CHKERRQ(ierr); } ierr = PetscObjectOptionsBegin((PetscObject)viewer);CHKERRQ(ierr); ierr = PetscOptionsFList("-viewer_type","Type of PetscViewer","None",PetscViewerList,(char*)(((PetscObject)viewer)->type_name ? ((PetscObject)viewer)->type_name : PETSCVIEWERASCII),vtype,256,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerSetType(viewer,vtype);CHKERRQ(ierr); } /* type has not been set? */ if (!((PetscObject)viewer)->type_name) { ierr = PetscViewerSetType(viewer,PETSCVIEWERASCII);CHKERRQ(ierr); } if (viewer->ops->setfromoptions) { ierr = (*viewer->ops->setfromoptions)(PetscOptionsObject,viewer);CHKERRQ(ierr); } /* process any options handlers added with PetscObjectAddOptionsHandler() */ ierr = PetscObjectProcessOptionsHandlers((PetscObject)viewer);CHKERRQ(ierr); ierr = PetscViewerViewFromOptions(viewer,NULL,"-viewer_view");CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C DMPlexCreateGmshFromFile - Create a DMPlex mesh from a Gmsh file + comm - The MPI communicator . filename - Name of the Gmsh file - interpolate - Create faces and edges in the mesh Output Parameter: . dm - The DM object representing the mesh Level: beginner .seealso: DMPlexCreateFromFile(), DMPlexCreateGmsh(), DMPlexCreate() @*/ PetscErrorCode DMPlexCreateGmshFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm) { PetscViewer viewer, vheader; PetscMPIInt rank; PetscViewerType vtype; char line[PETSC_MAX_PATH_LEN]; int snum; PetscBool match; int fT; PetscInt fileType; float version; PetscErrorCode ierr; PetscFunctionBegin; ierr = MPI_Comm_rank(comm, &rank); CHKERRQ(ierr); /* Determine Gmsh file type (ASCII or binary) from file header */ ierr = PetscViewerCreate(comm, &vheader); CHKERRQ(ierr); ierr = PetscViewerSetType(vheader, PETSCVIEWERASCII); CHKERRQ(ierr); ierr = PetscViewerFileSetMode(vheader, FILE_MODE_READ); CHKERRQ(ierr); ierr = PetscViewerFileSetName(vheader, filename); CHKERRQ(ierr); if (!rank) { /* Read only the first two lines of the Gmsh file */ ierr = PetscViewerRead(vheader, line, 1, NULL, PETSC_STRING); CHKERRQ(ierr); ierr = PetscStrncmp(line, "$MeshFormat", PETSC_MAX_PATH_LEN, &match); CHKERRQ(ierr); if (!match) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file"); ierr = PetscViewerRead(vheader, line, 2, NULL, PETSC_STRING); CHKERRQ(ierr); snum = sscanf(line, "%f %d", &version, &fT); fileType = (PetscInt) fT; if (snum != 2) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse Gmsh file header: %s", line); if (version < 2.0) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file must be at least version 2.0"); } ierr = MPI_Bcast(&fileType, 1, MPIU_INT, 0, comm); CHKERRQ(ierr); /* Create appropriate viewer and build plex */ if (fileType == 0) vtype = PETSCVIEWERASCII; else vtype = PETSCVIEWERBINARY; ierr = PetscViewerCreate(comm, &viewer); CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, vtype); CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ); CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, filename); CHKERRQ(ierr); ierr = DMPlexCreateGmsh(comm, viewer, interpolate, dm); CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer); CHKERRQ(ierr); ierr = PetscViewerDestroy(&vheader); CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode DMSetFromOptions_Mesh(DM dm) { PetscBool flg; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(dm, DM_CLASSID, 1); ierr = PetscOptionsHead("DMMesh Options");CHKERRQ(ierr); /* Handle DMMesh refinement */ /* Handle associated vectors */ /* Handle viewing */ ierr = PetscOptionsBool("-dm_mesh_view_vtk", "Output mesh in VTK format", "DMView", PETSC_FALSE, &flg, PETSC_NULL);CHKERRQ(ierr); if (flg) { PetscViewer viewer; ierr = PetscViewerCreate(((PetscObject) dm)->comm, &viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_VTK);CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, "mesh.vtk");CHKERRQ(ierr); ierr = DMView(dm, viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsBool("-dm_mesh_view", "Exhaustive mesh description", "DMView", PETSC_FALSE, &flg, PETSC_NULL);CHKERRQ(ierr); if (flg) { PetscViewer viewer; ierr = PetscViewerCreate(((PetscObject) dm)->comm, &viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DMView(dm, viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); }
/** * output_singular * ------ * Output the left and right singular vectors. */ PetscErrorCode output_singular(char *output_name, const Vec u, const Vec v) { PetscFunctionBegin; PetscErrorCode ierr; char output_name_prefixed[PETSC_MAX_PATH_LEN]; //const char *prefix = "/out/"; const char *u_extension = ".U"; const char *v_extension = ".V"; //ierr = PetscStrcpy(output_name_prefixed, getenv("FD3D_ROOT")); CHKERRQ(ierr); //ierr = PetscStrcat(output_name_prefixed, prefix); CHKERRQ(ierr); //ierr = PetscStrcat(output_name_prefixed, output_name); CHKERRQ(ierr); ierr = PetscStrcpy(output_name_prefixed, output_name); CHKERRQ(ierr); char u_file[PETSC_MAX_PATH_LEN]; char v_file[PETSC_MAX_PATH_LEN]; ierr = PetscStrcpy(u_file, output_name_prefixed); CHKERRQ(ierr); ierr = PetscStrcat(u_file, u_extension); CHKERRQ(ierr); ierr = PetscStrcpy(v_file, output_name_prefixed); CHKERRQ(ierr); ierr = PetscStrcat(v_file, v_extension); CHKERRQ(ierr); PetscViewer viewer; //viewer = PETSC_VIEWER_STDOUT_WORLD; //ierr = PetscViewerHDF5Open(PETSC_COMM_WORLD, h_file, FILE_MODE_WRITE, &viewer); CHKERRQ(ierr); /** Write the left singular vector u. */ ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer); CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, PETSCVIEWERBINARY); CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer, FILE_MODE_WRITE); CHKERRQ(ierr); ierr = PetscViewerBinarySkipInfo(viewer); CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, u_file); CHKERRQ(ierr); /* ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, e_file, FILE_MODE_WRITE, &viewer); CHKERRQ(ierr); */ ierr = VecView(u, viewer); CHKERRQ(ierr); /** Write the right singular vector v. */ ierr = PetscViewerDestroy(&viewer); CHKERRQ(ierr); ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer); CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, PETSCVIEWERBINARY); CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer, FILE_MODE_WRITE); CHKERRQ(ierr); ierr = PetscViewerBinarySkipInfo(viewer); CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, v_file); CHKERRQ(ierr); /* ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, h_file, FILE_MODE_WRITE, &viewer); CHKERRQ(ierr); */ ierr = VecView(v, viewer); CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer); CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode PetscViewerGetSingleton_ASCII(PetscViewer viewer,PetscViewer *outviewer) { PetscMPIInt rank; PetscErrorCode ierr; PetscViewer_ASCII *vascii = (PetscViewer_ASCII*)viewer->data,*ovascii; const char *name; PetscFunctionBegin; if (vascii->sviewer) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Singleton already obtained from PetscViewer and not restored"); ierr = PetscViewerCreate(PETSC_COMM_SELF,outviewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*outviewer,PETSCVIEWERASCII);CHKERRQ(ierr); ovascii = (PetscViewer_ASCII*)(*outviewer)->data; ovascii->fd = vascii->fd; ovascii->tab = vascii->tab; vascii->sviewer = *outviewer; (*outviewer)->format = viewer->format; ierr = PetscObjectGetName((PetscObject)viewer,&name);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)(*outviewer),name);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr); ((PetscViewer_ASCII*)((*outviewer)->data))->bviewer = viewer; (*outviewer)->ops->destroy = PetscViewerDestroy_ASCII_Singleton; if (rank) (*outviewer)->ops->flush = 0; else (*outviewer)->ops->flush = PetscViewerFlush_ASCII_Singleton_0; PetscFunctionReturn(0); }
PetscErrorCode MyVecLoad(const char fname[],PetscBool skippheader,PetscBool usempiio,Vec x) { MPI_Comm comm; PetscViewer viewer; PetscBool ismpiio,isskip; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = PetscObjectGetComm((PetscObject)x,&comm);CHKERRQ(ierr); ierr = PetscViewerCreate(comm,&viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(viewer,PETSCVIEWERBINARY);CHKERRQ(ierr); if (skippheader) { ierr = PetscViewerBinarySetSkipHeader(viewer,PETSC_TRUE);CHKERRQ(ierr); } ierr = PetscViewerFileSetMode(viewer,FILE_MODE_READ);CHKERRQ(ierr); if (usempiio) { ierr = PetscViewerBinarySetUseMPIIO(viewer,PETSC_TRUE);CHKERRQ(ierr); } ierr = PetscViewerFileSetName(viewer,fname);CHKERRQ(ierr); ierr = VecLoad(x,viewer);CHKERRQ(ierr); ierr = PetscViewerBinaryGetSkipHeader(viewer,&isskip);CHKERRQ(ierr); if (isskip) { ierr = PetscPrintf(comm,"*** PetscViewer[load] skipping header ***\n");CHKERRQ(ierr); } ierr = PetscViewerBinaryGetUseMPIIO(viewer,&ismpiio);CHKERRQ(ierr); if (ismpiio) { ierr = PetscPrintf(comm,"*** PetscViewer[load] using MPI-IO ***\n");CHKERRQ(ierr); } ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode PetscViewerGetSingleton_Draw(PetscViewer viewer,PetscViewer *sviewer) { PetscErrorCode ierr; PetscMPIInt rank; PetscInt i; PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*vsdraw; PetscFunctionBegin; if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to get singleton without first restoring previous"); /* only processor zero can use the PetscViewer draw singleton */ ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr); if (!rank) { ierr = PetscViewerCreate(PETSC_COMM_SELF,sviewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*sviewer,PETSCVIEWERDRAW);CHKERRQ(ierr); vsdraw = (PetscViewer_Draw*)(*sviewer)->data; for (i=0; i<vdraw->draw_max; i++) { if (vdraw->draw[i]) { ierr = PetscDrawGetSingleton(vdraw->draw[i],&vsdraw->draw[i]);CHKERRQ(ierr); } } } vdraw->singleton_made = PETSC_TRUE; PetscFunctionReturn(0); }
PetscErrorCode PetscViewerGetSubViewer_ASCII(PetscViewer viewer,MPI_Comm subcomm,PetscViewer *outviewer) { PetscMPIInt rank; PetscErrorCode ierr; PetscViewer_ASCII *vascii = (PetscViewer_ASCII*)viewer->data,*ovascii; PetscFunctionBegin; if (vascii->sviewer) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"SubViewer already obtained from PetscViewer and not restored"); ierr = PetscViewerASCIIPushSynchronized(viewer);CHKERRQ(ierr); ierr = PetscViewerCreate(subcomm,outviewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*outviewer,PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerASCIIPushSynchronized(*outviewer);CHKERRQ(ierr); ovascii = (PetscViewer_ASCII*)(*outviewer)->data; ovascii->fd = vascii->fd; ovascii->tab = vascii->tab; ovascii->closefile = PETSC_FALSE; vascii->sviewer = *outviewer; (*outviewer)->format = viewer->format; ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr); ((PetscViewer_ASCII*)((*outviewer)->data))->bviewer = viewer; (*outviewer)->ops->destroy = PetscViewerDestroy_ASCII_SubViewer; PetscFunctionReturn(0); }
int main(int argc, char **argv) { PetscErrorCode ierr; DM dm, rdm; PetscViewer vwr; PetscBool flg; char datafile[PETSC_MAX_PATH_LEN]; MPI_Comm comm; ierr = PetscInitialize(&argc, &argv, NULL, help); if (ierr) return ierr; comm = PETSC_COMM_WORLD; ierr = PetscViewerCreate(comm, &vwr);CHKERRQ(ierr); ierr = PetscViewerSetType(vwr, PETSCVIEWERHDF5);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(vwr, FILE_MODE_READ);CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL, NULL, "-f", datafile, PETSC_MAX_PATH_LEN, &flg);CHKERRQ(ierr); if (!flg) SETERRQ(comm, PETSC_ERR_ARG_WRONG, "Must provide meshfile"); ierr = PetscViewerFileSetName(vwr, datafile);CHKERRQ(ierr); ierr = DMCreate(comm, &dm);CHKERRQ(ierr); ierr = DMSetType(dm, DMPLEX);CHKERRQ(ierr); ierr = DMLoad(dm, vwr);CHKERRQ(ierr); ierr = PetscViewerDestroy(&vwr);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)dm, "BaryDM");CHKERRQ(ierr); ierr = DMViewFromOptions(dm, NULL, "-dm_view");CHKERRQ(ierr); ierr = DMPlexSetRefinementUniform(dm, PETSC_TRUE);CHKERRQ(ierr); ierr = DMRefine(dm, comm, &rdm);CHKERRQ(ierr); ierr = DMDestroy(&dm);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)rdm, "RefinedDM");CHKERRQ(ierr); ierr = DMViewFromOptions(rdm, NULL, "-refined_dm_view");CHKERRQ(ierr); ierr = DMDestroy(&rdm);CHKERRQ(ierr); ierr = PetscFinalize(); return ierr; }
PetscErrorCode private_PetscViewerCreate_XDMF(MPI_Comm comm,const char filename[],PetscViewer *v) { long int *bytes; PetscContainer container; PetscViewer viewer; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,&viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(viewer,PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer,FILE_MODE_WRITE);CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer,filename);CHKERRQ(ierr); ierr = PetscMalloc1(1,&bytes);CHKERRQ(ierr); bytes[0] = 0; ierr = PetscContainerCreate(comm,&container);CHKERRQ(ierr); ierr = PetscContainerSetPointer(container,(void*)bytes);CHKERRQ(ierr); ierr = PetscObjectCompose((PetscObject)viewer,"XDMFViewerContext",(PetscObject)container);CHKERRQ(ierr); /* write xdmf header */ ierr = PetscViewerASCIIPrintf(viewer,"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"<Xdmf xmlns:xi=\"http://www.w3.org/2001/XInclude\" Version=\"2.99\">\n");CHKERRQ(ierr); /* write xdmf domain */ ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"<Domain>\n");CHKERRQ(ierr); *v = viewer; PetscFunctionReturn(0); }
// Write the sub mesh into a HDF5 file. PetscErrorCode ProbeVolume::writeSubMeshHDF5(const std::string &filePath) { PetscErrorCode ierr; PetscFunctionBeginUser; // only the first process in the communicator write the sub-mesh into a file if (commRank == 0) { // because only one process is involved in writing the sub-mesh, // we need to create a temporary viewer PetscViewer viewer2; ierr = PetscViewerCreate(PETSC_COMM_SELF, &viewer2); CHKERRQ(ierr); ierr = PetscViewerSetType(viewer2, PETSCVIEWERHDF5); CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer2, FILE_MODE_WRITE); CHKERRQ(ierr); ierr = PetscViewerFileSetName( viewer2, filePath.c_str()); CHKERRQ(ierr); ierr = PetscViewerHDF5PushGroup(viewer2, "mesh"); CHKERRQ(ierr); std::vector<std::string> dirs{"x", "y", "z"}; for (unsigned int d = 0; d < coord.size(); ++d) { Vec tmp; ierr = VecCreateSeqWithArray(PETSC_COMM_SELF, 1, nPtsDir[d], &coord[d][0], &tmp); CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject) tmp, dirs[d].c_str()); CHKERRQ(ierr); ierr = VecView(tmp, viewer2); CHKERRQ(ierr); ierr = VecDestroy(&tmp); CHKERRQ(ierr); } ierr = PetscViewerDestroy(&viewer2); CHKERRQ(ierr); } PetscFunctionReturn(0); } // ProbeVolume::writeSubMeshHDF5
/*@C PetscViewerSAWsOpen - Opens an SAWs PetscViewer. Collective on MPI_Comm Input Parameters: . comm - the MPI communicator Output Parameter: . lab - the PetscViewer Options Database Keys: + -saws_port <port number> - port number where you are running SAWs client . -xxx_view saws - publish the object xxx - -xxx_saws_block - blocks the program at the end of a critical point (for KSP and SNES it is the end of a solve) until the user unblocks the problem with an external tool that access the object with SAWS Level: advanced Fortran Note: This routine is not supported in Fortran. Notes: Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the SAWs viewer allows one to view the object asynchronously as the program continues to run. One can remove SAWs access to the object with a call to PetscObjectSAWsViewOff(). Information about the SAWs is available via http://bitbucket.org/saws/saws .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PETSC_VIEWER_SAWS_(), PetscObjectSAWsBlock(), PetscObjectSAWsViewOff(), PetscObjectSAWsTakeAccess(), PetscObjectSAWsGrantAccess() @*/ PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm,PetscViewer *lab) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,lab);CHKERRQ(ierr); ierr = PetscViewerSetType(*lab,PETSCVIEWERSAWS);CHKERRQ(ierr); PetscFunctionReturn(0); }
// Initialize the probe. PetscErrorCode ProbeVolume::init(const MPI_Comm &comm, const YAML::Node &node, const type::Mesh &mesh) { PetscErrorCode ierr; PetscFunctionBeginUser; ierr = ProbeBase::init(comm, node, mesh); CHKERRQ(ierr); // store information about the type of PETSc Viewer object to use std::string vtype_str = node["viewer"].as<std::string>("ascii"); if (vtype_str == "ascii") viewerType = PETSCVIEWERASCII; else if (vtype_str == "hdf5") viewerType = PETSCVIEWERHDF5; // tolerance to define if a point belong to the sub-volume atol = node["atol"].as<PetscReal>(1e-6); // number of the time-steps over which we accumulate the data // data are added together and we write the time averaged data n_sum = node["n_sum"].as<PetscInt>(0); is = PETSC_NULL; dvec = PETSC_NULL; // store information about the sub-volume to monitor box = type::RealVec2D(3, type::RealVec1D(2, 0.0)); for (auto item : node["box"]) { type::Dir dir = type::str2dir[item.first.as<std::string>()]; box[dir][0] = item.second[0].as<PetscReal>(); box[dir][1] = item.second[1].as<PetscReal>(); } nPtsDir.resize(3, 1); startIdxDir.resize(3, 0); // get information about the location of the sub-mesh ierr = getSubMeshInfo(mesh, box); CHKERRQ(ierr); // create gridline coordinates for the sub-mesh ierr = createSubMesh(mesh); CHKERRQ(ierr); // write the sub-mesh to file ierr = writeSubMesh(path); CHKERRQ(ierr); // create a PETSc Index Set object to easily grab a sub-vector ierr = createIS(mesh); CHKERRQ(ierr); // create a PETSc Viewer to output the data ierr = PetscViewerCreate(comm, &viewer); CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, viewerType); CHKERRQ(ierr); // Note: we set the "append" mode as the output file already exists // (it was created when the sub-mesh was written into it) ierr = PetscViewerFileSetMode(viewer, FILE_MODE_APPEND); CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, path.c_str()); CHKERRQ(ierr); PetscFunctionReturn(0); } // ProbeVolume::init
/*@C PetscViewerSocketOpen - Opens a connection to a Matlab or other socket based server. Collective on MPI_Comm Input Parameters: + comm - the MPI communicator . machine - the machine the server is running on,, use PETSC_NULL for the local machine, use "server" to passively wait for a connection from elsewhere - port - the port to connect to, use PETSC_DEFAULT for the default Output Parameter: . lab - a context to use when communicating with the server Level: intermediate Notes: Most users should employ the following commands to access the Matlab PetscViewers $ $ PetscViewerSocketOpen(MPI_Comm comm, char *machine,int port,PetscViewer &viewer) $ MatView(Mat matrix,PetscViewer viewer) $ $ or $ $ PetscViewerSocketOpen(MPI_Comm comm,char *machine,int port,PetscViewer &viewer) $ VecView(Vec vector,PetscViewer viewer) Options Database Keys: For use with PETSC_VIEWER_SOCKET_WORLD, PETSC_VIEWER_SOCKET_SELF, PETSC_VIEWER_SOCKET_() or if PETSC_NULL is passed for machine or PETSC_DEFAULT is passed for port $ -viewer_socket_machine <machine> $ -viewer_socket_port <port> Environmental variables: + PETSC_VIEWER_SOCKET_PORT portnumber - PETSC_VIEWER_SOCKET_MACHINE machine name Currently the only socket client available is Matlab. See src/dm/da/examples/tests/ex12.c and ex12.m for an example of usage. Notes: The socket viewer is in some sense a subclass of the binary viewer, to read and write to the socket use PetscViewerBinaryRead/Write/GetDescriptor(). Concepts: Matlab^sending data Concepts: sockets^sending data .seealso: MatView(), VecView(), PetscViewerDestroy(), PetscViewerCreate(), PetscViewerSetType(), PetscViewerSocketSetConnection(), PETSC_VIEWER_SOCKET_, PETSC_VIEWER_SOCKET_WORLD, PETSC_VIEWER_SOCKET_SELF, PetscViewerBinaryWrite(), PetscViewerBinaryRead(), PetscViewerBinaryWriteStringArray(), PetscBinaryViewerGetDescriptor() @*/ PetscErrorCode PETSC_DLLEXPORT PetscViewerSocketOpen(MPI_Comm comm,const char machine[],int port,PetscViewer *lab) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,lab);CHKERRQ(ierr); ierr = PetscViewerSetType(*lab,PETSC_VIEWER_SOCKET);CHKERRQ(ierr); ierr = PetscViewerSocketSetConnection(*lab,machine,port);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerDrawOpen - Opens a window for use as a PetscViewer. If you want to do graphics in this window, you must call PetscViewerDrawGetDraw() and perform the graphics on the PetscDraw object. Collective on MPI_Comm Input Parameters: + comm - communicator that will share window . display - the X display on which to open, or null for the local machine . title - the title to put in the title bar, or null for no title . x, y - the screen coordinates of the upper left corner of window, or use PETSC_DECIDE - w, h - window width and height in pixels, or may use PETSC_DECIDE or PETSC_DRAW_FULL_SIZE, PETSC_DRAW_HALF_SIZE, PETSC_DRAW_THIRD_SIZE, PETSC_DRAW_QUARTER_SIZE Output Parameters: . viewer - the PetscViewer Format Options: + PETSC_VIEWER_DRAW_BASIC - displays with basic format - PETSC_VIEWER_DRAW_LG - displays using a line graph Options Database Keys: PetscViewerDrawOpen() calls PetscDrawCreate(), so see the manual page for PetscDrawCreate() for runtime options, including + -draw_type x or null . -nox - Disables all x-windows output . -display <name> - Specifies name of machine for the X display . -geometry <x,y,w,h> - allows setting the window location and size - -draw_pause <pause> - Sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input). Level: beginner Note for Fortran Programmers: Whenever indicating null character data in a Fortran code, NULL_CHARACTER must be employed; using NULL is not correct for character data! Thus, NULL_CHARACTER can be used for the display and title input parameters. Concepts: graphics^opening PetscViewer Concepts: drawing^opening PetscViewer .seealso: PetscDrawCreate(), PetscViewerDestroy(), PetscViewerDrawGetDraw(), PetscViewerCreate(), PETSC_VIEWER_DRAW_, PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF @*/ PetscErrorCode PetscViewerDrawOpen(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscViewer *viewer) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*viewer,PETSCVIEWERDRAW);CHKERRQ(ierr); ierr = PetscViewerDrawSetInfo(*viewer,display,title,x,y,w,h);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode OutputVTK(DM dm, const char *filename, PetscViewer *viewer) { PetscErrorCode ierr; PetscFunctionBeginUser; ierr = PetscViewerCreate(PetscObjectComm((PetscObject)dm), viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*viewer, PETSCVIEWERVTK);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*viewer, filename);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerStringOpen - Opens a string as a PetscViewer. This is a very simple PetscViewer; information on the object is simply stored into the string in a fairly nice way. Collective on MPI_Comm Input Parameters: + comm - the communicator . string - the string to use - len - the string length Output Parameter: . lab - the PetscViewer Level: advanced Fortran Note: This routine is not supported in Fortran. Concepts: PetscViewerString^creating .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PetscViewerStringGetStringRead(), PetscViewerStringSetString(), PETSCVIEWERSTRING @*/ PetscErrorCode PetscViewerStringOpen(MPI_Comm comm,char string[],size_t len,PetscViewer *lab) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,lab);CHKERRQ(ierr); ierr = PetscViewerSetType(*lab,PETSCVIEWERSTRING);CHKERRQ(ierr); ierr = PetscViewerStringSetString(*lab,string,len);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerASCIIOpenWithFILE - Given an open file creates an ASCII viewer that prints to it. Collective on MPI_Comm Input Parameters: + comm - the communicator - fd - the FILE pointer Output Parameter: . lab - the PetscViewer to use with the specified file Level: beginner Notes: This PetscViewer can be destroyed with PetscViewerDestroy(), but the fd will NOT be closed. If a multiprocessor communicator is used (such as PETSC_COMM_WORLD), then only the first processor in the group uses the file. All other processors send their data to the first processor to print. Concepts: PetscViewerASCII^creating Concepts: printf Concepts: printing Concepts: accessing remote file Concepts: remote file .seealso: MatView(), VecView(), PetscViewerDestroy(), PetscViewerBinaryOpen(), PetscViewerASCIIGetPointer(), PetscViewerPushFormat(), PETSC_VIEWER_STDOUT_, PETSC_VIEWER_STDERR_, PETSC_VIEWER_STDOUT_WORLD, PETSC_VIEWER_STDOUT_SELF, PetscViewerASCIIOpen() @*/ PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm comm,FILE *fd,PetscViewer *lab) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,lab);CHKERRQ(ierr); ierr = PetscViewerSetType(*lab,PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerASCIISetFILE(*lab,fd);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerHDF5Open - Opens a file for HDF5 input/output. Collective on MPI_Comm Input Parameters: + comm - MPI communicator . name - name of file - type - type of file $ FILE_MODE_WRITE - create new file for binary output $ FILE_MODE_READ - open existing file for binary input $ FILE_MODE_APPEND - open existing file for binary output Output Parameter: . hdf5v - PetscViewer for HDF5 input/output to use with the specified file Level: beginner Note: This PetscViewer should be destroyed with PetscViewerDestroy(). Concepts: HDF5 files Concepts: PetscViewerHDF5^creating .seealso: PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(), VecView(), MatView(), VecLoad(), MatLoad(), PetscFileMode, PetscViewer @*/ PetscErrorCode PetscViewerHDF5Open(MPI_Comm comm, const char name[], PetscFileMode type, PetscViewer *hdf5v) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm, hdf5v);CHKERRQ(ierr); ierr = PetscViewerSetType(*hdf5v, PETSCVIEWERHDF5);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(*hdf5v, type);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*hdf5v, name);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode OutputBIN(const char *filename, PetscViewer *viewer) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(PETSC_COMM_WORLD, viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*viewer, PETSCVIEWERBINARY);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(*viewer,FILE_MODE_WRITE);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*viewer, filename);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerBinaryOpen - Opens a file for binary input/output. Collective on MPI_Comm Input Parameters: + comm - MPI communicator . name - name of file - type - type of file $ FILE_MODE_WRITE - create new file for binary output $ FILE_MODE_READ - open existing file for binary input $ FILE_MODE_APPEND - open existing file for binary output Output Parameter: . binv - PetscViewer for binary input/output to use with the specified file Options Database Keys: + -viewer_binary_skip_info . -viewer_binary_skip_options - -viewer_binary_skip_header Level: beginner Note: This PetscViewer should be destroyed with PetscViewerDestroy(). For reading files, the filename may begin with ftp:// or http:// and/or end with .gz; in this case file is brought over and uncompressed. For creating files, if the file name ends with .gz it is automatically compressed when closed. For writing files it only opens the file on processor 0 in the communicator. For readable files it opens the file on all nodes that have the file. If node 0 does not have the file it generates an error even if other nodes do have the file. Concepts: binary files Concepts: PetscViewerBinary^creating Concepts: gzip Concepts: accessing remote file Concepts: remote file .seealso: PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(), VecView(), MatView(), VecLoad(), MatLoad(), PetscViewerBinaryGetDescriptor(), PetscViewerBinaryGetInfoPointer(), PetscFileMode, PetscViewer, PetscViewerBinaryRead() @*/ PetscErrorCode PetscViewerBinaryOpen(MPI_Comm comm,const char name[],PetscFileMode type,PetscViewer *binv) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,binv);CHKERRQ(ierr); ierr = PetscViewerSetType(*binv,PETSCVIEWERBINARY);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(*binv,type);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*binv,name);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerVTKOpen - Opens a file for VTK output. Collective on MPI_Comm Input Parameters: + comm - MPI communicator . name - name of file - type - type of file $ FILE_MODE_WRITE - create new file for binary output $ FILE_MODE_READ - open existing file for binary input (not currently supported) $ FILE_MODE_APPEND - open existing file for binary output (not currently supported) Output Parameter: . vtk - PetscViewer for VTK input/output to use with the specified file Level: beginner Note: This PetscViewer should be destroyed with PetscViewerDestroy(). Concepts: VTK files Concepts: PetscViewer^creating .seealso: PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(), VecView(), MatView(), VecLoad(), MatLoad(), PetscFileMode, PetscViewer @*/ PetscErrorCode PetscViewerVTKOpen(MPI_Comm comm,const char name[],PetscFileMode type,PetscViewer *vtk) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,vtk);CHKERRQ(ierr); ierr = PetscViewerSetType(*vtk,PETSCVIEWERVTK);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(*vtk,type);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*vtk,name);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C DMPlexCreateFluentFromFile - Create a DMPlex mesh from a Fluent mesh file + comm - The MPI communicator . filename - Name of the Fluent mesh file - interpolate - Create faces and edges in the mesh Output Parameter: . dm - The DM object representing the mesh Level: beginner .seealso: DMPlexCreateFromFile(), DMPlexCreateFluent(), DMPlexCreate() @*/ PetscErrorCode DMPlexCreateFluentFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm) { PetscViewer viewer; PetscErrorCode ierr; PetscFunctionBegin; /* Create file viewer and build plex */ ierr = PetscViewerCreate(comm, &viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ);CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, filename);CHKERRQ(ierr); ierr = DMPlexCreateFluent(comm, viewer, interpolate, dm);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerMathematicaOpen - Communicates with Mathemtica using MathLink. Collective on comm Input Parameters: + comm - The MPI communicator . port - [optional] The port to connect on, or PETSC_DECIDE . machine - [optional] The machine to run Mathematica on, or NULL - mode - [optional] The connection mode, or NULL Output Parameter: . viewer - The Mathematica viewer Level: intermediate Notes: Most users should employ the following commands to access the Mathematica viewers $ $ PetscViewerMathematicaOpen(MPI_Comm comm, int port, char *machine, char *mode, PetscViewer &viewer) $ MatView(Mat matrix, PetscViewer viewer) $ $ or $ $ PetscViewerMathematicaOpen(MPI_Comm comm, int port, char *machine, char *mode, PetscViewer &viewer) $ VecView(Vec vector, PetscViewer viewer) Options Database Keys: + -viewer_math_linkhost <machine> - The host machine for the kernel . -viewer_math_linkname <name> - The full link name for the connection . -viewer_math_linkport <port> - The port for the connection . -viewer_math_mode <mode> - The mode, e.g. Launch, Connect . -viewer_math_type <type> - The plot type, e.g. Triangulation, Vector - -viewer_math_graphics <output> - The output type, e.g. Motif, PS, PSFile .keywords: PetscViewer, Mathematica, open .seealso: MatView(), VecView() @*/ PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm comm, int port, const char machine[], const char mode[], PetscViewer *v) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm, v);CHKERRQ(ierr); #if 0 LinkMode linkmode; ierr = PetscViewerMathematicaSetLinkPort(*v, port);CHKERRQ(ierr); ierr = PetscViewerMathematicaSetLinkHost(*v, machine);CHKERRQ(ierr); ierr = PetscViewerMathematicaParseLinkMode(mode, &linkmode);CHKERRQ(ierr); ierr = PetscViewerMathematicaSetLinkMode(*v, linkmode);CHKERRQ(ierr); #endif ierr = PetscViewerSetType(*v, PETSC_VIEWER_MATHEMATICA);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode PetscViewerGetSingleton_Binary(PetscViewer viewer,PetscViewer *outviewer) { int rank; PetscErrorCode ierr; PetscViewer_Binary *vbinary = (PetscViewer_Binary*)viewer->data,*obinary; PetscFunctionBegin; ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr); if (!rank) { ierr = PetscViewerCreate(PETSC_COMM_SELF,outviewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*outviewer,PETSCVIEWERBINARY);CHKERRQ(ierr); obinary = (PetscViewer_Binary*)(*outviewer)->data; ierr = PetscMemcpy(obinary,vbinary,sizeof(PetscViewer_Binary));CHKERRQ(ierr); } else *outviewer = 0; PetscFunctionReturn(0); }
int main(int argc,char **args) { PetscViewer viewer; PetscInt i; PetscErrorCode ierr; ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr; ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(viewer, FILE_MODE_APPEND);CHKERRQ(ierr); ierr = PetscViewerFileSetName(viewer, "test.txt");CHKERRQ(ierr); for (i = 0; i < 10; ++i) { ierr = PetscViewerASCIIPrintf(viewer, "test line %d\n", i);CHKERRQ(ierr); } ierr = PetscFinalize(); return ierr; }
PetscErrorCode TSTrajectorySet_Singlefile(TSTrajectory jac,TS ts,PetscInt stepnum,PetscReal time,Vec X) { TSTrajectory_Singlefile *sf = (TSTrajectory_Singlefile*)jac->data; PetscErrorCode ierr; const char *filename; PetscFunctionBeginUser; if (stepnum == 0) { ierr = PetscViewerCreate(PETSC_COMM_WORLD, &sf->viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(sf->viewer, PETSCVIEWERBINARY);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(sf->viewer,FILE_MODE_WRITE);CHKERRQ(ierr); ierr = PetscObjectGetName((PetscObject)jac,&filename);CHKERRQ(ierr); ierr = PetscViewerFileSetName(sf->viewer, filename);CHKERRQ(ierr); } ierr = VecView(X,sf->viewer);CHKERRQ(ierr); ierr = PetscViewerBinaryWrite(sf->viewer,&time,1,PETSC_REAL,PETSC_FALSE);CHKERRQ(ierr); PetscFunctionReturn(0); }
EXTERN_C_END #undef __FUNCT__ #define __FUNCT__ "PetscViewerVTKOpen" /*@C PetscViewerVTKOpen - Opens a file for VTK output. Collective on MPI_Comm Input Parameters: + comm - MPI communicator . name - name of file - type - type of file $ FILE_MODE_WRITE - create new file for binary output $ FILE_MODE_READ - open existing file for binary input (not currently supported) $ FILE_MODE_APPEND - open existing file for binary output (not currently supported) Output Parameter: . vtk - PetscViewer for VTK input/output to use with the specified file Level: beginner Note: This PetscViewer should be destroyed with PetscViewerDestroy(). Concepts: VTK files Concepts: PetscViewer^creating .seealso: PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(), VecView(), MatView(), VecLoad(), MatLoad(), PetscFileMode, PetscViewer @*/ PetscErrorCode PetscViewerVTKOpen(MPI_Comm comm,const char name[],PetscFileMode type,PetscViewer *vtk) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,vtk);CHKERRQ(ierr); ierr = PetscViewerSetType(*vtk,PETSCVIEWERVTK);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(*vtk,type);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*vtk,name);CHKERRQ(ierr); PetscFunctionReturn(0); }
EXTERN_C_END #undef __FUNCT__ #define __FUNCT__ "PetscViewerHDF5Open" /*@C PetscViewerHDF5Open - Opens a file for HDF5 input/output. Collective on MPI_Comm Input Parameters: + comm - MPI communicator . name - name of file - type - type of file $ FILE_MODE_WRITE - create new file for binary output $ FILE_MODE_READ - open existing file for binary input $ FILE_MODE_APPEND - open existing file for binary output Output Parameter: . hdf5v - PetscViewer for HDF5 input/output to use with the specified file Level: beginner Note: This PetscViewer should be destroyed with PetscViewerDestroy(). Concepts: HDF5 files Concepts: PetscViewerHDF5^creating .seealso: PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(), VecView(), MatView(), VecLoad(), MatLoad(), PetscFileMode, PetscViewer @*/ PetscErrorCode PETSC_DLLEXPORT PetscViewerHDF5Open(MPI_Comm comm, const char name[], PetscFileMode type, PetscViewer *hdf5v) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm, hdf5v);CHKERRQ(ierr); ierr = PetscViewerSetType(*hdf5v, PETSC_VIEWER_HDF5);CHKERRQ(ierr); ierr = PetscViewerFileSetMode(*hdf5v, type);CHKERRQ(ierr); ierr = PetscViewerFileSetName(*hdf5v, name);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C KSPGMRESMonitorKrylov - Calls VecView() for each direction in the GMRES accumulated Krylov space. Collective on KSP Input Parameters: + ksp - the KSP context . its - iteration number . fgnorm - 2-norm of residual (or gradient) - a viewers object created with PetscViewersCreate() Level: intermediate .keywords: KSP, nonlinear, vector, monitor, view, Krylov space .seealso: KSPMonitorSet(), KSPMonitorDefault(), VecView(), PetscViewersCreate(), PetscViewersDestroy() @*/ PetscErrorCode KSPGMRESMonitorKrylov(KSP ksp,PetscInt its,PetscReal fgnorm,void *dummy) { PetscViewers viewers = (PetscViewers)dummy; KSP_GMRES *gmres = (KSP_GMRES*)ksp->data; PetscErrorCode ierr; Vec x; PetscViewer viewer; PetscBool flg; PetscFunctionBegin; ierr = PetscViewersGetViewer(viewers,gmres->it+1,&viewer);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&flg);CHKERRQ(ierr); if (!flg) { ierr = PetscViewerSetType(viewer,PETSCVIEWERDRAW);CHKERRQ(ierr); ierr = PetscViewerDrawSetInfo(viewer,NULL,"Krylov GMRES Monitor",PETSC_DECIDE,PETSC_DECIDE,300,300);CHKERRQ(ierr); } x = VEC_VV(gmres->it+1); ierr = VecView(x,viewer);CHKERRQ(ierr); PetscFunctionReturn(0); }