]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Augment a test to verify detection. 13337/head
authorDavid Wells <drwells@email.unc.edu>
Thu, 3 Feb 2022 17:12:41 +0000 (12:12 -0500)
committerDavid Wells <drwells@email.unc.edu>
Thu, 3 Feb 2022 17:12:41 +0000 (12:12 -0500)
tests/matrix_free/laplace_operator_01.cc
tests/matrix_free/laplace_operator_02.cc
tests/matrix_free/laplace_operator_03.cc

index 8c64120b1e0bd23a1ea387b04b5d59619593c72f..1dc773a35018d9069d95a4245dc98bda44e00c1d 100644 (file)
@@ -32,6 +32,7 @@
 #include <deal.II/grid/manifold_lib.h>
 
 #include <deal.II/lac/affine_constraints.h>
+#include <deal.II/lac/linear_operator.h>
 #include <deal.II/lac/trilinos_sparse_matrix.h>
 #include <deal.II/lac/trilinos_sparsity_pattern.h>
 
@@ -139,6 +140,18 @@ test()
 
   mf.vmult(out, in);
 
+  // Check that things work with LinearOperator too. This verifies that the
+  // detection mechanism for initialize_dof_vector() works.
+  {
+    LinearAlgebra::distributed::Vector<number> out2;
+    mf.initialize_dof_vector(out2);
+
+    const auto op_mf = linear_operator<decltype(out2)>(mf);
+    op_mf.vmult(out2, in);
+
+    out2 -= out;
+    AssertThrow(out2.l2_norm() == 0.0, ExcInternalError());
+  }
 
   // assemble trilinos sparse matrix with
   // (v, u) for reference
@@ -194,8 +207,21 @@ test()
 
   sparse_matrix.vmult(ref, in);
   out -= ref;
-  const double diff_norm = out.linfty_norm();
 
+  // For completeness, try again with LinearOperator for the same detection
+  // reasons as above:
+  {
+    LinearAlgebra::distributed::Vector<number> out2;
+    mf.initialize_dof_vector(out2);
+
+    const auto op_mf = linear_operator<decltype(out2)>(sparse_matrix);
+    op_mf.vmult(out2, in);
+
+    out2 -= ref;
+    AssertThrow(out2.l2_norm() == 0.0, ExcInternalError());
+  }
+
+  const double diff_norm = out.linfty_norm();
   deallog << "Norm of difference: " << diff_norm << std::endl << std::endl;
 }
 
index 7a8ddcaaa9a76fdb7815308547fb6d55f90c8674..b2cde0be55713021b49d637a9ef63579b72c7358 100644 (file)
@@ -15,7 +15,8 @@
 
 
 
-// the same as laplace_operator_01, but tests heterogeneous Laplace operator.
+// the same as laplace_operator_01 (excluding the extra detection tests), but
+// tests heterogeneous Laplace operator.
 
 #include <deal.II/base/function.h>
 #include <deal.II/base/utilities.h>
index 59f6bd2a65552815003403b88935bd03b21aa3c2..abbc56b498c87e5db81f209dbe08310cff3b2e67 100644 (file)
@@ -15,8 +15,8 @@
 
 
 
-// the same as laplace_operator_01, but heterogeneous Laplace operator with a
-// single constant coefficient per cell
+// the same as laplace_operator_01 (excluding the extra detection tests), but
+// heterogeneous Laplace operator with a single constant coefficient per cell
 
 #include <deal.II/base/function.h>
 #include <deal.II/base/utilities.h>

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.