From 415a98bd55e25b8459f602e43bcafdf6cb8a1689 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 2 Jan 2013 16:54:31 +0000 Subject: [PATCH] Patch by Fahad Alrashed: Add PETScWrappers::VectorBase::write_ascii. git-svn-id: https://svn.dealii.org/trunk@27896 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 ++++++ .../include/deal.II/lac/petsc_vector_base.h | 14 +++++++++++++- deal.II/source/lac/petsc_vector_base.cc | 18 +++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 6ef974f946..486e97a696 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -127,6 +127,12 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. New: The PETScWrappers::VectorBase class now has a function +PETScWrappers::VectorBase::write_ascii() that allows writing the +vector's data to the default output stream. +
    +(Fahad Alrashed, 2013/1/2) +
  2. Fixed: PETScWrappers::SparseDirectMUMPS forgot to release its memory upon destruction. This is now fixed.
    diff --git a/deal.II/include/deal.II/lac/petsc_vector_base.h b/deal.II/include/deal.II/lac/petsc_vector_base.h index eb265a8648..29391b7705 100644 --- a/deal.II/include/deal.II/lac/petsc_vector_base.h +++ b/deal.II/include/deal.II/lac/petsc_vector_base.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -734,6 +734,18 @@ namespace PETScWrappers */ void update_ghost_values() const; + + /** + * Prints the PETSc vector object values + * using PETSc internal vector viewer function + * VecView. The default format prints + * the vector's contents, including indices of + * vector elements. For other valid view formats, + * consult + * http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecView.html + */ + void write_ascii (const PetscViewerFormat format = PETSC_VIEWER_DEFAULT) ; + /** * Print to a * stream. @p precision denotes diff --git a/deal.II/source/lac/petsc_vector_base.cc b/deal.II/source/lac/petsc_vector_base.cc index 4b80d74837..2decd9a763 100644 --- a/deal.II/source/lac/petsc_vector_base.cc +++ b/deal.II/source/lac/petsc_vector_base.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -983,6 +983,22 @@ namespace PETScWrappers + void + VectorBase::write_ascii (const PetscViewerFormat format) + { + // First flush PETSc caches + compress(); + + // Set options + PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD, + format); + + // Write to screen + VecView (vector, PETSC_VIEWER_STDOUT_WORLD); + } + + + void VectorBase::print (std::ostream &out, const unsigned int precision, -- 2.39.5