]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Generate output in tables, rather than by hand.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Sep 2001 13:23:26 +0000 (13:23 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Sep 2001 13:23:26 +0000 (13:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@5011 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-11/step-11.cc

index fdbe64cd7838a4bb11477bcf3824c9b6cc4b6cee..7d734fe575e9ca9588a4c123b31360780a04b972 100644 (file)
@@ -8,6 +8,7 @@
 #include <base/quadrature_lib.h>
 #include <base/function.h>
 #include <base/logstream.h>
+#include <base/table_handler.h>
 #include <lac/vector.h>
 #include <lac/sparse_matrix.h>
 #include <lac/solver_cg.h>
@@ -41,7 +42,7 @@
                                 // following file for its
                                 // declaration:
 #include <algorithm>
-
+#include <iomanip>
 
 
                                 // Then we declare a class which
@@ -93,6 +94,8 @@ class LaplaceProblem
 
     Vector<double>       solution;
     Vector<double>       system_rhs;
+
+    TableHandler         output_table;
 };
 
 
@@ -555,13 +558,10 @@ void LaplaceProblem<dim>::assemble_and_solve ()
                                   // vector:
   const double norm = norm_per_cell.l2_norm();
 
-                                  // Last task -- show output:
-  std::cout << "  " << triangulation.n_active_cells() << " cells:  "
-           << "  |u|_1="
-           << norm
-           << ", error="
-           << fabs(norm-sqrt(3.14159265358/2))
-           << std::endl;
+                                  // Last task -- generate output:
+  output_table.add_value ("cells", triangulation.n_active_cells());
+  output_table.add_value ("|u|_1", norm);
+  output_table.add_value ("error", fabs(norm-sqrt(3.14159265358/2)));
 };
 
 
@@ -626,6 +626,14 @@ void LaplaceProblem<dim>::run ()
       setup_system ();
       assemble_and_solve ();
     };
+
+                                  // After all the data is generated,
+                                  // write a table of results to the
+                                  // screen:
+  output_table.set_precision("|u|_1", 6);
+  output_table.set_scientific("error", true);
+  output_table.write_text (std::cout);
+  std::cout << std::endl;
 };
 
     

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.