From: Martin Kronbichler Date: Tue, 31 May 2022 17:07:22 +0000 (+0200) Subject: Compare with interpolate() in test X-Git-Tag: v9.4.0-rc1~101^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72f408d8c85076eab16327f91aedd652613d0557;p=dealii.git Compare with interpolate() in test --- 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