From: dakshinai Date: Mon, 19 Jan 2015 08:16:05 +0000 (-0600) Subject: filtered_matrix test cases X-Git-Tag: v8.3.0-rc1~522^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c75b95cc9bd6f4a05132c3e89ca5ac5ea8f7c770;p=dealii.git filtered_matrix test cases --- diff --git a/tests/lac/filtered_matrix.cc b/tests/lac/filtered_matrix.cc index 4311e65cbb..d03bdce470 100644 --- a/tests/lac/filtered_matrix.cc +++ b/tests/lac/filtered_matrix.cc @@ -22,7 +22,6 @@ #include #include #include - #include @@ -80,8 +79,6 @@ void test (const FilteredMatrix &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 index 0000000000..014215fc70 --- /dev/null +++ b/tests/lac/filtered_matrix_01.cc @@ -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 +#include +#include +#include + +template +void +checkVmult(FullMatrix &A, Vector &V, + bool expect_constrained_source = false) +{ + deallog<< "vmult" << std::endl; + + FilteredMatrix < Vector > F; + F.initialize(A, expect_constrained_source); + F.add_constraint(0, 1); + + Vector 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 A(2, 3); + + A.fill(Adata); + + Vector V(3); + V(0) = 1; + V(1) = 2; + V(2) = 3; + + checkVmult(A, V, false); + checkVmult(A, V, true); +} diff --git a/tests/lac/filtered_matrix_01.output b/tests/lac/filtered_matrix_01.output new file mode 100644 index 0000000000..4f082a076e --- /dev/null +++ b/tests/lac/filtered_matrix_01.output @@ -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 index 0000000000..ac432c2712 --- /dev/null +++ b/tests/lac/filtered_matrix_02.cc @@ -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 +#include +#include +#include + +template +void +checkTvmult(FullMatrix &A, Vector &V, + bool expect_constrained_source = false) +{ + deallog << "Tvmult" << std::endl; + + FilteredMatrix < Vector > F; + F.initialize(A, expect_constrained_source); + F.add_constraint(0, 1); + + Vector 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 A(2, 3); + + A.fill(Adata); + + Vector V(2); + V(0) = 1; + V(1) = 2; + + checkTvmult(A, V, false); + checkTvmult(A, V, true); +} diff --git a/tests/lac/filtered_matrix_02.output b/tests/lac/filtered_matrix_02.output new file mode 100644 index 0000000000..27e7f6bec6 --- /dev/null +++ b/tests/lac/filtered_matrix_02.output @@ -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 index 0000000000..e42ab6bc22 --- /dev/null +++ b/tests/lac/filtered_matrix_03.cc @@ -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 +#include +#include +#include + +template +void +checkVmult_Add(FullMatrix &A, Vector &V, + bool expect_constrained_source = false) +{ + deallog << "vmult_add" << std::endl; + + FilteredMatrix < Vector > F; + F.initialize(A, expect_constrained_source); + F.add_constraint(0, 1); + + Vector 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 A(2, 3); + + A.fill(Adata); + + Vector V(3); + V(0) = 1; + V(1) = 2; + V(2) = 3; + + checkVmult_Add(A, V, false); + checkVmult_Add(A, V, true); +} diff --git a/tests/lac/filtered_matrix_03.output b/tests/lac/filtered_matrix_03.output new file mode 100644 index 0000000000..1bbc0b2bd0 --- /dev/null +++ b/tests/lac/filtered_matrix_03.output @@ -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 index 0000000000..1f74844e39 --- /dev/null +++ b/tests/lac/filtered_matrix_04.cc @@ -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 +#include +#include +#include + +template +void +checkTvmult_Add(FullMatrix &A, Vector &V, + bool expect_constrained_source = false) +{ + deallog << "Tvmult_add" << std::endl; + + FilteredMatrix < Vector > F; + F.initialize(A, expect_constrained_source); + F.add_constraint(0, 1); + + Vector 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 A(2, 3); + + A.fill(Adata); + + Vector V(2); + V(0) = 1; + V(1) = 2; + + checkTvmult_Add(A, V, false); + checkTvmult_Add(A, V, true); +} diff --git a/tests/lac/filtered_matrix_04.output b/tests/lac/filtered_matrix_04.output new file mode 100644 index 0000000000..8683f40500 --- /dev/null +++ b/tests/lac/filtered_matrix_04.output @@ -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 index 0000000000..0410137225 --- /dev/null +++ b/tests/lac/filtered_matrix_05.cc @@ -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 +#include +#include +#include + +template +void +checkApply_Constraints(FullMatrix &A, Vector &V, + bool matrix_is_symmetric = false) +{ + deallog << "apply_constraints" << std::endl; + + FilteredMatrix < Vector > 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 A(3, 3); + + A.fill(Adata); + + Vector V1(3); + Vector V2(3); + + V1(0) = V2(0) = 1; + V1(1) = V2(1) = 2; + V1(2) = V2(2) = 3; + + checkApply_Constraints(A, V1, false); + checkApply_Constraints(A, V2, true); +} diff --git a/tests/lac/filtered_matrix_05.output b/tests/lac/filtered_matrix_05.output new file mode 100644 index 0000000000..664c0a38fb --- /dev/null +++ b/tests/lac/filtered_matrix_05.output @@ -0,0 +1,5 @@ + +DEAL::apply_constraints +DEAL::1.0000 -2.0000 -4.0000 +DEAL::apply_constraints +DEAL::1.0000 -2.0000 -4.0000