]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Compare with interpolate() in test 13864/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Tue, 31 May 2022 17:07:22 +0000 (19:07 +0200)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Tue, 31 May 2022 17:09:27 +0000 (19:09 +0200)
tests/numerics/project_complex.cc
tests/numerics/project_complex.output

index 9254ff0ef9d16f9e4daf4a3227123ced6e932a8a..f7cb0f41ab9cf2d8d117745f9e8bc0aed62a3eec 100644 (file)
@@ -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<ComplexNumber> &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<ComplexNumber> interpolated_exact_solution(
-    dof_handler.n_dofs());
+  dealii::Vector<ComplexNumber> projected_solution(dof_handler.n_dofs());
+  dealii::Vector<ComplexNumber> 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;
 }
index 0fd8fc12f0b442283edd8868867114c242b04d11..3052bc5990fe159b36807534668a8105d450517e 100644 (file)
@@ -1,2 +1,3 @@
 
+DEAL::Relative difference between project and interpolate: 2.64851e-12
 DEAL::OK

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.