From 72f408d8c85076eab16327f91aedd652613d0557 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 31 May 2022 19:07:22 +0200 Subject: [PATCH] Compare with interpolate() in test --- tests/numerics/project_complex.cc | 49 +++++++-------------------- tests/numerics/project_complex.output | 1 + 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/tests/numerics/project_complex.cc b/tests/numerics/project_complex.cc index 9254ff0ef9..f7cb0f41ab 100644 --- a/tests/numerics/project_complex.cc +++ b/tests/numerics/project_complex.cc @@ -66,41 +66,9 @@ public: {} ComplexNumber - value(const Position &, const unsigned int) const + value(const Position &x, const unsigned int) const { - return ComplexNumber(0, 0); - } - - void - vector_value(const Position &, dealii::Vector &value) const - { - value.reinit(3); - for (unsigned int i = 0; i < 3; i++) - { - value[i] = {0, 0}; - } - } - - dealii::Tensor<1, 3, ComplexNumber> - curl(const Position &) const - { - dealii::Tensor<1, 3, ComplexNumber> ret; - for (unsigned int i = 0; i < 3; i++) - { - ret[i] = {0, 0}; - } - return ret; - } - - dealii::Tensor<1, 3, ComplexNumber> - val(const Position &) const - { - dealii::Tensor<1, 3, ComplexNumber> ret; - for (unsigned int i = 0; i < 3; i++) - { - ret[i] = {0, 0}; - } - return ret; + return x(0) + x(1) - ComplexNumber(0.2, 0.7) * x(2); } }; @@ -128,10 +96,17 @@ main() local_constraints.close(); dealii::QGauss<3> quadrature(2); - dealii::Vector interpolated_exact_solution( - dof_handler.n_dofs()); + dealii::Vector projected_solution(dof_handler.n_dofs()); + dealii::Vector interpolated_solution(dof_handler.n_dofs()); VectorTools::project( - dof_handler, local_constraints, quadrature, f, interpolated_exact_solution); + dof_handler, local_constraints, quadrature, f, projected_solution); + + VectorTools::interpolate(dof_handler, f, interpolated_solution); + + projected_solution -= interpolated_solution; + deallog << "Relative difference between project and interpolate: " + << projected_solution.l2_norm() / interpolated_solution.l2_norm() + << std::endl; deallog << "OK" << std::endl; } diff --git a/tests/numerics/project_complex.output b/tests/numerics/project_complex.output index 0fd8fc12f0..3052bc5990 100644 --- a/tests/numerics/project_complex.output +++ b/tests/numerics/project_complex.output @@ -1,2 +1,3 @@ +DEAL::Relative difference between project and interpolate: 2.64851e-12 DEAL::OK -- 2.39.5