]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Test print a complex vector.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 19 Oct 2013 19:08:07 +0000 (19:08 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 19 Oct 2013 19:08:07 +0000 (19:08 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31322 0785d39b-7218-0410-832d-ea1e28bc413d

tests/petsc_scalar_complex/vector_print.cc [new file with mode: 0644]
tests/petsc_scalar_complex/vector_print/cmp/+ [new file with mode: 0644]
tests/petsc_scalar_complex/vector_print/cmp/generic [new file with mode: 0644]

diff --git a/tests/petsc_scalar_complex/vector_print.cc b/tests/petsc_scalar_complex/vector_print.cc
new file mode 100644 (file)
index 0000000..a2d793b
--- /dev/null
@@ -0,0 +1,77 @@
+// ---------------------------------------------------------------------
+// $Id: vector_print.cc 
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// verify that VectorBase::print uses the precision parameter correctly and
+// restores the previous value of the stream precision
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("vector_print/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (5);
+        for (unsigned int k=0; k<v.size(); ++k)
+          v(k) = PetscScalar (k*1.2345678901234567,2.*k*1.2345678901234567);
+
+        // print with prescribed precision
+        deallog << "unreadable=true,across=false" << std::endl;
+        v.print (logfile, 10, true, false);
+
+        deallog << "unreadable=false,across=true" << std::endl;
+        v.print (logfile, 3, false, true);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_scalar_complex/vector_print/cmp/+ b/tests/petsc_scalar_complex/vector_print/cmp/+
new file mode 100644 (file)
index 0000000..a2b6107
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::unreadable=true,across=false
+(0.0000000000e+00,0.0000000000e+00)
+(1.2345678901e+00,2.4691357802e+00)
+(2.4691357802e+00,4.9382715605e+00)
+(3.7037036704e+00,7.4074073407e+00)
+(4.9382715605e+00,9.8765431210e+00)
+
+DEAL::unreadable=false,across=true
+(0.000,0.000) (1.235,2.469) (2.469,4.938) (3.704,7.407) (4.938,9.877) 
diff --git a/tests/petsc_scalar_complex/vector_print/cmp/generic b/tests/petsc_scalar_complex/vector_print/cmp/generic
new file mode 100644 (file)
index 0000000..cdcb15a
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::across=false
+(0.0000000000e+00,0.0000000000e+00)
+(1.2345678901e+00,2.4691357802e+00)
+(2.4691357802e+00,4.9382715605e+00)
+(3.7037036704e+00,7.4074073407e+00)
+(4.9382715605e+00,9.8765431210e+00)
+
+DEAL::across=true
+(0.000,0.000) (1.235,2.469) (2.469,4.938) (3.704,7.407) (4.938,9.877) 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.