void PetscMatrix<T>::print_matlab (const std::string name) const { libmesh_assert (this->initialized()); semiparallel_only(); // libmesh_assert (this->closed()); this->close(); PetscErrorCode ierr=0; PetscViewer petsc_viewer; ierr = PetscViewerCreate (this->comm().get(), &petsc_viewer); LIBMESH_CHKERRABORT(ierr); /** * Create an ASCII file containing the matrix * if a filename was provided. */ if (name != "NULL") { ierr = PetscViewerASCIIOpen( this->comm().get(), name.c_str(), &petsc_viewer); LIBMESH_CHKERRABORT(ierr); ierr = PetscViewerSetFormat (petsc_viewer, PETSC_VIEWER_ASCII_MATLAB); LIBMESH_CHKERRABORT(ierr); ierr = MatView (_mat, petsc_viewer); LIBMESH_CHKERRABORT(ierr); } /** * Otherwise the matrix will be dumped to the screen. */ else { ierr = PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD, PETSC_VIEWER_ASCII_MATLAB); LIBMESH_CHKERRABORT(ierr); ierr = MatView (_mat, PETSC_VIEWER_STDOUT_WORLD); LIBMESH_CHKERRABORT(ierr); } /** * Destroy the viewer. */ ierr = LibMeshPetscViewerDestroy (&petsc_viewer); LIBMESH_CHKERRABORT(ierr); }
void PetscVector<T>::print_matlab (const std::string name) const { this->_restore_array(); libmesh_assert (this->closed()); PetscErrorCode ierr=0; PetscViewer petsc_viewer; ierr = PetscViewerCreate (libMesh::COMM_WORLD, &petsc_viewer); CHKERRABORT(libMesh::COMM_WORLD,ierr); /** * Create an ASCII file containing the matrix * if a filename was provided. */ if (name != "NULL") { ierr = PetscViewerASCIIOpen( libMesh::COMM_WORLD, name.c_str(), &petsc_viewer); CHKERRABORT(libMesh::COMM_WORLD,ierr); ierr = PetscViewerSetFormat (petsc_viewer, PETSC_VIEWER_ASCII_MATLAB); CHKERRABORT(libMesh::COMM_WORLD,ierr); ierr = VecView (_vec, petsc_viewer); CHKERRABORT(libMesh::COMM_WORLD,ierr); } /** * Otherwise the matrix will be dumped to the screen. */ else { ierr = PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD, PETSC_VIEWER_ASCII_MATLAB); CHKERRABORT(libMesh::COMM_WORLD,ierr); ierr = VecView (_vec, PETSC_VIEWER_STDOUT_WORLD); CHKERRABORT(libMesh::COMM_WORLD,ierr); } /** * Destroy the viewer. */ ierr = LibMeshPetscViewerDestroy (&petsc_viewer); CHKERRABORT(libMesh::COMM_WORLD,ierr); }