]> https://gitweb.dealii.org/ - dealii.git/commitdiff
filtered_matrix test cases
authordakshinai <akdaks08@gmail.com>
Mon, 19 Jan 2015 08:16:05 +0000 (02:16 -0600)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Tue, 20 Jan 2015 07:21:34 +0000 (08:21 +0100)
tests/lac/filtered_matrix.cc
tests/lac/filtered_matrix_01.cc [new file with mode: 0644]
tests/lac/filtered_matrix_01.output [new file with mode: 0644]
tests/lac/filtered_matrix_02.cc [new file with mode: 0644]
tests/lac/filtered_matrix_02.output [new file with mode: 0644]
tests/lac/filtered_matrix_03.cc [new file with mode: 0644]
tests/lac/filtered_matrix_03.output [new file with mode: 0644]
tests/lac/filtered_matrix_04.cc [new file with mode: 0644]
tests/lac/filtered_matrix_04.output [new file with mode: 0644]
tests/lac/filtered_matrix_05.cc [new file with mode: 0644]
tests/lac/filtered_matrix_05.output [new file with mode: 0644]

index 4311e65cbbdfaf8909d6154b901c070ed76fc8bb..d03bdce47066bd18995b1c245311191f1040ba34 100644 (file)
@@ -22,7 +22,6 @@
 #include <deal.II/lac/matrix_lib.h>
 #include <deal.II/lac/precondition.h>
 #include <deal.II/lac/vector.h>
-
 #include <fstream>
 
 
@@ -80,8 +79,6 @@ void test (const FilteredMatrix<VECTOR> &M)
   deallog << std::endl;
 }
 
-
-
 int main()
 {
   std::ofstream logfile("output");
diff --git a/tests/lac/filtered_matrix_01.cc b/tests/lac/filtered_matrix_01.cc
new file mode 100644 (file)
index 0000000..014215f
--- /dev/null
@@ -0,0 +1,67 @@
+// ---------------------------------------------------------------------
+// $Id: filtered_matrix.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2007 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+void
+checkVmult(FullMatrix<number> &A, Vector<number> &V,
+           bool expect_constrained_source = false)
+{
+  deallog<< "vmult" << std::endl;
+
+  FilteredMatrix < Vector<double> > F;
+  F.initialize(A, expect_constrained_source);
+  F.add_constraint(0, 1);
+
+  Vector<number> O(A.m());
+
+  F.vmult(O, V);
+
+  for (unsigned int i = 0; i < O.size(); ++i)
+    deallog << O(i) << '\t';
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+  { 1, 2, 3, 4, 5, 6 };
+
+  FullMatrix<double> A(2, 3);
+
+  A.fill(Adata);
+
+  Vector<double> V(3);
+  V(0) = 1;
+  V(1) = 2;
+  V(2) = 3;
+
+  checkVmult<double>(A, V, false);
+  checkVmult<double>(A, V, true);
+}
diff --git a/tests/lac/filtered_matrix_01.output b/tests/lac/filtered_matrix_01.output
new file mode 100644 (file)
index 0000000..4f082a0
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::vmult
+DEAL::1.0000   28.0000 
+DEAL::vmult
+DEAL::1.0000   32.0000 
diff --git a/tests/lac/filtered_matrix_02.cc b/tests/lac/filtered_matrix_02.cc
new file mode 100644 (file)
index 0000000..ac432c2
--- /dev/null
@@ -0,0 +1,66 @@
+// ---------------------------------------------------------------------
+// $Id: filtered_matrix.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2007 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+void
+checkTvmult(FullMatrix<number> &A, Vector<number> &V,
+            bool expect_constrained_source = false)
+{
+  deallog << "Tvmult" << std::endl;
+
+  FilteredMatrix < Vector<double> > F;
+  F.initialize(A, expect_constrained_source);
+  F.add_constraint(0, 1);
+
+  Vector<number> O(A.n());
+
+  F.Tvmult(O, V);
+
+  for (unsigned int i = 0; i < O.size(); ++i)
+    deallog << O(i) << '\t';
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+  { 1, 2, 3, 4, 5, 6 };
+
+  FullMatrix<double> A(2, 3);
+
+  A.fill(Adata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkTvmult<double>(A, V, false);
+  checkTvmult<double>(A, V, true);
+}
diff --git a/tests/lac/filtered_matrix_02.output b/tests/lac/filtered_matrix_02.output
new file mode 100644 (file)
index 0000000..27e7f6b
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Tvmult
+DEAL::1.0000   10.0000 12.0000 
+DEAL::Tvmult
+DEAL::1.0000   12.0000 15.0000 
diff --git a/tests/lac/filtered_matrix_03.cc b/tests/lac/filtered_matrix_03.cc
new file mode 100644 (file)
index 0000000..e42ab6b
--- /dev/null
@@ -0,0 +1,71 @@
+// ---------------------------------------------------------------------
+// $Id: filtered_matrix.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2007 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+void
+checkVmult_Add(FullMatrix<number> &A, Vector<number> &V,
+               bool expect_constrained_source = false)
+{
+  deallog << "vmult_add" << std::endl;
+
+  FilteredMatrix < Vector<double> > F;
+  F.initialize(A, expect_constrained_source);
+  F.add_constraint(0, 1);
+
+  Vector<number> O(A.m());
+  for (unsigned int i = 0; i < O.size(); ++i)
+    {
+      O(i) = 1;
+    }
+
+  F.vmult_add(O, V);
+
+  for (unsigned int i = 0; i < O.size(); ++i)
+    deallog << O(i) << '\t';
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+  { 1, 2, 3, 4, 5, 6 };
+
+  FullMatrix<double> A(2, 3);
+
+  A.fill(Adata);
+
+  Vector<double> V(3);
+  V(0) = 1;
+  V(1) = 2;
+  V(2) = 3;
+
+  checkVmult_Add<double>(A, V, false);
+  checkVmult_Add<double>(A, V, true);
+}
diff --git a/tests/lac/filtered_matrix_03.output b/tests/lac/filtered_matrix_03.output
new file mode 100644 (file)
index 0000000..1bbc0b2
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::vmult_add
+DEAL::1.0000   29.0000 
+DEAL::vmult_add
+DEAL::1.0000   33.0000 
diff --git a/tests/lac/filtered_matrix_04.cc b/tests/lac/filtered_matrix_04.cc
new file mode 100644 (file)
index 0000000..1f74844
--- /dev/null
@@ -0,0 +1,70 @@
+// ---------------------------------------------------------------------
+// $Id: filtered_matrix.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2007 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+void
+checkTvmult_Add(FullMatrix<number> &A, Vector<number> &V,
+                bool expect_constrained_source = false)
+{
+  deallog << "Tvmult_add" << std::endl;
+
+  FilteredMatrix < Vector<double> > F;
+  F.initialize(A, expect_constrained_source);
+  F.add_constraint(0, 1);
+
+  Vector<number> O(A.n());
+  for (unsigned int i = 0; i < O.size(); ++i)
+    {
+      O(i) = 1;
+    }
+
+  F.Tvmult_add(O, V);
+
+  for (unsigned int i = 0; i < O.size(); ++i)
+    deallog << O(i) << '\t';
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+  { 1, 2, 3, 4, 5, 6 };
+
+  FullMatrix<double> A(2, 3);
+
+  A.fill(Adata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkTvmult_Add<double>(A, V, false);
+  checkTvmult_Add<double>(A, V, true);
+}
diff --git a/tests/lac/filtered_matrix_04.output b/tests/lac/filtered_matrix_04.output
new file mode 100644 (file)
index 0000000..8683f40
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Tvmult_add
+DEAL::1.0000   11.0000 13.0000 
+DEAL::Tvmult_add
+DEAL::1.0000   13.0000 16.0000 
diff --git a/tests/lac/filtered_matrix_05.cc b/tests/lac/filtered_matrix_05.cc
new file mode 100644 (file)
index 0000000..0410137
--- /dev/null
@@ -0,0 +1,67 @@
+// ---------------------------------------------------------------------
+// $Id: filtered_matrix.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2007 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+void
+checkApply_Constraints(FullMatrix<number> &A, Vector<number> &V,
+                       bool matrix_is_symmetric = false)
+{
+  deallog << "apply_constraints" << std::endl;
+
+  FilteredMatrix < Vector<double> > F;
+  F.initialize(A);
+  F.add_constraint(0, 1);
+
+  F.apply_constraints(V, matrix_is_symmetric);
+
+  for (unsigned int i = 0; i < V.size(); ++i)
+    deallog << V(i) << '\t';
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+  { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+  FullMatrix<double> A(3, 3);
+
+  A.fill(Adata);
+
+  Vector<double> V1(3);
+  Vector<double> V2(3);
+
+  V1(0) = V2(0) = 1;
+  V1(1) = V2(1) = 2;
+  V1(2) = V2(2) = 3;
+
+  checkApply_Constraints<double>(A, V1, false);
+  checkApply_Constraints<double>(A, V2, true);
+}
diff --git a/tests/lac/filtered_matrix_05.output b/tests/lac/filtered_matrix_05.output
new file mode 100644 (file)
index 0000000..664c0a3
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::apply_constraints
+DEAL::1.0000   -2.0000 -4.0000 
+DEAL::apply_constraints
+DEAL::1.0000   -2.0000 -4.0000 

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.