From: kronbichler Date: Tue, 16 Sep 2008 09:36:14 +0000 (+0000) Subject: A few changes that make the updated TrilinosWrappers vector classes compatible with... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f08f02e142d2d63925649001abe731556d7bcab9;p=dealii-svn.git A few changes that make the updated TrilinosWrappers vector classes compatible with the directory deal.II/. git-svn-id: https://svn.dealii.org/trunk@16831 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/common/template-arguments.in b/deal.II/common/template-arguments.in index 5885944921..9548b9015d 100644 --- a/deal.II/common/template-arguments.in +++ b/deal.II/common/template-arguments.in @@ -14,9 +14,11 @@ SERIAL_VECTORS := { Vector; BlockVector; @DEAL_II_EXPAND_TRILINOS_VECTOR@; + @DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@; @DEAL_II_EXPAND_PETSC_VECTOR@; @DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR@; + @DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR@; @DEAL_II_EXPAND_PETSC_BLOCKVECTOR@; } diff --git a/deal.II/configure b/deal.II/configure index 3e61f2f770..e7312fa5a4 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -722,6 +722,8 @@ DEAL_II_PETSC_MPIUNI_LIB DEAL_II_DEFINE_DEAL_II_USE_PETSC DEAL_II_EXPAND_TRILINOS_VECTOR DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR +DEAL_II_EXPAND_TRILINOS_MPI_VECTOR +DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR USE_CONTRIB_TRILINOS DEAL_II_TRILINOS_DIR DEAL_II_TRILINOS_SHARED @@ -12049,6 +12051,8 @@ echo "$as_me: error: When building deal.II with shared libraries, Trilinos also DEAL_II_EXPAND_TRILINOS_VECTOR="TrilinosWrappers::Vector" DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR="TrilinosWrappers::BlockVector" + DEAL_II_EXPAND_TRILINOS_MPI_VECTOR="TrilinosWrappers::MPI::Vector" + DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR="TrilinosWrappers::MPI::BlockVector" if test "x$with_trilinos" = "x" ; then with_trilinos="yes" @@ -14711,6 +14715,8 @@ DEAL_II_PETSC_MPIUNI_LIB!$DEAL_II_PETSC_MPIUNI_LIB$ac_delim DEAL_II_DEFINE_DEAL_II_USE_PETSC!$DEAL_II_DEFINE_DEAL_II_USE_PETSC$ac_delim DEAL_II_EXPAND_TRILINOS_VECTOR!$DEAL_II_EXPAND_TRILINOS_VECTOR$ac_delim DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR!$DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR$ac_delim +DEAL_II_EXPAND_TRILINOS_MPI_VECTOR!$DEAL_II_EXPAND_TRILINOS_MPI_VECTOR$ac_delim +DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR!$DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR$ac_delim USE_CONTRIB_TRILINOS!$USE_CONTRIB_TRILINOS$ac_delim DEAL_II_TRILINOS_DIR!$DEAL_II_TRILINOS_DIR$ac_delim DEAL_II_TRILINOS_SHARED!$DEAL_II_TRILINOS_SHARED$ac_delim @@ -14735,7 +14741,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 29; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 31; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/deal.II/deal.II/include/fe/fe_values.h b/deal.II/deal.II/include/fe/fe_values.h index 1116ce6d82..25b540778e 100644 --- a/deal.II/deal.II/include/fe/fe_values.h +++ b/deal.II/deal.II/include/fe/fe_values.h @@ -1960,6 +1960,28 @@ class FEValuesBase : protected FEValuesData, void get_interpolated_dof_values (const TrilinosWrappers::BlockVector &in, Vector &out) const = 0; + /** + * Call + * @p get_interpolated_dof_values + * of the iterator with the + * given arguments. + */ + + virtual + void + get_interpolated_dof_values (const TrilinosWrappers::MPI::Vector &in, + Vector &out) const = 0; + + /** + * Call + * @p get_interpolated_dof_values + * of the iterator with the + * given arguments. + */ + virtual + void + get_interpolated_dof_values (const TrilinosWrappers::MPI::BlockVector &in, + Vector &out) const = 0; #endif }; @@ -2124,6 +2146,28 @@ class FEValuesBase : protected FEValuesData, void get_interpolated_dof_values (const TrilinosWrappers::BlockVector &in, Vector &out) const; + + /** + * Call + * @p get_interpolated_dof_values + * of the iterator with the + * given arguments. + */ + virtual + void + get_interpolated_dof_values (const TrilinosWrappers::MPI::Vector &in, + Vector &out) const; + + /** + * Call + * @p get_interpolated_dof_values + * of the iterator with the + * given arguments. + */ + virtual + void + get_interpolated_dof_values (const TrilinosWrappers::MPI::BlockVector &in, + Vector &out) const; #endif private: @@ -2333,6 +2377,28 @@ class FEValuesBase : protected FEValuesData, void get_interpolated_dof_values (const TrilinosWrappers::BlockVector &in, Vector &out) const; + + /** + * Call + * @p get_interpolated_dof_values + * of the iterator with the + * given arguments. + */ + virtual + void + get_interpolated_dof_values (const TrilinosWrappers::MPI::Vector &in, + Vector &out) const; + + /** + * Call + * @p get_interpolated_dof_values + * of the iterator with the + * given arguments. + */ + virtual + void + get_interpolated_dof_values (const TrilinosWrappers::MPI::BlockVector &in, + Vector &out) const; #endif private: diff --git a/deal.II/deal.II/include/numerics/matrices.h b/deal.II/deal.II/include/numerics/matrices.h index 9b8db14cba..540695fcd0 100644 --- a/deal.II/deal.II/include/numerics/matrices.h +++ b/deal.II/deal.II/include/numerics/matrices.h @@ -67,6 +67,11 @@ namespace TrilinosWrappers class Vector; class BlockSparseMatrix; class BlockVector; + namespace MPI + { + class Vector; + class BlockVector; + } } #endif @@ -1108,43 +1113,103 @@ class MatrixTools : public MatrixCreator #ifdef DEAL_II_USE_TRILINOS /** - * Apply dirichlet boundary conditions to - * the system matrix and vectors as - * described in the general - * documentation. This function works on - * the classes that are used to wrap - * Trilinos objects. + * Apply dirichlet boundary + * conditions to the system matrix + * and vectors as described in the + * general documentation. This + * function works on the classes + * that are used to wrap Trilinos + * objects. * - * Note that this function is not very - * efficient: it needs to alternatingly - * read and write into the matrix, a - * situation that Trilinos does not handle - * too well. In addition, we only get rid - * of rows corresponding to boundary - * nodes, but the corresponding case of - * deleting the respective columns - * (i.e. if @p eliminate_columns is @p - * true) is not presently implemented, - * and probably will never because it is - * too expensive without direct access to - * the Trilinos data structures. (This leads - * to the situation where the action - * indicates by the default value of the - * last argument is actually not - * implemented; that argument has - * true as its default value - * to stay consistent with the other - * functions of same name in this class.) - * A third reason against this function - * is that it doesn't handle the case - * where the matrix is distributed across - * an MPI system. + * Note that this function is not + * very efficient: it needs to + * alternatingly read and write + * into the matrix, a situation + * that Trilinos does not handle + * too well. In addition, we only + * get rid of rows corresponding to + * boundary nodes, but the + * corresponding case of deleting + * the respective columns (i.e. if + * @p eliminate_columns is @p true) + * is not presently implemented, + * and probably will never because + * it is too expensive without + * direct access to the Trilinos + * data structures. (This leads to + * the situation where the action + * indicates by the default value + * of the last argument is actually + * not implemented; that argument + * has true as its + * default value to stay consistent + * with the other functions of same + * name in this class.) A third + * reason against this function is + * that it doesn't handle the case + * where the matrix is distributed + * across an MPI system. + */ + static void + apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::SparseMatrix &matrix, + TrilinosWrappers::Vector &solution, + TrilinosWrappers::Vector &right_hand_side, + const bool eliminate_columns = true); + + /** + * This function does the same as + * the one above, except now + * working on block structures. + */ + static void + apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::BlockSparseMatrix &matrix, + TrilinosWrappers::BlockVector &solution, + TrilinosWrappers::BlockVector &right_hand_side, + const bool eliminate_columns = true); + + /** + * Apply dirichlet boundary + * conditions to the system matrix + * and vectors as described in the + * general documentation. This + * function works on the classes + * that are used to wrap Trilinos + * objects. + * + * Note that this function is not + * very efficient: it needs to + * alternatingly read and write + * into the matrix, a situation + * that Trilinos does not handle + * too well. In addition, we only + * get rid of rows corresponding to + * boundary nodes, but the + * corresponding case of deleting + * the respective columns (i.e. if + * @p eliminate_columns is @p true) + * is not presently implemented, + * and probably will never because + * it is too expensive without + * direct access to the Trilinos + * data structures. (This leads to + * the situation where the action + * indicates by the default value + * of the last argument is actually + * not implemented; that argument + * has true as its + * default value to stay consistent + * with the other functions of same + * name in this class.) This + * function does work on MPI vector + * types. */ static void apply_boundary_values (const std::map &boundary_values, TrilinosWrappers::SparseMatrix &matrix, - TrilinosWrappers::Vector &solution, - TrilinosWrappers::Vector &right_hand_side, + TrilinosWrappers::MPI::Vector &solution, + TrilinosWrappers::MPI::Vector &right_hand_side, const bool eliminate_columns = true); /** @@ -1155,8 +1220,8 @@ class MatrixTools : public MatrixCreator static void apply_boundary_values (const std::map &boundary_values, TrilinosWrappers::BlockSparseMatrix &matrix, - TrilinosWrappers::BlockVector &solution, - TrilinosWrappers::BlockVector &right_hand_side, + TrilinosWrappers::MPI::BlockVector &solution, + TrilinosWrappers::MPI::BlockVector &right_hand_side, const bool eliminate_columns = true); #endif diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 342d9ff716..348d11b051 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -1741,6 +1741,8 @@ VECTOR_FUNCTIONS(PETScWrappers::MPI::BlockVector); #ifdef DEAL_II_USE_TRILINOS VECTOR_FUNCTIONS(TrilinosWrappers::Vector); VECTOR_FUNCTIONS(TrilinosWrappers::BlockVector); +VECTOR_FUNCTIONS(TrilinosWrappers::MPI::Vector); +VECTOR_FUNCTIONS(TrilinosWrappers::MPI::BlockVector); #endif diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 670e31b5a1..dc37d675e7 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -188,6 +188,30 @@ get_interpolated_dof_values (const TrilinosWrappers::BlockVector &in, cell->get_interpolated_dof_values (in, out); } + + +template +template +void +FEValuesBase::CellIterator:: +get_interpolated_dof_values (const TrilinosWrappers::MPI::Vector &in, + Vector &out) const +{ + cell->get_interpolated_dof_values (in, out); +} + + + +template +template +void +FEValuesBase::CellIterator:: +get_interpolated_dof_values (const TrilinosWrappers::MPI::BlockVector &in, + Vector &out) const +{ + cell->get_interpolated_dof_values (in, out); +} + #endif @@ -340,6 +364,28 @@ get_interpolated_dof_values (const TrilinosWrappers::BlockVector &, Assert (false, ExcMessage (message_string)); } + + +template +void +FEValuesBase::TriaCellIterator:: +get_interpolated_dof_values (const TrilinosWrappers::MPI::Vector &, + Vector &) const +{ + Assert (false, ExcMessage (message_string)); +} + + + +template +void +FEValuesBase::TriaCellIterator:: +get_interpolated_dof_values (const TrilinosWrappers::MPI::BlockVector &, + Vector &) const +{ + Assert (false, ExcMessage (message_string)); +} + #endif diff --git a/deal.II/deal.II/source/numerics/error_estimator.cc b/deal.II/deal.II/source/numerics/error_estimator.cc index 89ec089838..4abda8a0d8 100644 --- a/deal.II/deal.II/source/numerics/error_estimator.cc +++ b/deal.II/deal.II/source/numerics/error_estimator.cc @@ -1675,6 +1675,12 @@ INSTANTIATE(TrilinosWrappers::BlockVector,DoFHandler); INSTANTIATE(TrilinosWrappers::Vector,hp::DoFHandler); INSTANTIATE(TrilinosWrappers::BlockVector,hp::DoFHandler); + +INSTANTIATE(TrilinosWrappers::MPI::Vector,DoFHandler); +INSTANTIATE(TrilinosWrappers::MPI::BlockVector,DoFHandler); + +INSTANTIATE(TrilinosWrappers::MPI::Vector,hp::DoFHandler); +INSTANTIATE(TrilinosWrappers::MPI::BlockVector,hp::DoFHandler); #endif #undef INSTANTIATE diff --git a/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc b/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc index 9fcf748c6c..869ad7104f 100644 --- a/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc +++ b/deal.II/deal.II/source/numerics/matrices.all_dimensions.cc @@ -695,7 +695,7 @@ namespace TrilinosWrappers TrilinosMatrix &matrix, TrilinosVector &solution, TrilinosVector &right_hand_side, - const bool eliminate_columns) + const bool eliminate_columns) { Assert (eliminate_columns == false, ExcNotImplemented()); @@ -796,6 +796,85 @@ namespace TrilinosWrappers solution.compress (); right_hand_side.compress (); } + + + + template + void + apply_block_boundary_values (const std::map &boundary_values, + TrilinosMatrix &matrix, + TrilinosBlockVector &solution, + TrilinosBlockVector &right_hand_side, + const bool eliminate_columns) + { + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + + const unsigned int n_blocks = matrix.n_block_rows(); + + matrix.compress(); + + // We need to find the subdivision + // into blocks for the boundary values. + // To this end, generate a vector of + // maps with the respective indices. + std::vector > block_boundary_values(n_blocks); + { + int offset = 0, block=0; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + { + if (dof->first >= matrix.block(block,0).m() + offset) + { + offset += matrix.block(block,0).m(); + block++; + } + const unsigned int index = dof->first - offset; + block_boundary_values[block].insert( + std::pair (index,dof->second)); + } + } + + // Now call the non-block variants on + // the diagonal subblocks and the + // solution/rhs. + for (unsigned int block=0; block local_range + = matrix.block(block_m,0).local_range(); + + std::vector constrained_rows; + for (std::map::const_iterator + dof = block_boundary_values[block_m].begin(); + dof != block_boundary_values[block_m].end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + constrained_rows.push_back (dof->first); + + for (unsigned int block_n=0; block_n &boundary_values, TrilinosWrappers::SparseMatrix &matrix, - TrilinosWrappers::Vector &solution, - TrilinosWrappers::Vector &right_hand_side, + TrilinosWrappers::Vector &solution, + TrilinosWrappers::Vector &right_hand_side, const bool eliminate_columns) { // simply redirect to the generic function @@ -814,6 +893,24 @@ apply_boundary_values (const std::map &boundary_values, right_hand_side, eliminate_columns); } + + +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::SparseMatrix &matrix, + TrilinosWrappers::MPI::Vector &solution, + TrilinosWrappers::MPI::Vector &right_hand_side, + const bool eliminate_columns) +{ + // simply redirect to the generic function + // used for both trilinos matrix types + TrilinosWrappers::apply_boundary_values (boundary_values, matrix, solution, + right_hand_side, eliminate_columns); +} + + + void MatrixTools:: apply_boundary_values (const std::map &boundary_values, @@ -822,71 +919,24 @@ apply_boundary_values (const std::map &boundary_values, TrilinosWrappers::BlockVector &right_hand_side, const bool eliminate_columns) { - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.n(), solution.size())); - Assert (matrix.n_block_rows() == matrix.n_block_cols(), - ExcNotQuadratic()); - - const unsigned int n_blocks = matrix.n_block_rows(); + TrilinosWrappers::apply_block_boundary_values (boundary_values, matrix, + solution, right_hand_side, + eliminate_columns); +} - matrix.compress(); - // We need to find the subdivision - // into blocks for the boundary values. - // To this end, generate a vector of - // maps with the respective indices. - std::vector > block_boundary_values(n_blocks); - { - int offset = 0, block=0; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - { - if (dof->first >= matrix.block(block,0).m() + offset) - { - offset += matrix.block(block,0).m(); - block++; - } - const unsigned int index = dof->first - offset; - block_boundary_values[block].insert(std::pair (index,dof->second)); - } - } - - // Now call the non-block variants on - // the diagonal subblocks and the - // solution/rhs. - for (unsigned int block=0; block local_range - = matrix.block(block_m,0).local_range(); - - std::vector constrained_rows; - for (std::map::const_iterator - dof = block_boundary_values[block_m].begin(); - dof != block_boundary_values[block_m].end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - constrained_rows.push_back (dof->first); - - for (unsigned int block_n=0; block_n &boundary_values, + TrilinosWrappers::BlockSparseMatrix &matrix, + TrilinosWrappers::MPI::BlockVector &solution, + TrilinosWrappers::MPI::BlockVector &right_hand_side, + const bool eliminate_columns) +{ + TrilinosWrappers::apply_block_boundary_values (boundary_values, matrix, + solution, right_hand_side, + eliminate_columns); } #endif diff --git a/deal.II/deal.II/source/numerics/solution_transfer.cc b/deal.II/deal.II/source/numerics/solution_transfer.cc index 35660fb7e9..3cf0eef087 100644 --- a/deal.II/deal.II/source/numerics/solution_transfer.cc +++ b/deal.II/deal.II/source/numerics/solution_transfer.cc @@ -465,6 +465,12 @@ template class SolutionTransfer >; template class SolutionTransfer >; + +template class SolutionTransfer >; +template class SolutionTransfer >; + +template class SolutionTransfer >; +template class SolutionTransfer >; #endif /*---------------------------- solution_transfer.cc ----------------------*/ diff --git a/deal.II/lac/source/trilinos_block_vector.cc b/deal.II/lac/source/trilinos_block_vector.cc index b54adda76d..864f0b40de 100644 --- a/deal.II/lac/source/trilinos_block_vector.cc +++ b/deal.II/lac/source/trilinos_block_vector.cc @@ -199,11 +199,11 @@ namespace TrilinosWrappers BlockVector::reinit (const unsigned int num_blocks) { std::vector block_sizes (num_blocks, 0); - this->block_indices.reinit (block_sizes); - if (this->components.size() != this->n_blocks()) - this->components.resize(this->n_blocks()); + block_indices.reinit (block_sizes); + if (components.size() != n_blocks()) + components.resize(n_blocks()); - for (unsigned int i=0;in_blocks();++i) + for (unsigned int i=0;i block_sizes (v.n_blocks(), 0); + block_indices.reinit (block_sizes); + if (components.size() != n_blocks()) + components.resize(n_blocks()); + } for (unsigned int i=0; in_blocks(); ++i) this->components[i] = v.block(i); + collect_sizes(); + return *this; }