From: kronbichler Date: Fri, 13 Nov 2009 21:13:36 +0000 (+0000) Subject: Cleanup Trilinos matrix: Small update in comments. Do not provide functions that... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77d24ea96ca6b0ee08e7ed5a12d3a635ecbfc997;p=dealii-svn.git Cleanup Trilinos matrix: Small update in comments. Do not provide functions that cannot reasonably implemented like the check for symmetry. Implement memory consumption. git-svn-id: https://svn.dealii.org/trunk@20111 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/trilinos_sparse_matrix.h b/deal.II/lac/include/lac/trilinos_sparse_matrix.h index 0e53779ccb..e40e8caace 100644 --- a/deal.II/lac/include/lac/trilinos_sparse_matrix.h +++ b/deal.II/lac/include/lac/trilinos_sparse_matrix.h @@ -406,11 +406,11 @@ namespace TrilinosWrappers * the matrix is going to be * distributed among different * processors. This function works in - * parallel, too, but it is + * %parallel, too, but it is * recommended to manually specify * the %parallel partioning of the * matrix using an Epetra_Map. When - * run in parallel, it is currently + * run in %parallel, it is currently * necessary that each processor * holds the sparsity_pattern * structure because each processor @@ -555,7 +555,7 @@ namespace TrilinosWrappers * matrix-vector products. This is a * collective operation, i.e., it * needs to be run on all processors - * when used in parallel. + * when used in %parallel. * * See @ref GlossCompress "Compressing distributed objects" * for more information. @@ -627,7 +627,7 @@ namespace TrilinosWrappers * columns. This interface is meant * to be used for generating * rectangular matrices, where one - * map describes the parallel + * map describes the %parallel * partitioning of the dofs * associated with the matrix rows * and the other one the partitioning @@ -660,7 +660,7 @@ namespace TrilinosWrappers * columns. This interface is meant * to be used for generating * rectangular matrices, where one - * map specifies the parallel + * map specifies the %parallel * distribution of degrees of freedom * associated with matrix rows and * the second one specifies the @@ -699,7 +699,7 @@ namespace TrilinosWrappers * rectangular matrix) are the natural * way to initialize the matrix size, * its distribution among the MPI - * processes (if run in parallel) as + * processes (if run in %parallel) as * well as the locatoin of non-zero * elements. Trilinos stores the * sparsity pattern internally, so it @@ -769,7 +769,7 @@ namespace TrilinosWrappers * matrix argument, this function * takes a %parallel partitioning * specified by the user instead of - * internally generating one. + * internally generating it. * * The optional parameter * copy_values decides @@ -906,7 +906,7 @@ namespace TrilinosWrappers * columns. This interface is meant * to be used for generating * rectangular matrices, where one - * map specifies the parallel + * map specifies the %parallel * distribution of degrees of freedom * associated with matrix rows and * the second one specifies the @@ -948,7 +948,7 @@ namespace TrilinosWrappers * natural way to initialize the * matrix size, its distribution * among the MPI processes (if run in - * parallel) as well as the locatoin + * %parallel) as well as the locatoin * of non-zero elements. Trilinos * stores the sparsity pattern * internally, so it won't be needed @@ -1020,7 +1020,7 @@ namespace TrilinosWrappers * matrix argument, this function * takes a %parallel partitioning * specified by the user instead of - * internally generating one. + * internally generating it. * * The optional parameter * copy_values decides @@ -1141,28 +1141,13 @@ namespace TrilinosWrappers */ unsigned int row_length (const unsigned int row) const; - /** - * Test whether a matrix is - * symmetric. Default - * tolerance is zero. TODO: - * Not implemented. - */ - bool is_symmetric (const double tol = 0.0) const; - - /** - * Test whether a matrix is - * Hermitian, i.e. it is the - * complex conjugate of its - * transpose. TODO: Not - * implemented. - */ - bool is_hermitian () const; - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. Currently not - * implemented for this class. + * Determine an estimate for the memory + * consumption (in bytes) of this + * object. Note that only the memory + * reserved on the current processor is + * returned in case this is called in + * an MPI-based program. */ unsigned int memory_consumption () const; @@ -1456,14 +1441,10 @@ namespace TrilinosWrappers SparseMatrix & operator /= (const TrilinosScalar factor); /** - * Copy the given matrix to this - * one. - * - * The function returns a - * reference to *this. + * Copy the given (Trilinos) matrix + * (sparsity pattern and entries). */ - SparseMatrix & - copy_from (const SparseMatrix &source); + void copy_from (const SparseMatrix &source); /** * Add matrix scaled by diff --git a/deal.II/lac/source/trilinos_sparse_matrix.cc b/deal.II/lac/source/trilinos_sparse_matrix.cc index f38d807112..695c0791cd 100644 --- a/deal.II/lac/source/trilinos_sparse_matrix.cc +++ b/deal.II/lac/source/trilinos_sparse_matrix.cc @@ -327,11 +327,9 @@ namespace TrilinosWrappers - SparseMatrix & + void SparseMatrix::copy_from (const SparseMatrix &m) { - column_space_map = std::auto_ptr - (new Epetra_Map (m.domain_partitioner())); // check whether we need to update the // partitioner or can just copy the data: @@ -340,10 +338,14 @@ namespace TrilinosWrappers if (local_range() == m.local_range()) *matrix = *m.matrix; else - matrix = std::auto_ptr - (new Epetra_FECrsMatrix(*m.matrix)); + { + column_space_map = std::auto_ptr + (new Epetra_Map (m.domain_partitioner())); + matrix = std::auto_ptr + (new Epetra_FECrsMatrix(*m.matrix)); + } + compress(); - return *this; } @@ -1368,27 +1370,6 @@ namespace TrilinosWrappers - bool - SparseMatrix::is_symmetric (const double tolerance) const - { - (void)tolerance; - - Assert (false, ExcNotImplemented()); - - return false; - } - - - - bool - SparseMatrix::is_hermitian () const - { - Assert (false, ExcNotImplemented()); - return false; - } - - - void SparseMatrix::write_ascii () { @@ -1426,6 +1407,18 @@ namespace TrilinosWrappers + unsigned int + SparseMatrix::memory_consumption () const + { + unsigned int static_memory = sizeof(this) + sizeof (*matrix) + + sizeof(*matrix->Graph().DataPtr()); + return ((sizeof(TrilinosScalar)+sizeof(int))*matrix->NumMyNonzeros() + + sizeof(int)*local_size() + + static_memory); + } + + + // explicit instantiations //