]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed ParsedConvergenceTable::difference() 13435/head
authorLuca Heltai <luca.heltai@sissa.it>
Tue, 22 Feb 2022 15:38:02 +0000 (15:38 +0000)
committerLuca Heltai <luca.heltai@sissa.it>
Tue, 22 Feb 2022 15:38:02 +0000 (15:38 +0000)
doc/news/changes/minor/20220222LucaHeltai [new file with mode: 0644]
include/deal.II/base/parsed_convergence_table.h
tests/base/parsed_convergence_table_11.cc [new file with mode: 0644]
tests/base/parsed_convergence_table_11.output [new file with mode: 0644]

diff --git a/doc/news/changes/minor/20220222LucaHeltai b/doc/news/changes/minor/20220222LucaHeltai
new file mode 100644 (file)
index 0000000..304f67a
--- /dev/null
@@ -0,0 +1,3 @@
+Fixed: ParsedConvergenceTable::difference() was not working. This is now fixed.
+<br>
+(Luca Heltai, 2022/02/22)
index 1f889aa887e00d8f4e1b2edeed89c3dcc778e71c..657d0792e9377e74e977c24612027dd1531e39e3 100644 (file)
@@ -492,7 +492,7 @@ ParsedConvergenceTable::difference(const DoFHandler<dim, spacedim> &dh,
   error_from_exact(
     dh,
     solution,
-    Functions::ConstantFunction<spacedim>(0, component_names.size()),
+    Functions::ConstantFunction<spacedim>(0.0, component_names.size()),
     weight);
 }
 
@@ -514,7 +514,7 @@ ParsedConvergenceTable::difference(const Mapping<dim, spacedim> &   mapping,
     mapping,
     dh,
     solution,
-    Functions::ConstantFunction<spacedim>(0, component_names.size()),
+    Functions::ConstantFunction<spacedim>(0.0, component_names.size()),
     weight);
 }
 
diff --git a/tests/base/parsed_convergence_table_11.cc b/tests/base/parsed_convergence_table_11.cc
new file mode 100644 (file)
index 0000000..3aec176
--- /dev/null
@@ -0,0 +1,69 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 - 2020 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 differences
+// between finite element solutions
+
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/parsed_convergence_table.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/lac/vector.h>
+
+#include <deal.II/numerics/vector_tools.h>
+
+#include <map>
+
+#include "../tests.h"
+
+int
+main()
+{
+  initlog();
+
+  ParsedConvergenceTable table;
+
+  ParameterHandler prm;
+  table.add_parameters(prm);
+  prm.set("Rate key", "");
+  prm.set("Rate mode", "none");
+
+  Triangulation<2> tria;
+  GridGenerator::hyper_cube(tria);
+
+  FE_Q<2>       fe(1);
+  DoFHandler<2> dh(tria);
+
+  Functions::CosineFunction<2> exact(1);
+
+  for (unsigned int i = 0; i < 5; ++i)
+    {
+      tria.refine_global(1);
+      dh.distribute_dofs(fe);
+      Vector<double> sol(dh.n_dofs());
+      Vector<double> sol2(dh.n_dofs());
+      VectorTools::interpolate(dh, exact, sol);
+      sol2 = 1e-3;
+      sol2 -= sol;
+      table.difference(dh, sol, sol2);
+    }
+  table.output_table(deallog.get_file_stream());
+}
diff --git a/tests/base/parsed_convergence_table_11.output b/tests/base/parsed_convergence_table_11.output
new file mode 100644 (file)
index 0000000..da394e4
--- /dev/null
@@ -0,0 +1,7 @@
+
+cells dofs u_L2_norm u_Linfty_norm u_H1_norm 
+4     9    9.016e-01 1.918e+00     2.245e+00 
+16    25   9.738e-01 1.978e+00     2.387e+00 
+64    81   9.928e-01 1.994e+00     2.423e+00 
+256   289  9.976e-01 1.998e+00     2.433e+00 
+1024  1089 9.988e-01 1.999e+00     2.435e+00 

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.