From 1b83ca144eb91923371ff2820193844cd42ddf4a Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 3 Nov 2016 08:48:13 +0100 Subject: [PATCH] fix matrix-free unit tests due to a change to DiagonalMatrix in Base class while here, also use LaplaceOperator and add a few missing typedefs. --- include/deal.II/matrix_free/operators.h | 20 +++- .../parallel_multigrid_adaptive_02.cc | 109 +----------------- .../parallel_multigrid_adaptive_04.cc | 108 +---------------- 3 files changed, 26 insertions(+), 211 deletions(-) diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 3b17805338..5269ffef57 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -52,7 +52,7 @@ namespace MatrixFreeOperators /** * Number typedef. */ - typedef Number number_type; + typedef Number value_type; /** * size_type needed for preconditioner classes. @@ -305,6 +305,15 @@ namespace MatrixFreeOperators class MassOperator : public Base { public: + /** + * Number typedef. + */ + typedef typename Base::value_type value_type; + + /** + * size_type needed for preconditioner classes. + */ + typedef typename Base::size_type size_type; /** * Constructor. @@ -347,6 +356,15 @@ namespace MatrixFreeOperators class LaplaceOperator : public Base { public: + /** + * Number typedef. + */ + typedef typename Base::value_type value_type; + + /** + * size_type needed for preconditioner classes. + */ + typedef typename Base::size_type size_type; /** * Constructor. diff --git a/tests/matrix_free/parallel_multigrid_adaptive_02.cc b/tests/matrix_free/parallel_multigrid_adaptive_02.cc index 0022408296..d2f2bd838c 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_02.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_02.cc @@ -16,7 +16,7 @@ // same as parallel_multigird_adaptive_01, but based on MGTransferMatrixFree -// and deriving from the MatrixFreeOperators::Base class. +// and using MatrixFreeOperators::LaplaceOperator class. #include "../tests.h" @@ -50,107 +50,6 @@ std::ofstream logfile("output"); using namespace dealii::MatrixFreeOperators; -template -class LaplaceOperator : public MatrixFreeOperators::Base -{ -public: - typedef number value_type; - - LaplaceOperator() - : - MatrixFreeOperators::Base() - {}; - - void compute_diagonal () - { - unsigned int dummy = 0; - LinearAlgebra::distributed::Vector &inverse_diagonal_entries = Base::inverse_diagonal_entries; - this->initialize_dof_vector(inverse_diagonal_entries); - Base:: - data->cell_loop (&LaplaceOperator::local_diagonal_cell, - this, inverse_diagonal_entries, dummy); - - const std::vector & - constrained_dofs = Base::data->get_constrained_dofs(); - for (unsigned int i=0; i::edge_constrained_indices.size(); ++i) - inverse_diagonal_entries.local_element(Base::edge_constrained_indices[i]) = 0.; - - for (unsigned int i=0; i 1e-10) - inverse_diagonal_entries.local_element(i) = 1./inverse_diagonal_entries.local_element(i); - else - inverse_diagonal_entries.local_element(i) = 1.; - } - -protected: - - - void apply_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const - { - Base:: - data->cell_loop (&LaplaceOperator::local_apply, this, dst, src); - } - - -private: - - void - local_apply (const MatrixFree &data, - LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, - const std::pair &cell_range) const - { - FEEvaluation phi (data); - - for (unsigned int cell=cell_range.first; cell &data, - LinearAlgebra::distributed::Vector &dst, - const unsigned int &, - const std::pair &cell_range) const - { - FEEvaluation phi (data); - - for (unsigned int cell=cell_range.first; cell local_diagonal_vector[phi.tensor_dofs_per_cell]; - for (unsigned int i=0; i(); - phi.begin_dof_values()[i] = 1.; - phi.evaluate (false,true,false); - for (unsigned int q=0; q class MGInterfaceMatrix : public Subscriptor { @@ -279,7 +178,7 @@ void do_test (const DoFHandler &dof) MappingQ mapping(fe_degree+1); - LaplaceOperator fine_matrix; + LaplaceOperator fine_matrix; MatrixFree fine_level_data; typename MatrixFree::AdditionalData fine_level_additional_data; @@ -311,7 +210,7 @@ void do_test (const DoFHandler &dof) } // set up multigrid in analogy to step-37 - typedef LaplaceOperator LevelMatrixType; + typedef LaplaceOperator LevelMatrixType; MGLevelObject mg_matrices; MGLevelObject > mg_level_data; @@ -365,7 +264,7 @@ void do_test (const DoFHandler &dof) smoother_data[level].eig_cg_n_iterations = 15; smoother_data[level].preconditioner. reset(new DiagonalMatrix >()); - smoother_data[level].preconditioner->get_vector() = + *smoother_data[level].preconditioner = mg_matrices[level].get_matrix_diagonal_inverse(); } mg_smoother.initialize(mg_matrices, smoother_data); diff --git a/tests/matrix_free/parallel_multigrid_adaptive_04.cc b/tests/matrix_free/parallel_multigrid_adaptive_04.cc index af783779e0..a415d3f647 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_04.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_04.cc @@ -49,108 +49,6 @@ std::ofstream logfile("output"); using namespace dealii::MatrixFreeOperators; - -template -class LaplaceOperator : public MatrixFreeOperators::Base -{ -public: - typedef number value_type; - - LaplaceOperator() - : - MatrixFreeOperators::Base() - {}; - - void compute_diagonal () - { - unsigned int dummy = 0; - LinearAlgebra::distributed::Vector &inverse_diagonal_entries = Base::inverse_diagonal_entries; - this->initialize_dof_vector(inverse_diagonal_entries); - Base:: - data->cell_loop (&LaplaceOperator::local_diagonal_cell, - this, inverse_diagonal_entries, dummy); - - const std::vector & - constrained_dofs = Base::data->get_constrained_dofs(); - for (unsigned int i=0; i::edge_constrained_indices.size(); ++i) - inverse_diagonal_entries.local_element(Base::edge_constrained_indices[i]) = 0.; - - for (unsigned int i=0; i 1e-10) - inverse_diagonal_entries.local_element(i) = 1./inverse_diagonal_entries.local_element(i); - else - inverse_diagonal_entries.local_element(i) = 1.; - } - -protected: - - - void apply_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const - { - Base:: - data->cell_loop (&LaplaceOperator::local_apply, this, dst, src); - } - - -private: - - void - local_apply (const MatrixFree &data, - LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, - const std::pair &cell_range) const - { - FEEvaluation phi (data); - - for (unsigned int cell=cell_range.first; cell &data, - LinearAlgebra::distributed::Vector &dst, - const unsigned int &, - const std::pair &cell_range) const - { - FEEvaluation phi (data); - - for (unsigned int cell=cell_range.first; cell local_diagonal_vector[phi.tensor_dofs_per_cell]; - for (unsigned int i=0; i(); - phi.begin_dof_values()[i] = 1.; - phi.evaluate (false,true,false); - for (unsigned int q=0; q class MGInterfaceMatrix : public Subscriptor { @@ -279,7 +177,7 @@ void do_test (const DoFHandler &dof) MappingQ mapping(fe_degree+1); - LaplaceOperator fine_matrix; + LaplaceOperator fine_matrix; MatrixFree fine_level_data; typename MatrixFree::AdditionalData fine_level_additional_data; @@ -311,7 +209,7 @@ void do_test (const DoFHandler &dof) } // set up multigrid in analogy to step-37 - typedef LaplaceOperator LevelMatrixType; + typedef LaplaceOperator LevelMatrixType; MGLevelObject mg_matrices; MGLevelObject > mg_level_data; @@ -365,7 +263,7 @@ void do_test (const DoFHandler &dof) smoother_data[level].eig_cg_n_iterations = 15; smoother_data[level].preconditioner. reset(new DiagonalMatrix >()); - smoother_data[level].preconditioner->get_vector() = + *smoother_data[level].preconditioner = mg_matrices[level].get_matrix_diagonal_inverse(); } mg_smoother.initialize(mg_matrices, smoother_data); -- 2.39.5