*/
none,
/**
- * Quotient of values in
- * the previous row and in
- * this row.
+ * Quotient of values in the previous row and in this row.
*/
reduction_rate,
/**
- * Logarithm of
- * #reduction_rate to the
- * base 2 representing the
- * order of convergence
- * when halving the grid
- * size, e.g. from h to
- * h/2.
+ * Logarithm of #reduction_rate to the base 2 representing the order of
+ * convergence when halving the grid size, e.g. from h to h/2.
*/
reduction_rate_log2
};
/**
- * Evaluates the convergence rates of the
- * data column <tt>data_column_key</tt>
- * due to the #RateMode in relation to
- * the reference column <tt>reference_column_key</tt>.
- * Be sure that the value types of the
- * table entries of the
- * data column and the reference data column
- * is a number, i.e. double, float,
- * (unsigned) int, and so on.
+ * Evaluates the convergence rates of the data column
+ * <tt>data_column_key</tt> due to the #RateMode in relation to the
+ * reference column <tt>reference_column_key</tt>. Be sure that the value
+ * types of the table entries of the data column and the reference data
+ * column is a number, i.e. double, float, (unsigned) int, and so on.
*
- * The new rate column and the data column
- * will be merged to a supercolumn. The
- * tex caption of the supercolumn will be
- * (by default) the same as the one of the
- * data column. This may be changed by using
- * the <tt>set_tex_supercaption (...)</tt> function
- * of the base class TableHandler.
+ * As this class has no information on the space dimension upon which the
+ * reference column vs. the value column is based upon, it needs to be
+ * passed as last argument to this method. The default dimension is two.
+ *
+ * The new rate column and the data column will be merged to a
+ * supercolumn. The tex caption of the supercolumn will be (by default) the
+ * same as the one of the data column. This may be changed by using the
+ * <tt>set_tex_supercaption (...)</tt> function of the base class
+ * TableHandler.
*
* This method behaves in the following way:
*
- * If RateMode is reduction_rate, then the computed
- * output is
+ * If RateMode is reduction_rate, then the computed output is
* $ \frac{e_{n-1}/k_{n-1}}{e_n/k_n} $.
*
* Where $k$ is the reference column.
*
- * If RateMode is reduction_rate_log2, then the
- * computed output is
+ * If RateMode is reduction_rate_log2, then the computed output is
* $
- * 2\frac{\log |e_{n-1}/e_{n}|}{\log |k_n/k_{n-1}|}
+ * dim \frac{\log |e_{n-1}/e_{n}|}{\log |k_n/k_{n-1}|}
* $.
*
- * This is useful, for example, if we use as
- * reference key the number of degrees of freedom.
- * Assuming that the error is proportional to
- * $ C (1/\sqrt{k})^r $, then this method will
- * produce the rate $r$ as a result.
+ * This is useful, for example, if we use as reference key the number of
+ * degrees of freedom. Assuming that the error is proportional to $ C
+ * (1/\sqrt{k})^r $, then this method will produce the rate $r$ as a result.
*
- * @note Since this function adds columns
- * to the table after several rows have
- * already been filled, it switches off
- * the auto fill mode of the TableHandler
- * base class. If you intend to add
- * further data with auto fill, you will
- * have to re-enable it after calling
- * this function.
+ * @note Since this function adds columns to the table after several rows
+ * have already been filled, it switches off the auto fill mode of the
+ * TableHandler base class. If you intend to add further data with auto
+ * fill, you will have to re-enable it after calling this function.
*/
void
evaluate_convergence_rates (const std::string &data_column_key,
const std::string &reference_column_key,
- const RateMode rate_mode);
+ const RateMode rate_mode,
+ const unsigned int dim = 2);
/**
--- /dev/null
+//-----------------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2010 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//-----------------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/base/data_out_base.h>
+#include <deal.II/base/table_handler.h>
+#include <deal.II/base/convergence_table.h>
+#include <deal.II/base/logstream.h>
+
+#include <vector>
+#include <iomanip>
+#include <fstream>
+#include <string>
+
+// test the method evaluate_convergence_rates with argument
+// reference_column_key and data from various dimension where the reference
+// data must be scaled by dimension
+
+int main ()
+{
+ std::ofstream logfile("convergence_table_04/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ ConvergenceTable table_1;
+ ConvergenceTable table_2;
+ ConvergenceTable table_3;
+
+ deallog.push("1d");
+ table_1.add_value("n_cells", 16);
+ table_1.add_value("error", 4.841e-04);
+ table_1.add_value("n_cells", 24);
+ table_1.add_value("error", 1.446e-04);
+ table_1.add_value("n_cells", 32);
+ table_1.add_value("error", 6.120e-05);
+ table_1.add_value("n_cells", 48);
+ table_1.add_value("error", 1.817e-05);
+ table_1.add_value("n_cells", 64);
+ table_1.add_value("error", 7.672e-06);
+ table_1.add_value("n_cells", 96);
+ table_1.add_value("error", 2.274e-06);
+ table_1.add_value("n_cells", 128);
+ table_1.add_value("error", 9.597e-07);
+ table_1.set_scientific("error", true);
+ //table_1.evaluate_convergence_rates("error", "n_cells", ConvergenceTable::reduction_rate);
+ table_1.evaluate_convergence_rates("error", "n_cells", ConvergenceTable::reduction_rate_log2, 1);
+ table_1.write_text(deallog.get_file_stream());
+ deallog.pop();
+
+ deallog.push("2d");
+ table_2.add_value("n_cells", 64);
+ table_2.add_value("error", 7.755e-03);
+ table_2.add_value("n_cells", 144);
+ table_2.add_value("error", 2.326e-03);
+ table_2.add_value("n_cells", 256);
+ table_2.add_value("error", 9.969e-04);
+ table_2.add_value("n_cells", 576);
+ table_2.add_value("error", 2.987e-04);
+ table_2.add_value("n_cells", 1024);
+ table_2.add_value("error", 1.265e-04);
+ table_2.add_value("n_cells", 2304);
+ table_2.add_value("error", 3.759e-05);
+ table_2.add_value("n_cells", 4096);
+ table_2.add_value("error", 1.587e-05);
+ table_2.set_scientific("error", true);
+ //table_2.evaluate_convergence_rates("error", "n_cells", ConvergenceTable::reduction_rate);
+ table_2.evaluate_convergence_rates("error", "n_cells", ConvergenceTable::reduction_rate_log2, 2);
+ table_2.write_text(deallog.get_file_stream());
+ deallog.pop();
+
+ deallog.push("3d");
+ table_3.add_value("n_cells", 512);
+ table_3.add_value("error", 5.791e-02);
+ table_3.add_value("n_cells", 1728);
+ table_3.add_value("error", 2.624e-02);
+ table_3.add_value("n_cells", 4096);
+ table_3.add_value("error", 1.480e-02);
+ table_3.add_value("n_cells", 13824);
+ table_3.add_value("error", 6.587e-03);
+ table_3.add_value("n_cells", 32768);
+ table_3.add_value("error", 3.708e-03);
+ table_3.add_value("n_cells", 110592);
+ table_3.add_value("error", 1.649e-03);
+ table_3.add_value("n_cells", 262144);
+ table_3.add_value("error", 9.275e-04);
+ table_3.set_scientific("error", true);
+ //table_3.evaluate_convergence_rates("error", "n_cells", ConvergenceTable::reduction_rate);
+ table_3.evaluate_convergence_rates("error", "n_cells", ConvergenceTable::reduction_rate_log2, 3);
+ table_3.write_text(deallog.get_file_stream());
+ deallog.pop();
+
+
+}