From: Denis Davydov Date: Fri, 28 Oct 2016 19:22:32 +0000 (+0200) Subject: rename number to Number in matrix-free operators X-Git-Tag: v8.5.0-rc1~530^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3306%2Fhead;p=dealii.git rename number to Number in matrix-free operators --- diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 2762304780..a39e7ddb07 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -44,19 +44,19 @@ namespace MatrixFreeOperators * * @author Denis Davydov, 2016 */ - template + template class Base : public Subscriptor { public: /** * Number typedef. */ - typedef number number_type; + typedef Number number_type; /** * size_type needed for preconditioner classes. */ - typedef typename LinearAlgebra::distributed::Vector::size_type size_type; + typedef typename LinearAlgebra::distributed::Vector::size_type size_type; /** * Default constructor. @@ -77,12 +77,12 @@ namespace MatrixFreeOperators /** * Initialize operator on fine scale. */ - void initialize (const MatrixFree &data); + void initialize (const MatrixFree &data); /** * Initialize operator on a level @p level. */ - void initialize (const MatrixFree &data, + void initialize (const MatrixFree &data, const MGConstrainedDoFs &mg_constrained_dofs, const unsigned int level); @@ -99,44 +99,44 @@ namespace MatrixFreeOperators /** * vmult operator for interface. */ - void vmult_interface_down(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + void vmult_interface_down(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * vmult operator for interface. */ - void vmult_interface_up(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + void vmult_interface_up(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * Matrix-vector multiplication. */ - void vmult (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + void vmult (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * Transpose matrix-vector multiplication. */ - void Tvmult (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + void Tvmult (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * Adding Matrix-vector multiplication. */ - void vmult_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + void vmult_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * Adding transpose matrix-vector multiplication. */ - void Tvmult_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + void Tvmult_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * Returns the value of the matrix entry (row,col). In matrix-free context * this function is valid only for row==col when diagonal is initialized. */ - number el (const unsigned int row, + Number el (const unsigned int row, const unsigned int col) const; /** @@ -147,7 +147,7 @@ namespace MatrixFreeOperators /** * A wrapper for initialize_dof_vector() of MatrixFree object. */ - void initialize_dof_vector (LinearAlgebra::distributed::Vector &vec) const; + void initialize_dof_vector (LinearAlgebra::distributed::Vector &vec) const; /** * Compute diagonal of this operator. @@ -160,42 +160,42 @@ namespace MatrixFreeOperators /** * Get read access to the inverse diagonal of this operator. */ - const LinearAlgebra::distributed::Vector &get_matrix_diagonal_inverse() const; + const LinearAlgebra::distributed::Vector &get_matrix_diagonal_inverse() const; /** * Apply the Jacobi preconditioner, which multiplies every element of the * src vector by the inverse of the respective diagonal element and * multiplies the result with the relaxation factor omega. */ - void precondition_Jacobi(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, - const number omega) const; + void precondition_Jacobi(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src, + const Number omega) const; protected: /** * Apply operator to @p src and add result in @p dst. */ - virtual void apply_add(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const = 0; + virtual void apply_add(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const = 0; /** * Apply transpose operator to @p src and add result in @p dst. * * Default implementation is to call apply_add(). */ - virtual void Tapply_add(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + virtual void Tapply_add(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * MatrixFree object to be used with this operator. */ - SmartPointer, Base > data; + SmartPointer, Base > data; /** * A vector to store inverse of diagonal elements. */ - LinearAlgebra::distributed::Vector inverse_diagonal_entries; + LinearAlgebra::distributed::Vector inverse_diagonal_entries; /** * Indices of DoFs on edge in case the operator is used in GMG context. @@ -206,7 +206,7 @@ namespace MatrixFreeOperators /** * Auxiliary vector. */ - mutable std::vector > edge_constrained_values; + mutable std::vector > edge_constrained_values; /** * A flag which determines whether or not this operator has interface @@ -218,8 +218,8 @@ namespace MatrixFreeOperators * Function which implements vmult_add (@p transpose = false) and * Tvmult_add (@p transpose = true). */ - void mult_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, + void mult_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src, const bool transpose) const; }; @@ -293,8 +293,8 @@ namespace MatrixFreeOperators * * @author Daniel Arndt, 2016 */ - template - class MassOperator : public Base + template + class MassOperator : public Base { public: @@ -314,15 +314,15 @@ namespace MatrixFreeOperators * assumed that the passed input and output vector are correctly initialized * using initialize_dof_vector(). */ - virtual void apply_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const; + virtual void apply_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const; /** * For this operator, there is just a cell contribution. */ - void local_apply_cell (const MatrixFree &data, - LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, + void local_apply_cell (const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src, const std::pair &cell_range) const; }; @@ -442,15 +442,15 @@ namespace MatrixFreeOperators } //----------------- Base operator ----------------------------- - template - Base::~Base () + template + Base::~Base () { } - template - Base::Base () + template + Base::Base () : Subscriptor(), data(NULL), @@ -460,9 +460,9 @@ namespace MatrixFreeOperators - template - typename Base::size_type - Base::m () const + template + typename Base::size_type + Base::m () const { Assert(data != NULL, ExcNotInitialized()); @@ -471,18 +471,18 @@ namespace MatrixFreeOperators - template - typename Base::size_type - Base::n () const + template + typename Base::size_type + Base::n () const { return m(); } - template + template void - Base::clear () + Base::clear () { data = NULL; inverse_diagonal_entries.reinit(0); @@ -490,9 +490,9 @@ namespace MatrixFreeOperators - template - number - Base::el (const unsigned int row, + template + Number + Base::el (const unsigned int row, const unsigned int col) const { Assert (row == col, ExcNotImplemented()); @@ -502,9 +502,9 @@ namespace MatrixFreeOperators - template + template void - Base::initialize_dof_vector (LinearAlgebra::distributed::Vector &vec) const + Base::initialize_dof_vector (LinearAlgebra::distributed::Vector &vec) const { Assert(data != NULL, ExcNotInitialized()); @@ -516,29 +516,29 @@ namespace MatrixFreeOperators - template + template void - Base:: - initialize (const MatrixFree &data_) + Base:: + initialize (const MatrixFree &data_) { - data = SmartPointer, Base >(&data_,typeid(*this).name()); + data = SmartPointer, Base >(&data_,typeid(*this).name()); edge_constrained_indices.clear(); have_interface_matrices = false; } - template + template void - Base:: - initialize (const MatrixFree &data_, + Base:: + initialize (const MatrixFree &data_, const MGConstrainedDoFs &mg_constrained_dofs, const unsigned int level) { AssertThrow (level != numbers::invalid_unsigned_int, ExcMessage("level is not set")); - data = SmartPointer, Base >(&data_,typeid(*this).name()); + data = SmartPointer, Base >(&data_,typeid(*this).name()); // setup edge_constrained indices std::vector interface_indices; @@ -556,10 +556,10 @@ namespace MatrixFreeOperators - template + template void - Base::vmult (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base::vmult (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { dst = 0; vmult_add (dst, src); @@ -567,30 +567,30 @@ namespace MatrixFreeOperators - template + template void - Base::vmult_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base::vmult_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { mult_add (dst, src, false); } - template + template void - Base::Tvmult_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base::Tvmult_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { mult_add (dst, src, true); } - template + template void - Base::mult_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, + Base::mult_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src, const bool transpose) const { Assert(src.partitioners_are_globally_compatible(*data->get_dof_info(0).vector_partitioner), ExcInternalError()); @@ -601,9 +601,9 @@ namespace MatrixFreeOperators for (unsigned int i=0; i(src.local_element(edge_constrained_indices[i]), + std::pair(src.local_element(edge_constrained_indices[i]), dst.local_element(edge_constrained_indices[i])); - const_cast&>(src).local_element(edge_constrained_indices[i]) = 0.; + const_cast&>(src).local_element(edge_constrained_indices[i]) = 0.; } if (transpose) @@ -620,18 +620,18 @@ namespace MatrixFreeOperators // destination for (unsigned int i=0; i&>(src).local_element(edge_constrained_indices[i]) = edge_constrained_values[i].first; + const_cast&>(src).local_element(edge_constrained_indices[i]) = edge_constrained_values[i].first; dst.local_element(edge_constrained_indices[i]) = edge_constrained_values[i].second + edge_constrained_values[i].first; } } - template + template void - Base:: - vmult_interface_down(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base:: + vmult_interface_down(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { Assert(src.partitioners_are_globally_compatible(*data->get_dof_info(0).vector_partitioner), ExcInternalError()); Assert(dst.partitioners_are_globally_compatible(*data->get_dof_info(0).vector_partitioner), ExcInternalError()); @@ -646,9 +646,9 @@ namespace MatrixFreeOperators for (unsigned int i=0; i(src.local_element(edge_constrained_indices[i]), + std::pair(src.local_element(edge_constrained_indices[i]), dst.local_element(edge_constrained_indices[i])); - const_cast&>(src).local_element(edge_constrained_indices[i]) = 0.; + const_cast&>(src).local_element(edge_constrained_indices[i]) = 0.; } apply_add(dst,src); @@ -661,7 +661,7 @@ namespace MatrixFreeOperators ++c; // reset the src values - const_cast&>(src).local_element(edge_constrained_indices[i]) = edge_constrained_values[i].first; + const_cast&>(src).local_element(edge_constrained_indices[i]) = edge_constrained_values[i].first; } for ( ; c + template void - Base:: - vmult_interface_up(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base:: + vmult_interface_up(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { Assert(src.partitioners_are_globally_compatible(*data->get_dof_info(0).vector_partitioner), ExcInternalError()); Assert(dst.partitioners_are_globally_compatible(*data->get_dof_info(0).vector_partitioner), ExcInternalError()); @@ -683,7 +683,7 @@ namespace MatrixFreeOperators if (!have_interface_matrices) return; - LinearAlgebra::distributed::Vector src_cpy (src); + LinearAlgebra::distributed::Vector src_cpy (src); unsigned int c=0; for (unsigned int i=0; i + template void - Base::Tvmult (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base::Tvmult (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { dst = 0; Tvmult_add (dst,src); @@ -715,18 +715,18 @@ namespace MatrixFreeOperators - template + template std::size_t - Base::memory_consumption () const + Base::memory_consumption () const { return inverse_diagonal_entries.memory_consumption(); } - template - const LinearAlgebra::distributed::Vector & - Base::get_matrix_diagonal_inverse() const + template + const LinearAlgebra::distributed::Vector & + Base::get_matrix_diagonal_inverse() const { Assert(inverse_diagonal_entries.size() > 0, ExcNotInitialized()); return inverse_diagonal_entries; @@ -734,21 +734,21 @@ namespace MatrixFreeOperators - template + template void - Base::Tapply_add(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + Base::Tapply_add(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { apply_add(dst,src); } - template + template void - Base::precondition_Jacobi(LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, - const number omega) const + Base::precondition_Jacobi(LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src, + const Number omega) const { Assert(inverse_diagonal_entries.size() > 0, ExcNotInitialized()); @@ -761,66 +761,66 @@ namespace MatrixFreeOperators //-----------------------------MassOperator---------------------------------- - template - MassOperator:: + template + MassOperator:: MassOperator () : - Base() + Base() {} - template + template void - MassOperator:: + MassOperator:: compute_diagonal() { - Assert((Base::data != NULL), ExcNotInitialized()); + Assert((Base::data != NULL), ExcNotInitialized()); - LinearAlgebra::distributed::Vector ones; - Base::initialize_dof_vector(Base::inverse_diagonal_entries); - Base::initialize_dof_vector(ones); + LinearAlgebra::distributed::Vector ones; + Base::initialize_dof_vector(Base::inverse_diagonal_entries); + Base::initialize_dof_vector(ones); ones = 1.; ones.update_ghost_values(); - apply_add(Base::inverse_diagonal_entries, ones); + apply_add(Base::inverse_diagonal_entries, ones); const std::vector &constrained_dofs - = Base::data->get_constrained_dofs(); + = Base::data->get_constrained_dofs(); for (unsigned int i=0; i< constrained_dofs.size(); ++i) - Base::inverse_diagonal_entries.local_element(constrained_dofs[i]) = 1.; + Base::inverse_diagonal_entries.local_element(constrained_dofs[i]) = 1.; - const unsigned int local_size = Base::inverse_diagonal_entries.local_size(); + const unsigned int local_size = Base::inverse_diagonal_entries.local_size(); for (unsigned int i=0; i::inverse_diagonal_entries.local_element(i) - =1./Base::inverse_diagonal_entries.local_element(i); + Base::inverse_diagonal_entries.local_element(i) + =1./Base::inverse_diagonal_entries.local_element(i); - Base::inverse_diagonal_entries.compress(VectorOperation::insert); - Base::inverse_diagonal_entries.update_ghost_values(); + Base::inverse_diagonal_entries.compress(VectorOperation::insert); + Base::inverse_diagonal_entries.update_ghost_values(); } - template + template void - MassOperator:: - apply_add (LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src) const + MassOperator:: + apply_add (LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src) const { - Base::data->cell_loop (&MassOperator::local_apply_cell, + Base::data->cell_loop (&MassOperator::local_apply_cell, this, dst, src); } - template + template void - MassOperator:: - local_apply_cell (const MatrixFree &data, - LinearAlgebra::distributed::Vector &dst, - const LinearAlgebra::distributed::Vector &src, + MassOperator:: + local_apply_cell (const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, + const LinearAlgebra::distributed::Vector &src, const std::pair &cell_range) const { - FEEvaluation phi(*Base::data); + FEEvaluation phi(*Base::data); for (unsigned int cell=cell_range.first; cell