From aed7a687e19f1a1b1348a88695aba3376cda6b13 Mon Sep 17 00:00:00 2001 From: dakshinai Date: Fri, 19 Sep 2014 16:40:53 -0500 Subject: [PATCH] Test lac/SchurMatrix --- tests/lac/schur_matrix_01.cc | 133 +++++++++++++++++++++++++++++ tests/lac/schur_matrix_01.output | 8 ++ tests/lac/schur_matrix_02.cc | 136 ++++++++++++++++++++++++++++++ tests/lac/schur_matrix_02.output | 3 + tests/lac/schur_matrix_03.cc | 138 ++++++++++++++++++++++++++++++ tests/lac/schur_matrix_03.output | 5 ++ tests/lac/schur_matrix_04.cc | 140 +++++++++++++++++++++++++++++++ tests/lac/schur_matrix_04.output | 5 ++ 8 files changed, 568 insertions(+) create mode 100644 tests/lac/schur_matrix_01.cc create mode 100644 tests/lac/schur_matrix_01.output create mode 100644 tests/lac/schur_matrix_02.cc create mode 100644 tests/lac/schur_matrix_02.output create mode 100644 tests/lac/schur_matrix_03.cc create mode 100644 tests/lac/schur_matrix_03.output create mode 100644 tests/lac/schur_matrix_04.cc create mode 100644 tests/lac/schur_matrix_04.output diff --git a/tests/lac/schur_matrix_01.cc b/tests/lac/schur_matrix_01.cc new file mode 100644 index 0000000000..00dfccd9e6 --- /dev/null +++ b/tests/lac/schur_matrix_01.cc @@ -0,0 +1,133 @@ +// --------------------------------------------------------------------- +// $Id: schur_matrix_01.cc dilangov $ +// +// Copyright (C) 2014 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. +// +// --------------------------------------------------------------------- + +// check SchurMatrix::vmult + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +template + void + checkVmult(BlockVector &dst, const BlockVector &src, + const MA_inverse &Ainv, const MB &B, const MDt &Dt, const MC &C) + { + deallog << "vmult" << std::endl; + + GrowingVectorMemory < BlockVector > mem; + + SchurMatrix S(Ainv, B, Dt, C, mem); + + S.debug_level(1); + + S.vmult(dst, src); + + for (unsigned int i = 0; i < dst.size(); ++i) + deallog << dst(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); + + std::vector < types::global_dof_index > ivector(1); + ivector[0] = 1; + + double array[] = + { 2 }; + std::list l(&array[0], &array[1]); + + BlockVector src(ivector, l.begin(), l.end()); + BlockVector dst(ivector); + + const double Adata1[] = + { 1 }; + + const double Adata2[] = + { 2 }; + + const double Adata3[] = + { 4 }; + + const double Adata4[] = + { 5 }; + + const double Ddata1[] = + { 3 }; + + const double Ddata2[] = + { 6 }; + + const double Bdata1[] = + { 7 }; + + const double Bdata2[] = + { 8 }; + + const double Cdata[] = + { 9 }; + + FullMatrix MA1(1, 1); + FullMatrix MA2(1, 1); + FullMatrix MA3(1, 1); + FullMatrix MA4(1, 1); + FullMatrix MB1(1, 1); + FullMatrix MB2(1, 1); + FullMatrix MC(1, 1); + FullMatrix MD1(1, 1); + FullMatrix MD2(1, 1); + + MA1.fill(Adata1); + MA2.fill(Adata2); + MA3.fill(Adata3); + MA4.fill(Adata4); + MB1.fill(Bdata1); + MB2.fill(Bdata2); + MC.fill(Cdata); + MD1.fill(Ddata1); + MD2.fill(Ddata2); + + BlockMatrixArray Ainv(2, 2); + BlockMatrixArray B(1, 2); + BlockMatrixArray C(1, 1); + BlockMatrixArray Dt(1, 2); + + Ainv.enter(MA1, 0, 0); + Ainv.enter(MA2, 0, 1); + Ainv.enter(MA3, 1, 0); + Ainv.enter(MA4, 1, 1); + B.enter(MB1, 0, 0); + B.enter(MB2, 0, 1); + C.enter(MC, 0, 0); + Dt.enter(MD1, 0, 0); + Dt.enter(MD2, 0, 1); + + checkVmult, BlockMatrixArray, + BlockMatrixArray, BlockMatrixArray >(dst, src, Ainv, B, + Dt, C); +} diff --git a/tests/lac/schur_matrix_01.output b/tests/lac/schur_matrix_01.output new file mode 100644 index 0000000000..29a64a7145 --- /dev/null +++ b/tests/lac/schur_matrix_01.output @@ -0,0 +1,8 @@ + +DEAL::vmult +DEAL:Schur::src:2.0000 +DEAL:Schur::C:18.0000 +DEAL:Schur::Dt:13.4164 +DEAL:Schur::Ainverse:89.1964 +DEAL:Schur::dst:900.0000 +DEAL::900.0000 diff --git a/tests/lac/schur_matrix_02.cc b/tests/lac/schur_matrix_02.cc new file mode 100644 index 0000000000..def0f27152 --- /dev/null +++ b/tests/lac/schur_matrix_02.cc @@ -0,0 +1,136 @@ +// --------------------------------------------------------------------- +// $Id: schur_matrix_01.cc dilangov $ +// +// Copyright (C) 2014 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. +// +// --------------------------------------------------------------------- + +// check SchurMatrix::residual + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +template + void + checkResidual(BlockVector &dst, const BlockVector &src, + const BlockVector &rhs, const MA_inverse &Ainv, const MB &B, + const MDt &Dt, const MC &C) + { + deallog << "residual" << std::endl; + + GrowingVectorMemory < BlockVector > mem; + + SchurMatrix S(Ainv, B, Dt, C, mem); + + double r = S.residual(dst, src, rhs); + + deallog << "Residual:" << r << 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); + + std::vector < types::global_dof_index > ivector(1); + ivector[0] = 1; + + double src_array[] = + { 2 }; + std::list src_l(&src_array[0], &src_array[1]); + BlockVector src(ivector, src_l.begin(), src_l.end()); + + double rhs_array[] = + { 1000 }; + std::list rhs_l(&rhs_array[0], &rhs_array[1]); + BlockVector rhs(ivector, rhs_l.begin(), rhs_l.end()); + + BlockVector dst(ivector); + + const double Adata1[] = + { 1 }; + + const double Adata2[] = + { 2 }; + + const double Adata3[] = + { 4 }; + + const double Adata4[] = + { 5 }; + + const double Ddata1[] = + { 3 }; + + const double Ddata2[] = + { 6 }; + + const double Bdata1[] = + { 7 }; + + const double Bdata2[] = + { 8 }; + + const double Cdata[] = + { 9 }; + + FullMatrix MA1(1, 1); + FullMatrix MA2(1, 1); + FullMatrix MA3(1, 1); + FullMatrix MA4(1, 1); + FullMatrix MB1(1, 1); + FullMatrix MB2(1, 1); + FullMatrix MC(1, 1); + FullMatrix MD1(1, 1); + FullMatrix MD2(1, 1); + + MA1.fill(Adata1); + MA2.fill(Adata2); + MA3.fill(Adata3); + MA4.fill(Adata4); + MB1.fill(Bdata1); + MB2.fill(Bdata2); + MC.fill(Cdata); + MD1.fill(Ddata1); + MD2.fill(Ddata2); + + BlockMatrixArray Ainv(2, 2); + BlockMatrixArray B(1, 2); + BlockMatrixArray C(1, 1); + BlockMatrixArray Dt(1, 2); + + Ainv.enter(MA1, 0, 0); + Ainv.enter(MA2, 0, 1); + Ainv.enter(MA3, 1, 0); + Ainv.enter(MA4, 1, 1); + B.enter(MB1, 0, 0); + B.enter(MB2, 0, 1); + C.enter(MC, 0, 0); + Dt.enter(MD1, 0, 0); + Dt.enter(MD2, 0, 1); + + checkResidual, BlockMatrixArray, + BlockMatrixArray, BlockMatrixArray >(dst, src, rhs, Ainv, + B, Dt, C); + +} diff --git a/tests/lac/schur_matrix_02.output b/tests/lac/schur_matrix_02.output new file mode 100644 index 0000000000..de98ff8706 --- /dev/null +++ b/tests/lac/schur_matrix_02.output @@ -0,0 +1,3 @@ + +DEAL::residual +DEAL::Residual:100.0000 diff --git a/tests/lac/schur_matrix_03.cc b/tests/lac/schur_matrix_03.cc new file mode 100644 index 0000000000..e245493328 --- /dev/null +++ b/tests/lac/schur_matrix_03.cc @@ -0,0 +1,138 @@ +// --------------------------------------------------------------------- +// $Id: schur_matrix_01.cc dilangov $ +// +// Copyright (C) 2014 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. +// +// --------------------------------------------------------------------- + +// check SchurMatrix::prepare_rhs + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +template + void + checkPrepare_rhs(BlockVector &dst, const BlockVector &src, + const MA_inverse &Ainv, const MB &B, const MDt &Dt, const MC &C) + { + deallog << "prepare_rhs" << std::endl; + + GrowingVectorMemory < BlockVector > mem; + + SchurMatrix S(Ainv, B, Dt, C, mem); + + S.debug_level(1); + + S.prepare_rhs(dst, src); + + } + +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); + + std::vector < types::global_dof_index > ivector(2); + ivector[0] = 1; + ivector[1] = 1; + + double src_array[] = + { 9, 21 }; + std::list src_l(&src_array[0], &src_array[2]); + BlockVector src(ivector, src_l.begin(), src_l.end()); + + std::vector < types::global_dof_index > ivector2(1); + ivector2[0] = 1; + + double dst_array[] = + { 2 }; + std::list dst_l(&dst_array[0], &dst_array[1]); + BlockVector dst(ivector2, dst_l.begin(), dst_l.end()); + + const double Adata1[] = + { 1 }; + + const double Adata2[] = + { 2 }; + + const double Adata3[] = + { 4 }; + + const double Adata4[] = + { 5 }; + + const double Ddata1[] = + { 3 }; + + const double Ddata2[] = + { 6 }; + + const double Bdata1[] = + { 7 }; + + const double Bdata2[] = + { 8 }; + + const double Cdata[] = + { 9 }; + + FullMatrix MA1(1, 1); + FullMatrix MA2(1, 1); + FullMatrix MA3(1, 1); + FullMatrix MA4(1, 1); + FullMatrix MB1(1, 1); + FullMatrix MB2(1, 1); + FullMatrix MC(1, 1); + FullMatrix MD1(1, 1); + FullMatrix MD2(1, 1); + + MA1.fill(Adata1); + MA2.fill(Adata2); + MA3.fill(Adata3); + MA4.fill(Adata4); + MB1.fill(Bdata1); + MB2.fill(Bdata2); + MC.fill(Cdata); + MD1.fill(Ddata1); + MD2.fill(Ddata2); + + BlockMatrixArray Ainv(2, 2); + BlockMatrixArray B(1, 2); + BlockMatrixArray C(1, 1); + BlockMatrixArray Dt(1, 2); + + Ainv.enter(MA1, 0, 0); + Ainv.enter(MA2, 0, 1); + Ainv.enter(MA3, 1, 0); + Ainv.enter(MA4, 1, 1); + B.enter(MB1, 0, 0); + B.enter(MB2, 0, 1); + C.enter(MC, 0, 0); + Dt.enter(MD1, 0, 0); + Dt.enter(MD2, 0, 1); + + checkPrepare_rhs, BlockMatrixArray, + BlockMatrixArray, BlockMatrixArray >(dst, src, Ainv, B, + Dt, C); + +} diff --git a/tests/lac/schur_matrix_03.output b/tests/lac/schur_matrix_03.output new file mode 100644 index 0000000000..900ff7aedf --- /dev/null +++ b/tests/lac/schur_matrix_03.output @@ -0,0 +1,5 @@ + +DEAL::prepare_rhs +DEAL:Schur-prepare::src:22.8473 +DEAL:Schur-prepare::Ainverse:149.9400 +DEAL:Schur-prepare::dst:1487.0000 diff --git a/tests/lac/schur_matrix_04.cc b/tests/lac/schur_matrix_04.cc new file mode 100644 index 0000000000..0774c31ae2 --- /dev/null +++ b/tests/lac/schur_matrix_04.cc @@ -0,0 +1,140 @@ +// --------------------------------------------------------------------- +// $Id: schur_matrix_01.cc dilangov $ +// +// Copyright (C) 2014 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. +// +// --------------------------------------------------------------------- + +// check SchurMatrix::postprocess + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +template + void + checkPostprocess(BlockVector &dst, const BlockVector &src, + const BlockVector &rhs, const MA_inverse &Ainv, const MB &B, + const MDt &Dt, const MC &C) + { + deallog << "postprocess" << std::endl; + + GrowingVectorMemory < BlockVector > mem; + + SchurMatrix S(Ainv, B, Dt, C, mem); + + S.debug_level(1); + + S.postprocess(dst, src, rhs); + } + +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); + + std::vector < types::global_dof_index > ivector(2); + ivector[0] = 1; + ivector[1] = 1; + + double rhs_array[] = + { 9, 21 }; + std::list rhs_l(&rhs_array[0], &rhs_array[2]); + BlockVector rhs(ivector, rhs_l.begin(), rhs_l.end()); + + std::vector < types::global_dof_index > ivector2(1); + ivector2[0] = 1; + + double src_array[] = + { 2 }; + std::list src_l(&src_array[0], &src_array[1]); + BlockVector src(ivector2, src_l.begin(), src_l.end()); + + BlockVector dst(ivector); + + const double Adata1[] = + { 1 }; + + const double Adata2[] = + { 2 }; + + const double Adata3[] = + { 4 }; + + const double Adata4[] = + { 5 }; + + const double Ddata1[] = + { 3 }; + + const double Ddata2[] = + { 6 }; + + const double Bdata1[] = + { 7 }; + + const double Bdata2[] = + { 8 }; + + const double Cdata[] = + { 9 }; + + FullMatrix MA1(1, 1); + FullMatrix MA2(1, 1); + FullMatrix MA3(1, 1); + FullMatrix MA4(1, 1); + FullMatrix MB1(1, 1); + FullMatrix MB2(1, 1); + FullMatrix MC(1, 1); + FullMatrix MD1(1, 1); + FullMatrix MD2(1, 1); + + MA1.fill(Adata1); + MA2.fill(Adata2); + MA3.fill(Adata3); + MA4.fill(Adata4); + MB1.fill(Bdata1); + MB2.fill(Bdata2); + MC.fill(Cdata); + MD1.fill(Ddata1); + MD2.fill(Ddata2); + + BlockMatrixArray Ainv(2, 2); + BlockMatrixArray B(1, 2); + BlockMatrixArray C(1, 1); + BlockMatrixArray Dt(1, 2); + + Ainv.enter(MA1, 0, 0); + Ainv.enter(MA2, 0, 1); + Ainv.enter(MA3, 1, 0); + Ainv.enter(MA4, 1, 1); + B.enter(MB1, 0, 0); + B.enter(MB2, 0, 1); + C.enter(MC, 0, 0); + Dt.enter(MD1, 0, 0); + Dt.enter(MD2, 0, 1); + + checkPostprocess, BlockMatrixArray, + BlockMatrixArray, BlockMatrixArray >(dst, src, rhs, Ainv, + B, Dt, C); + +} diff --git a/tests/lac/schur_matrix_04.output b/tests/lac/schur_matrix_04.output new file mode 100644 index 0000000000..b662bd8594 --- /dev/null +++ b/tests/lac/schur_matrix_04.output @@ -0,0 +1,5 @@ + +DEAL::postprocess +DEAL:Schur-post::src:2.0000 +DEAL:Schur-post::Dt:13.4164 +DEAL:Schur-post::dst:60.7454 -- 2.39.5