From b5196a78d233deed8f7e3d545efeb3ffee53ed56 Mon Sep 17 00:00:00 2001 From: heister Date: Tue, 14 Aug 2012 14:58:40 +0000 Subject: [PATCH] merge: unify compress() for linear algebra objects git-svn-id: https://svn.dealii.org/trunk@25986 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/doxygen/headers/distributed.h | 4 + deal.II/doc/doxygen/headers/glossary.h | 5 +- deal.II/doc/news/changes.h | 8 ++ .../include/deal.II/lac/block_matrix_base.h | 13 +++- deal.II/include/deal.II/lac/block_vector.h | 24 ++++++ .../include/deal.II/lac/block_vector_base.h | 17 ++++- deal.II/include/deal.II/lac/parallel_vector.h | 31 ++++---- .../include/deal.II/lac/petsc_matrix_base.h | 5 +- .../deal.II/lac/petsc_parallel_vector.h | 2 +- deal.II/include/deal.II/lac/petsc_vector.h | 2 +- .../include/deal.II/lac/petsc_vector_base.h | 74 ++++++------------- .../lac/trilinos_block_sparse_matrix.h | 14 ---- .../deal.II/lac/trilinos_block_vector.h | 31 ++++++++ .../lac/trilinos_parallel_block_vector.h | 64 ++++++++-------- .../deal.II/lac/trilinos_sparse_matrix.h | 5 +- .../deal.II/lac/trilinos_vector_base.h | 47 ++++++++++-- deal.II/include/deal.II/lac/vector.h | 20 ++++- .../deal.II/numerics/vector_tools.templates.h | 1 + .../source/distributed/solution_transfer.cc | 38 +--------- deal.II/source/lac/constraint_matrix.cc | 4 +- deal.II/source/lac/petsc_matrix_base.cc | 2 +- deal.II/source/lac/petsc_vector_base.cc | 34 ++++----- .../lac/trilinos_block_sparse_matrix.cc | 8 -- deal.II/source/lac/trilinos_block_vector.cc | 9 --- 24 files changed, 254 insertions(+), 208 deletions(-) diff --git a/deal.II/doc/doxygen/headers/distributed.h b/deal.II/doc/doxygen/headers/distributed.h index b549dd4c83..f5ff673c46 100644 --- a/deal.II/doc/doxygen/headers/distributed.h +++ b/deal.II/doc/doxygen/headers/distributed.h @@ -52,6 +52,10 @@ * too many details. All the algorithms described below are implement in * classes and functions in namespace parallel::distributed. * + * One important aspect in parallel computations using MPI is that write + * access to matrix and vector elements requires a call to compress() after + * the operation is finished and before the object is used (for example read + * from). Also see @ref GlossCompress. * *

Other resources

* diff --git a/deal.II/doc/doxygen/headers/glossary.h b/deal.II/doc/doxygen/headers/glossary.h index 008ed4e1e4..f1129b7982 100644 --- a/deal.II/doc/doxygen/headers/glossary.h +++ b/deal.II/doc/doxygen/headers/glossary.h @@ -1,3 +1,4 @@ + //------------------------------------------------------------------------- // $Id$ // Version: $Name$ @@ -356,8 +357,8 @@ * ways: * * - You tell the object that you want to compress what operation is - * intended. The TrilinosWrappers::VectorBase::compress() can take - * such an additional argument. + * intended. This can be done using the VectorOperation argument in + * the various compress() functions. * - You do a fake addition or set operation on the object in question. For * example, you can add a zero to an element of the matrix or vector, * which has no effect other than telling the object that the next diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 1c45b5f3cd..1e8ca84a17 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -62,6 +62,14 @@ used to store boundary indicators internally.
    +
  1. +Changed: unify the concept of compress() for all linear algebra +objects. Introduce type VectorOperation to decide between +add and insert. Implement also for serial vectors. Note: +this breaks distributed::vector::compress(bool). +
    +(Timo Heister, 2012/08/13) +
  2. Changed: Support for the METIS 4.x has been replaced with support for METIS 5.x. Use --with-metis=path/to/metis to configure diff --git a/deal.II/include/deal.II/lac/block_matrix_base.h b/deal.II/include/deal.II/lac/block_matrix_base.h index c910989653..8f68491ec6 100644 --- a/deal.II/include/deal.II/lac/block_matrix_base.h +++ b/deal.II/include/deal.II/lac/block_matrix_base.h @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -736,8 +737,14 @@ class BlockMatrixBase : public Subscriptor /** * Call the compress() function on all * the subblocks of the matrix. + * + * + * See @ref GlossCompress "Compressing + * distributed objects" for more + * information. */ - void compress (); + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); /** * Multiply the entire matrix by a @@ -2316,11 +2323,11 @@ BlockMatrixBase::diag_element (const unsigned int i) const template inline void -BlockMatrixBase::compress () +BlockMatrixBase::compress (::dealii::VectorOperation::values operation) { for (unsigned int r=0; r > */ ~BlockVector (); + /** + * Call the compress() function on all + * the subblocks. + * + * This functionality only needs to be + * called if using MPI based vectors and + * exists in other objects for + * compatibility. + * + * See @ref GlossCompress "Compressing + * distributed objects" for more + * information. + */ + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); + /** * Copy operator: fill all components of * the vector with the given scalar @@ -523,6 +539,14 @@ BlockVector::operator = (const BlockVector &v) return *this; } +template +inline +void BlockVector::compress (::dealii::VectorOperation::values operation) +{ + for (unsigned int i=0; in_blocks();++i) + this->components[i].compress(operation); +} + template diff --git a/deal.II/include/deal.II/lac/block_vector_base.h b/deal.II/include/deal.II/lac/block_vector_base.h index f984a739a2..dff90420e1 100644 --- a/deal.II/include/deal.II/lac/block_vector_base.h +++ b/deal.II/include/deal.II/lac/block_vector_base.h @@ -787,8 +787,19 @@ class BlockVectorBase : public Subscriptor /** * Call the compress() function on all * the subblocks of the matrix. + * + * This functionality only needs to be + * called if using MPI based vectors and + * exists in other objects for + * compatibility. + * + * See @ref GlossCompress "Compressing + * distributed objects" for more + * information. */ - void compress (); + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); + /** * Access to a single block. @@ -1824,10 +1835,10 @@ BlockVectorBase::collect_sizes () template inline void -BlockVectorBase::compress () +BlockVectorBase::compress (::dealii::VectorOperation::values operation) { for (unsigned int i=0; i inline void - Vector::compress (const bool add_ghost_data) + Vector::compress (::dealii::VectorOperation::values operation) { compress_start (); - compress_finish (add_ghost_data); + if (operation == ::dealii::VectorOperation::insert) + compress_finish (false); + else + compress_finish (true); } diff --git a/deal.II/include/deal.II/lac/petsc_matrix_base.h b/deal.II/include/deal.II/lac/petsc_matrix_base.h index 727eee8567..e8b352e46f 100644 --- a/deal.II/include/deal.II/lac/petsc_matrix_base.h +++ b/deal.II/include/deal.II/lac/petsc_matrix_base.h @@ -20,6 +20,7 @@ # include # include # include +# include # include # include @@ -671,8 +672,8 @@ namespace PETScWrappers * for more information. * more information. */ - void compress (); - + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); /** * Return the value of the entry * (i,j). This may be an diff --git a/deal.II/include/deal.II/lac/petsc_parallel_vector.h b/deal.II/include/deal.II/lac/petsc_parallel_vector.h index d7f40bfbcf..df431183bd 100644 --- a/deal.II/include/deal.II/lac/petsc_parallel_vector.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_vector.h @@ -543,7 +543,7 @@ namespace PETScWrappers for (unsigned int i=0; i # include +# include # include # include @@ -294,9 +295,9 @@ namespace PETScWrappers * * See @ref GlossCompress "Compressing distributed objects" * for more information. - * more information. */ - void compress (); + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); /** * Set all components of the vector to @@ -823,33 +824,6 @@ namespace PETScWrappers */ IndexSet ghost_indices; - /** - * PETSc doesn't allow to mix additions - * to matrix entries and overwriting - * them (to make synchronisation of - * parallel computations - * simpler). Since the interface of the - * existing classes don't support the - * notion of not interleaving things, - * we have to emulate this - * ourselves. The way we do it is to, - * for each access operation, store - * whether it is an insertion or an - * addition. If the previous one was of - * different type, then we first have - * to flush the PETSc buffers; - * otherwise, we can simply go on. - * - * The following structure and variable - * declare and store the previous - * state. - */ - struct LastAction - { - enum Values { none, insert, add }; - }; - - /** * Store whether the last action was a * write or add operation. This @@ -858,7 +832,7 @@ namespace PETScWrappers * even though the vector object they * refer to is constant. */ - mutable LastAction::Values last_action; + mutable ::dealii::VectorOperation::values last_action; /** * Make the reference class a friend. @@ -954,10 +928,10 @@ namespace PETScWrappers const VectorReference & VectorReference::operator = (const PetscScalar &value) const { - Assert ((vector.last_action == VectorBase::LastAction::insert) + Assert ((vector.last_action == VectorOperation::insert) || - (vector.last_action == VectorBase::LastAction::none), - ExcWrongMode (VectorBase::LastAction::insert, + (vector.last_action == VectorOperation::unknown), + ExcWrongMode (VectorOperation::insert, vector.last_action)); #ifdef PETSC_USE_64BIT_INDICES @@ -970,7 +944,7 @@ namespace PETScWrappers = VecSetValues (vector, 1, &petsc_i, &value, INSERT_VALUES); AssertThrow (ierr == 0, ExcPETScError(ierr)); - vector.last_action = VectorBase::LastAction::insert; + vector.last_action = VectorOperation::insert; return *this; } @@ -981,13 +955,13 @@ namespace PETScWrappers const VectorReference & VectorReference::operator += (const PetscScalar &value) const { - Assert ((vector.last_action == VectorBase::LastAction::add) + Assert ((vector.last_action == VectorOperation::add) || - (vector.last_action == VectorBase::LastAction::none), - ExcWrongMode (VectorBase::LastAction::add, + (vector.last_action == VectorOperation::unknown), + ExcWrongMode (VectorOperation::add, vector.last_action)); - vector.last_action = VectorBase::LastAction::add; + vector.last_action = VectorOperation::add; // we have to do above actions in any // case to be consistent with the MPI @@ -1019,13 +993,13 @@ namespace PETScWrappers const VectorReference & VectorReference::operator -= (const PetscScalar &value) const { - Assert ((vector.last_action == VectorBase::LastAction::add) + Assert ((vector.last_action == VectorOperation::add) || - (vector.last_action == VectorBase::LastAction::none), - ExcWrongMode (VectorBase::LastAction::add, + (vector.last_action == VectorOperation::unknown), + ExcWrongMode (VectorOperation::add, vector.last_action)); - vector.last_action = VectorBase::LastAction::add; + vector.last_action = VectorOperation::add; // we have to do above actions in any // case to be consistent with the MPI @@ -1058,13 +1032,13 @@ namespace PETScWrappers const VectorReference & VectorReference::operator *= (const PetscScalar &value) const { - Assert ((vector.last_action == VectorBase::LastAction::insert) + Assert ((vector.last_action == VectorOperation::insert) || - (vector.last_action == VectorBase::LastAction::none), - ExcWrongMode (VectorBase::LastAction::insert, + (vector.last_action == VectorOperation::unknown), + ExcWrongMode (VectorOperation::insert, vector.last_action)); - vector.last_action = VectorBase::LastAction::insert; + vector.last_action = VectorOperation::insert; // we have to do above actions in any // case to be consistent with the MPI @@ -1098,13 +1072,13 @@ namespace PETScWrappers const VectorReference & VectorReference::operator /= (const PetscScalar &value) const { - Assert ((vector.last_action == VectorBase::LastAction::insert) + Assert ((vector.last_action == VectorOperation::insert) || - (vector.last_action == VectorBase::LastAction::none), - ExcWrongMode (VectorBase::LastAction::insert, + (vector.last_action == VectorOperation::unknown), + ExcWrongMode (VectorOperation::insert, vector.last_action)); - vector.last_action = VectorBase::LastAction::insert; + vector.last_action = VectorOperation::insert; // we have to do above actions in any // case to be consistent with the MPI diff --git a/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h index 20034ccfc4..767c2082a4 100644 --- a/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h @@ -246,20 +246,6 @@ namespace TrilinosWrappers void reinit (const ::dealii::BlockSparseMatrix &deal_ii_sparse_matrix, const double drop_tolerance=1e-13); - /** - * This function calls the compress() - * command of all matrices after - * the assembly is - * completed. Note that all MPI - * processes need to call this - * command (whereas the individual - * assembly routines will most probably - * only be called on each processor - * individually) before any - * can complete it. - */ - void compress (); - /** * Returns the state of the * matrix, i.e., whether diff --git a/deal.II/include/deal.II/lac/trilinos_block_vector.h b/deal.II/include/deal.II/lac/trilinos_block_vector.h index 61017fd564..a5c22e2d03 100644 --- a/deal.II/include/deal.II/lac/trilinos_block_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_block_vector.h @@ -186,6 +186,22 @@ namespace TrilinosWrappers */ ~BlockVector (); + /** + * use compress(VectorOperation) instead + * + * @deprecated + * + * See @ref GlossCompress "Compressing + * distributed objects" for more + * information. + */ + void compress (const Epetra_CombineMode last_action); + + /** + * so it is not hidden + */ + using BlockVectorBase::compress; + /** * Copy operator: fill all * components of the vector that @@ -503,6 +519,21 @@ namespace TrilinosWrappers } + inline + void + BlockVector::compress (const Epetra_CombineMode last_action) + { + ::dealii::VectorOperation::values last_action_; + if (last_action == Add) + last_action_ = ::dealii::VectorOperation::add; + else if (last_action == Insert) + last_action_ = ::dealii::VectorOperation::insert; + else + AssertThrow(false, ExcNotImplemented()); + + this->compress(last_action_); + } + inline void BlockVector::swap (BlockVector &v) diff --git a/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h b/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h index c18190c410..841b008116 100644 --- a/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h @@ -306,36 +306,23 @@ namespace TrilinosWrappers void import_nonlocal_data_for_fe (const TrilinosWrappers::BlockSparseMatrix &m, const BlockVector &v); - /** - * Compress the underlying - * representation of the Trilinos - * object, i.e. flush the buffers - * of the vector object if it has - * any. This function is - * necessary after writing into a - * vector element-by-element and - * before anything else can be - * done on it. - * - * The (defaulted) argument can - * be used to specify the - * compress mode - * (Add or - * Insert) in case - * the vector has not been - * written to since the last - * time this function was - * called. The argument is - * ignored if the vector has - * been added or written to - * since the last time - * compress() was called. - * - * See @ref GlossCompress "Compressing distributed objects" - * for more information. - * more information. - */ - void compress (const Epetra_CombineMode last_action = Zero); + + /** + * use compress(VectorOperation) instead + * + * @deprecated + * + * See @ref GlossCompress "Compressing + * distributed objects" for more + * information. + */ + void compress (const Epetra_CombineMode last_action); + + /** + * so it is not hidden + */ + using BlockVectorBase::compress; + /** * Returns the state of the @@ -471,6 +458,23 @@ namespace TrilinosWrappers + inline + void + BlockVector::compress (const Epetra_CombineMode last_action) + { + ::dealii::VectorOperation::values last_action_; + if (last_action == Add) + last_action_ = ::dealii::VectorOperation::add; + else if (last_action == Insert) + last_action_ = ::dealii::VectorOperation::insert; + else + AssertThrow(false, ExcNotImplemented()); + + this->compress(last_action_); + } + + + template BlockVector & BlockVector::operator = (const ::dealii::BlockVector &v) diff --git a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h index ef463416db..696d0e8e4b 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h @@ -1163,7 +1163,8 @@ namespace TrilinosWrappers * See @ref GlossCompress "Compressing distributed objects" * for more information. */ - void compress (); + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); /** * Set the element (i,j) @@ -2588,7 +2589,7 @@ namespace TrilinosWrappers inline void - SparseMatrix::compress () + SparseMatrix::compress (::dealii::VectorOperation::values operation) { // flush buffers int ierr; diff --git a/deal.II/include/deal.II/lac/trilinos_vector_base.h b/deal.II/include/deal.II/lac/trilinos_vector_base.h index 549bc76afb..2b462a7707 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector_base.h +++ b/deal.II/include/deal.II/lac/trilinos_vector_base.h @@ -344,9 +344,14 @@ namespace TrilinosWrappers * * See @ref GlossCompress "Compressing distributed objects" * for more information. - * more information. */ - void compress (const Epetra_CombineMode last_action = Zero); + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown); + + /** + * @deprecated + */ + void compress (const Epetra_CombineMode last_action); /** * Returns the state of the @@ -1204,10 +1209,42 @@ namespace TrilinosWrappers inline void - VectorBase::compress (const Epetra_CombineMode given_last_action) + VectorBase::compress (const Epetra_CombineMode last_action) { - Epetra_CombineMode mode = (last_action != Zero) ? - last_action : given_last_action; + ::dealii::VectorOperation::values last_action_; + if (last_action == Add) + last_action_ = ::dealii::VectorOperation::add; + else if (last_action == Insert) + last_action_ = ::dealii::VectorOperation::insert; + else + AssertThrow(false, ExcNotImplemented()); + + compress(last_action_); + } + + + + inline + void + VectorBase::compress (::dealii::VectorOperation::values given_last_action) + { + //Select which mode to send to + //Trilinos. Note that we use last_action + //if available and ignore what the user + //tells us to detect wrongly mixed + //operations. Typically given_last_action + //is only used on machines that do not + //execute an operation (because they have + //no own cells for example). + Epetra_CombineMode mode = last_action; + if (last_action == Zero) + { + if (given_last_action==::dealii::VectorOperation::add) + mode = Add; + else if (given_last_action==::dealii::VectorOperation::insert) + mode = Insert; + } + #ifdef DEBUG # ifdef DEAL_II_COMPILER_SUPPORTS_MPI // check that every process has decided diff --git a/deal.II/include/deal.II/lac/vector.h b/deal.II/include/deal.II/lac/vector.h index 2500fc913d..5e232a756a 100644 --- a/deal.II/include/deal.II/lac/vector.h +++ b/deal.II/include/deal.II/lac/vector.h @@ -65,6 +65,21 @@ template class VectorView; *@{ */ +/** + * This enum keeps track of the current operation in parallel linear algebra + * objects like Vectors and Matrices. + * + * It is used in the various compress() functions. They also exist in serial + * codes for compatibility and are empty there. + * + * See @ref GlossCompress "Compressing distributed objects" for more + * information. + */ +struct VectorOperation +{ + enum values { unknown, insert, add }; +}; + /** * Numerical vector of data. For this class there are different types @@ -297,7 +312,8 @@ class Vector : public Subscriptor * this class, it is immaterial and thus * an empty function. */ - void compress () const; + void compress (::dealii::VectorOperation::values operation + =::dealii::VectorOperation::unknown) const; /** * Change the dimension of the vector to @@ -1495,7 +1511,7 @@ Vector::operator != (const Vector& v) const template inline void -Vector::compress () const +Vector::compress (::dealii::VectorOperation::values) const {} diff --git a/deal.II/include/deal.II/numerics/vector_tools.templates.h b/deal.II/include/deal.II/numerics/vector_tools.templates.h index 190b8866e7..673e069acc 100644 --- a/deal.II/include/deal.II/numerics/vector_tools.templates.h +++ b/deal.II/include/deal.II/numerics/vector_tools.templates.h @@ -259,6 +259,7 @@ namespace VectorTools = function_values_scalar[fe_index][dof_to_rep_index_table[fe_index][i]]; } } + vec.compress(::dealii::VectorOperation::insert); } diff --git a/deal.II/source/distributed/solution_transfer.cc b/deal.II/source/distributed/solution_transfer.cc index 8022f743c3..11e46f6551 100644 --- a/deal.II/source/distributed/solution_transfer.cc +++ b/deal.II/source/distributed/solution_transfer.cc @@ -40,41 +40,6 @@ namespace parallel namespace distributed { - namespace - { - template - void compress_vector_insert(VECTOR & vec) - { - vec.compress(); - } - -#ifdef DEAL_II_USE_TRILINOS - void compress_vector_insert(TrilinosWrappers::Vector & vec) - { - vec.compress(Insert); - } - - void compress_vector_insert(TrilinosWrappers::BlockVector & vec) - { - for (unsigned int i=0;i SolutionTransfer::SolutionTransfer(const DH &dof) : @@ -206,10 +171,11 @@ namespace parallel std_cxx1x::_3, std_cxx1x::ref(all_out))); + for (typename std::vector::iterator it=all_out.begin(); it !=all_out.end(); ++it) - compress_vector_insert(*(*it)); + (*it)->compress(::dealii::VectorOperation::insert); input_vectors.clear(); } diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 55df9b2a4b..51befc6145 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -1922,7 +1922,7 @@ ConstraintMatrix::distribute (TrilinosWrappers::MPI::Vector &vec) const // constraints, so we need to explicitly // state, that the others are doing an // insert here: - vec.compress (Insert); + vec.compress (::dealii::VectorOperation::insert); } @@ -2016,7 +2016,7 @@ ConstraintMatrix::distribute (TrilinosWrappers::MPI::BlockVector &vec) const it->entries[i].second); vec(it->line) = new_value; } - vec.block(block).compress(Insert); + vec.block(block).compress(::dealii::VectorOperation::insert); } } diff --git a/deal.II/source/lac/petsc_matrix_base.cc b/deal.II/source/lac/petsc_matrix_base.cc index e0e3220c2f..605aecf2b0 100644 --- a/deal.II/source/lac/petsc_matrix_base.cc +++ b/deal.II/source/lac/petsc_matrix_base.cc @@ -275,7 +275,7 @@ namespace PETScWrappers void - MatrixBase::compress () + MatrixBase::compress (::dealii::VectorOperation::values operation) { // flush buffers int ierr; diff --git a/deal.II/source/lac/petsc_vector_base.cc b/deal.II/source/lac/petsc_vector_base.cc index 6820ff126a..77bff1b40d 100644 --- a/deal.II/source/lac/petsc_vector_base.cc +++ b/deal.II/source/lac/petsc_vector_base.cc @@ -177,7 +177,7 @@ namespace PETScWrappers VectorBase::VectorBase () : ghosted(false), - last_action (LastAction::none), + last_action (::dealii::VectorOperation::unknown), attained_ownership(true) {} @@ -188,7 +188,7 @@ namespace PETScWrappers Subscriptor (), ghosted(v.ghosted), ghost_indices(v.ghost_indices), - last_action (LastAction::none), + last_action (::dealii::VectorOperation::unknown), attained_ownership(true) { int ierr = VecDuplicate (v.vector, &vector); @@ -205,7 +205,7 @@ namespace PETScWrappers Subscriptor (), vector(v), ghosted(false), - last_action (LastAction::none), + last_action (::dealii::VectorOperation::unknown), attained_ownership(false) {} @@ -405,15 +405,14 @@ namespace PETScWrappers void - VectorBase::compress () + VectorBase::compress (::dealii::VectorOperation::values operation) { // note that one may think that we only need to do something - // if in fact the state is anything but LastAction::none. but + // if in fact the state is anything but last_action::unknown. but // that's not true: one frequently gets into situations where // only one processor (or a subset of processors) actually writes // something into a vector, but we still need to call - // VecAssemblyBegin/End on all processors, even those that are - // still in LastAction::none state + // VecAssemblyBegin/End on all processors. int ierr; ierr = VecAssemblyBegin(vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -422,7 +421,7 @@ namespace PETScWrappers // reset the last action field to indicate that we're back to // a pristine state - last_action = VectorBase::LastAction::none; + last_action = ::dealii::VectorOperation::unknown; } @@ -1120,7 +1119,7 @@ namespace PETScWrappers std::size_t VectorBase::memory_consumption () const { - std::size_t mem = sizeof(Vec)+sizeof(LastAction::Values) + std::size_t mem = sizeof(Vec)+sizeof(last_action) +MemoryConsumption::memory_consumption(ghosted) +MemoryConsumption::memory_consumption(ghost_indices); @@ -1145,14 +1144,13 @@ namespace PETScWrappers const PetscScalar *values, const bool add_values) { - Assert ((last_action == (add_values ? - LastAction::add : - LastAction::insert)) + ::dealii::VectorOperation::values action = (add_values ? + ::dealii::VectorOperation::add : + ::dealii::VectorOperation::insert); + Assert ((last_action == action) || - (last_action == LastAction::none), - internal::VectorReference::ExcWrongMode ((add_values ? - LastAction::add : - LastAction::insert), + (last_action == ::dealii::VectorOperation::unknown), + internal::VectorReference::ExcWrongMode (action, last_action)); // VecSetValues complains if we @@ -1181,9 +1179,7 @@ namespace PETScWrappers // set the mode here, independent of whether we have actually // written elements or whether the list was empty - last_action = (add_values ? - VectorBase::LastAction::add : - VectorBase::LastAction::insert); + last_action = action; } diff --git a/deal.II/source/lac/trilinos_block_sparse_matrix.cc b/deal.II/source/lac/trilinos_block_sparse_matrix.cc index a107de8656..e6452b6b8f 100644 --- a/deal.II/source/lac/trilinos_block_sparse_matrix.cc +++ b/deal.II/source/lac/trilinos_block_sparse_matrix.cc @@ -249,14 +249,6 @@ namespace TrilinosWrappers - void - BlockSparseMatrix::compress() - { - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) - this->block(r,c).compress(); - } - void diff --git a/deal.II/source/lac/trilinos_block_vector.cc b/deal.II/source/lac/trilinos_block_vector.cc index e15cca0972..3b3f513695 100644 --- a/deal.II/source/lac/trilinos_block_vector.cc +++ b/deal.II/source/lac/trilinos_block_vector.cc @@ -174,15 +174,6 @@ namespace TrilinosWrappers - void - BlockVector::compress (const Epetra_CombineMode last_action) - { - for (unsigned int i=0; i