From: Luca Heltai Date: Wed, 10 Apr 2019 00:07:31 +0000 (+0200) Subject: ParsedConvergenceTable, custom error computations, writing to files X-Git-Tag: v9.1.0-rc1~143^2~10 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88724dcb713ea57f9c1e583339e13a188f1552d5;p=dealii.git ParsedConvergenceTable, custom error computations, writing to files --- diff --git a/tests/base/parsed_convergence_table_10.cc b/tests/base/parsed_convergence_table_10.cc new file mode 100644 index 0000000000..af3c9a43ee --- /dev/null +++ b/tests/base/parsed_convergence_table_10.cc @@ -0,0 +1,82 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +// Test the functionality of the ParsedConvergenceTable class for +// custom error computations, writing to files + +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#include + +#include "../tests.h" + +int +main() +{ + initlog(); + + ParsedConvergenceTable table({"u"}, {{ParsedConvergenceTableFlags::custom}}); + + ParameterHandler prm; + table.add_parameters(prm); + + std::string input = "set Extra columns = dt, dofs, cells\n" + "set Rate key = cells\n" + "set Enable output to streams = false\n"; + + prm.parse_input_from_string(input); + + Triangulation<2> tria; + GridGenerator::hyper_cube(tria); + + FESystem<2> fe(FE_Q<2>(1), 1); + DoFHandler<2> dh(tria); + + for (unsigned int i = 0; i < 5; ++i) + { + tria.refine_global(1); + dh.distribute_dofs(fe); + auto cycle = [&](const unsigned int) { + return 1.0 / ((i + 1) * (i + 1)); + }; + table.custom_error(cycle, dh, "cycle", true, i + 1); + } + + input = "set Error file name = error.txt\n"; + prm.parse_input_from_string(input); + table.output_table(); + cat_file("error.txt"); + + input = "set Error file name = error.org\n"; + prm.parse_input_from_string(input); + table.output_table(); + cat_file("error.org"); + + input = "set Error file name = error.tex\n"; + prm.parse_input_from_string(input); + table.output_table(); + cat_file("error.tex"); +} diff --git a/tests/base/parsed_convergence_table_10.output b/tests/base/parsed_convergence_table_10.output new file mode 100644 index 0000000000..f1d7508a0e --- /dev/null +++ b/tests/base/parsed_convergence_table_10.output @@ -0,0 +1,35 @@ + +dofs cells dt u_cycle + 9 4 1.0000 1.000e+00 - + 25 16 2.0000 2.500e-01 2.00 + 81 64 3.0000 1.111e-01 1.17 + 289 256 4.0000 6.250e-02 0.83 +1089 1024 5.0000 4.000e-02 0.64 + +| dofs | cells | dt | u_cycle | u_cycle...red.rate.log2 | +| 9 | 4 | 1.0000 | 1.000e+00 | - | +| 25 | 16 | 2.0000 | 2.500e-01 | 2.00 | +| 81 | 64 | 3.0000 | 1.111e-01 | 1.17 | +| 289 | 256 | 4.0000 | 6.250e-02 | 0.83 | +| 1089 | 1024 | 5.0000 | 4.000e-02 | 0.64 | + +\documentclass[10pt]{report} +\usepackage{float} + + +\begin{document} +\begin{table}[H] +\begin{center} +\begin{tabular}{|r|r|r|c|c|} \hline +\# dofs & \# cells & \Delta t & +\multicolumn{2}{|c|}{$\| u - u_h \|_{\text{cycle} $}\\ \hline +9 & 4 & 1.0000 & 1.000e+00 & -\\ \hline +25 & 16 & 2.0000 & 2.500e-01 & 2.00\\ \hline +81 & 64 & 3.0000 & 1.111e-01 & 1.17\\ \hline +289 & 256 & 4.0000 & 6.250e-02 & 0.83\\ \hline +1089 & 1024 & 5.0000 & 4.000e-02 & 0.64\\ \hline +\end{tabular} +\end{center} +\end{table} +\end{document} +