From 5f2c61940679b1627897e0456dab9ea754925e97 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Tue, 22 Feb 2022 15:38:02 +0000 Subject: [PATCH] Fixed ParsedConvergenceTable::difference() --- doc/news/changes/minor/20220222LucaHeltai | 3 + .../deal.II/base/parsed_convergence_table.h | 4 +- tests/base/parsed_convergence_table_11.cc | 69 +++++++++++++++++++ tests/base/parsed_convergence_table_11.output | 7 ++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 doc/news/changes/minor/20220222LucaHeltai create mode 100644 tests/base/parsed_convergence_table_11.cc create mode 100644 tests/base/parsed_convergence_table_11.output diff --git a/doc/news/changes/minor/20220222LucaHeltai b/doc/news/changes/minor/20220222LucaHeltai new file mode 100644 index 0000000000..304f67a5a2 --- /dev/null +++ b/doc/news/changes/minor/20220222LucaHeltai @@ -0,0 +1,3 @@ +Fixed: ParsedConvergenceTable::difference() was not working. This is now fixed. +
+(Luca Heltai, 2022/02/22) diff --git a/include/deal.II/base/parsed_convergence_table.h b/include/deal.II/base/parsed_convergence_table.h index 1f889aa887..657d0792e9 100644 --- a/include/deal.II/base/parsed_convergence_table.h +++ b/include/deal.II/base/parsed_convergence_table.h @@ -492,7 +492,7 @@ ParsedConvergenceTable::difference(const DoFHandler &dh, error_from_exact( dh, solution, - Functions::ConstantFunction(0, component_names.size()), + Functions::ConstantFunction(0.0, component_names.size()), weight); } @@ -514,7 +514,7 @@ ParsedConvergenceTable::difference(const Mapping & mapping, mapping, dh, solution, - Functions::ConstantFunction(0, component_names.size()), + Functions::ConstantFunction(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 index 0000000000..3aec176b25 --- /dev/null +++ b/tests/base/parsed_convergence_table_11.cc @@ -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 +#include + +#include + +#include + +#include +#include + +#include + +#include + +#include + +#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 sol(dh.n_dofs()); + Vector 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 index 0000000000..da394e4285 --- /dev/null +++ b/tests/base/parsed_convergence_table_11.output @@ -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 -- 2.39.5