]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add a test
authorMatthias Maier <tamiko@43-1.org>
Thu, 3 May 2018 03:00:24 +0000 (22:00 -0500)
committerMatthias Maier <tamiko@43-1.org>
Thu, 3 May 2018 19:09:25 +0000 (14:09 -0500)
include/deal.II/lac/linear_operator.h
tests/lac/linear_operator_17a.cc [new file with mode: 0644]
tests/lac/linear_operator_17a.output [new file with mode: 0644]

index a08b89cb762e5d5462f2d75bc09c6b26431712a4..54ab1370f508784363818a1a82a0e62246691e19 100644 (file)
@@ -910,7 +910,7 @@ template <typename Range, typename Domain, typename Payload>
 LinearOperator<Range, Domain, Payload>
 mean_value_filter(const LinearOperator<Range, Domain, Payload> &op)
 {
-  auto return_op = mean_value_operator<Range, Payload>(op.reinit_range_vector);
+  auto return_op = mean_value_filter<Range, Payload>(op.reinit_range_vector);
   static_cast<Payload &>(return_op) = op.identity_payload();
 
   return return_op;
diff --git a/tests/lac/linear_operator_17a.cc b/tests/lac/linear_operator_17a.cc
new file mode 100644 (file)
index 0000000..a2eeb15
--- /dev/null
@@ -0,0 +1,64 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 - 2018 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Test the LinearOperator template on a trivial vector implementation
+// :: RightVector -> LeftVector
+
+#include "../tests.h"
+
+#include <deal.II/lac/linear_operator.h>
+#include <deal.II/lac/block_linear_operator.h>
+#include <deal.II/lac/block_vector.h>
+
+
+using namespace dealii;
+
+
+int main()
+{
+  initlog();
+
+  const std::function<void(Vector<double> &, bool)> reinit_vector =
+    [](Vector<double> &v, bool omit_zeroing_entries) {
+      v.reinit(3, omit_zeroing_entries);
+    };
+
+  auto id = identity_operator(reinit_vector);
+  const auto filter = mean_value_filter(id);
+
+  const auto block_filter = block_diagonal_operator<3>(filter);
+
+  BlockVector<double> block_vector(3, 3);
+  block_vector.block(0)[0] = 1;
+  block_vector.block(0)[1] = 2;
+  block_vector.block(0)[2] = 3;
+  block_vector.block(1)[0] = 4;
+  block_vector.block(1)[1] = 6;
+  block_vector.block(1)[2] = 8;
+  block_vector.block(2)[0] = 9;
+  block_vector.block(2)[1] = 12;
+  block_vector.block(2)[2] = 15;
+
+  deallog << block_vector.block(0) << std::endl;
+  deallog << block_vector.block(1) << std::endl;
+  deallog << block_vector.block(2) << std::endl;
+
+  BlockVector<double> block_vector_2(3, 3);
+  block_filter.vmult(block_vector_2, block_vector);
+
+  deallog << block_vector_2.block(0) << std::endl;
+  deallog << block_vector_2.block(1) << std::endl;
+  deallog << block_vector_2.block(2) << std::endl;
+}
diff --git a/tests/lac/linear_operator_17a.output b/tests/lac/linear_operator_17a.output
new file mode 100644 (file)
index 0000000..cff73c6
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::1.00000 2.00000 3.00000 
+DEAL::
+DEAL::4.00000 6.00000 8.00000 
+DEAL::
+DEAL::9.00000 12.0000 15.0000 
+DEAL::
+DEAL::-1.00000 0.00000 1.00000 
+DEAL::
+DEAL::-2.00000 0.00000 2.00000 
+DEAL::
+DEAL::-3.00000 0.00000 3.00000 
+DEAL::

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.