include/deal.II/lac/trilinos_sparsity_pattern.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: trilinos_sparsity_pattern.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__trilinos_sparsity_pattern_h
00013 #define __deal2__trilinos_sparsity_pattern_h
00014 
00015 
00016 #include <deal.II/base/config.h>
00017 
00018 #ifdef DEAL_II_USE_TRILINOS
00019 
00020 #  include <deal.II/base/subscriptor.h>
00021 #  include <deal.II/base/index_set.h>
00022 #  include <deal.II/lac/exceptions.h>
00023 
00024 #  include <vector>
00025 #  include <cmath>
00026 #  include <memory>
00027 
00028 #  include <deal.II/base/std_cxx1x/shared_ptr.h>
00029 
00030 #  include <Epetra_FECrsGraph.h>
00031 #  include <Epetra_Map.h>
00032 #  ifdef DEAL_II_COMPILER_SUPPORTS_MPI
00033 #    include <Epetra_MpiComm.h>
00034 #    include "mpi.h"
00035 #  else
00036 #    include "Epetra_SerialComm.h"
00037 #  endif
00038 
00039 DEAL_II_NAMESPACE_OPEN
00040 
00041                                    // forward declarations
00042 class SparsityPattern;
00043 class CompressedSparsityPattern;
00044 class CompressedSetSparsityPattern;
00045 class CompressedSimpleSparsityPattern;
00046 
00047 namespace TrilinosWrappers
00048 {
00049                                    // forward declarations
00050   class SparsityPattern;
00051 
00052   namespace SparsityPatternIterators
00053   {
00061     class const_iterator
00062     {
00063       private:
00067         class Accessor
00068         {
00069           public:
00076             Accessor (const SparsityPattern *sparsity_pattern,
00077                       const unsigned int     row,
00078                       const unsigned int     index);
00079 
00084             unsigned int row() const;
00085 
00090             unsigned int index() const;
00091 
00096             unsigned int column() const;
00097 
00101             DeclException0 (ExcBeyondEndOfSparsityPattern);
00102 
00106             DeclException3 (ExcAccessToNonlocalRow,
00107                             int, int, int,
00108                             << "You tried to access row " << arg1
00109                             << " of a distributed sparsity pattern, "
00110                             << " but only rows " << arg2 << " through " << arg3
00111                             << " are stored locally and can be accessed.");
00112 
00113           private:
00117             mutable SparsityPattern *sparsity_pattern;
00118 
00122             unsigned int a_row;
00123 
00127             unsigned int a_index;
00128 
00154             std_cxx1x::shared_ptr<const std::vector<unsigned int> > colnum_cache;
00155 
00164             void visit_present_row ();
00165 
00170             friend class const_iterator;
00171         };
00172 
00173       public:
00174 
00181         const_iterator (const SparsityPattern *sparsity_pattern,
00182                         const unsigned int     row,
00183                         const unsigned int     index);
00184 
00188         const_iterator& operator++ ();
00189 
00193         const_iterator operator++ (int);
00194 
00198         const Accessor& operator* () const;
00199 
00203         const Accessor* operator-> () const;
00204 
00210         bool operator == (const const_iterator&) const;
00211 
00215         bool operator != (const const_iterator&) const;
00216 
00225         bool operator < (const const_iterator&) const;
00226 
00230         DeclException2 (ExcInvalidIndexWithinRow,
00231                         int, int,
00232                         << "Attempt to access element " << arg2
00233                         << " of row " << arg1
00234                         << " which doesn't have that many elements.");
00235 
00236       private:
00241         Accessor accessor;
00242 
00243         friend class TrilinosWrappers::SparsityPattern;
00244     };
00245 
00246   }
00247 
00248 
00269   class SparsityPattern : public Subscriptor
00270   {
00271     public:
00272 
00277       typedef SparsityPatternIterators::const_iterator const_iterator;
00278 
00288       SparsityPattern ();
00289 
00317       SparsityPattern (const unsigned int  m,
00318                        const unsigned int  n,
00319                        const unsigned int  n_entries_per_row = 0);
00320 
00334       SparsityPattern (const unsigned int               m,
00335                        const unsigned int               n,
00336                        const std::vector<unsigned int> &n_entries_per_row);
00337 
00343       SparsityPattern (const SparsityPattern &input_sparsity_pattern);
00344 
00350       virtual ~SparsityPattern ();
00351 
00371       void
00372       reinit (const unsigned int  m,
00373               const unsigned int  n,
00374               const unsigned int  n_entries_per_row = 0);
00375 
00388       void
00389       reinit (const unsigned int               m,
00390               const unsigned int               n,
00391               const std::vector<unsigned int> &n_entries_per_row);
00392 
00398       void
00399       copy_from (const SparsityPattern &input_sparsity_pattern);
00400 
00408       template<typename SparsityType>
00409       void
00410       copy_from (const SparsityType &nontrilinos_sparsity_pattern);
00411 
00423       SparsityPattern & operator = (const SparsityPattern &input_sparsity_pattern);
00424 
00435       void clear ();
00436 
00454       void compress ();
00456 
00460 
00484       SparsityPattern (const Epetra_Map   &parallel_partitioning,
00485                        const unsigned int  n_entries_per_row = 0);
00486 
00506       SparsityPattern (const Epetra_Map                &parallel_partitioning,
00507                        const std::vector<unsigned int> &n_entries_per_row);
00508 
00537       SparsityPattern (const Epetra_Map   &row_parallel_partitioning,
00538                        const Epetra_Map   &col_parallel_partitioning,
00539                        const unsigned int  n_entries_per_row = 0);
00540 
00561       SparsityPattern (const Epetra_Map                &row_parallel_partitioning,
00562                        const Epetra_Map                &col_parallel_partitioning,
00563                        const std::vector<unsigned int> &n_entries_per_row);
00564 
00590       void
00591       reinit (const Epetra_Map   &parallel_partitioning,
00592               const unsigned int  n_entries_per_row = 0);
00593 
00612       void
00613       reinit (const Epetra_Map                &parallel_partitioning,
00614               const std::vector<unsigned int> &n_entries_per_row);
00615 
00644       void
00645       reinit (const Epetra_Map   &row_parallel_partitioning,
00646               const Epetra_Map   &col_parallel_partitioning,
00647               const unsigned int  n_entries_per_row = 0);
00648 
00672       void
00673       reinit (const Epetra_Map                &row_parallel_partitioning,
00674               const Epetra_Map                &col_parallel_partitioning,
00675               const std::vector<unsigned int> &n_entries_per_row);
00676 
00692       template<typename SparsityType>
00693       void
00694       reinit (const Epetra_Map   &row_parallel_partitioning,
00695               const Epetra_Map   &col_parallel_partitioning,
00696               const SparsityType &nontrilinos_sparsity_pattern,
00697               const bool          exchange_data = false);
00698 
00714       template<typename SparsityType>
00715       void
00716       reinit (const Epetra_Map   &parallel_partitioning,
00717               const SparsityType &nontrilinos_sparsity_pattern,
00718               const bool          exchange_data = false);
00720 
00724 
00746       SparsityPattern (const IndexSet     &parallel_partitioning,
00747                        const MPI_Comm     &communicator = MPI_COMM_WORLD,
00748                        const unsigned int  n_entries_per_row = 0);
00749 
00769       SparsityPattern (const IndexSet                  &parallel_partitioning,
00770                        const MPI_Comm                  &communicator,
00771                        const std::vector<unsigned int> &n_entries_per_row);
00772 
00796       SparsityPattern (const IndexSet     &row_parallel_partitioning,
00797                        const IndexSet     &col_parallel_partitioning,
00798                        const MPI_Comm     &communicator = MPI_COMM_WORLD,
00799                        const unsigned int  n_entries_per_row = 0);
00800 
00821       SparsityPattern (const IndexSet                  &row_parallel_partitioning,
00822                        const IndexSet                  &col_parallel_partitioning,
00823                        const MPI_Comm                  &communicator,
00824                        const std::vector<unsigned int> &n_entries_per_row);
00825 
00852       void
00853       reinit (const IndexSet     &parallel_partitioning,
00854               const MPI_Comm     &communicator = MPI_COMM_WORLD,
00855               const unsigned int  n_entries_per_row = 0);
00856 
00875       void
00876       reinit (const IndexSet                  &parallel_partitioning,
00877               const MPI_Comm                  &communicator,
00878               const std::vector<unsigned int> &n_entries_per_row);
00879 
00909       void
00910       reinit (const IndexSet     &row_parallel_partitioning,
00911               const IndexSet     &col_parallel_partitioning,
00912               const MPI_Comm     &communicator = MPI_COMM_WORLD,
00913               const unsigned int  n_entries_per_row = 0);
00914 
00922       void
00923       reinit (const IndexSet                  &row_parallel_partitioning,
00924               const IndexSet                  &col_parallel_partitioning,
00925               const MPI_Comm                  &communicator,
00926               const std::vector<unsigned int> &n_entries_per_row);
00927 
00944       template<typename SparsityType>
00945       void
00946       reinit (const IndexSet     &row_parallel_partitioning,
00947               const IndexSet     &col_parallel_partitioning,
00948               const SparsityType &nontrilinos_sparsity_pattern,
00949               const MPI_Comm     &communicator = MPI_COMM_WORLD,
00950               const bool          exchange_data = false);
00951 
00967       template<typename SparsityType>
00968       void
00969       reinit (const IndexSet     &parallel_partitioning,
00970               const SparsityType &nontrilinos_sparsity_pattern,
00971               const MPI_Comm     &communicator = MPI_COMM_WORLD,
00972               const bool          exchange_data = false);
00974 
00978 
00986       bool is_compressed () const;
00987 
00993       unsigned int max_entries_per_row () const;
00994 
00999       unsigned int n_rows () const;
01000 
01005       unsigned int n_cols () const;
01006 
01020       unsigned int local_size () const;
01021 
01036       std::pair<unsigned int, unsigned int>
01037         local_range () const;
01038 
01044       bool in_local_range (const unsigned int index) const;
01045 
01050       unsigned int n_nonzero_elements () const;
01051 
01056       unsigned int row_length (const unsigned int row) const;
01057 
01069       unsigned int bandwidth () const;
01070 
01077       bool empty () const;
01078 
01085       bool exists (const unsigned int i,
01086                    const unsigned int j) const;
01087 
01094       std::size_t memory_consumption () const;
01095 
01097 
01105       void add (const unsigned int i,
01106                 const unsigned int j);
01107 
01108 
01113       template <typename ForwardIterator>
01114       void add_entries (const unsigned int row,
01115                         ForwardIterator    begin,
01116                         ForwardIterator    end,
01117                         const bool         indices_are_sorted = false);
01119 
01123 
01130       const Epetra_FECrsGraph & trilinos_sparsity_pattern () const;
01131 
01142       const Epetra_Map & domain_partitioner () const;
01143 
01153       const Epetra_Map & range_partitioner () const;
01154 
01162       const Epetra_Map & row_partitioner () const;
01163 
01174       const Epetra_Map & col_partitioner () const;
01175 
01181       const Epetra_Comm & trilinos_communicator () const;
01183 
01187 
01192       const_iterator begin () const;
01193 
01197       const_iterator end () const;
01198 
01212       const_iterator begin (const unsigned int r) const;
01213 
01229       const_iterator end (const unsigned int r) const;
01230 
01232 
01236 
01246       void write_ascii ();
01247 
01260       void print (std::ostream &out,
01261                   const bool    write_extended_trilinos_info = false) const;
01262 
01288       void print_gnuplot (std::ostream &out) const;
01289 
01291 
01296       DeclException1 (ExcTrilinosError,
01297                       int,
01298                       << "An error with error number " << arg1
01299                       << " occured while calling a Trilinos function");
01300 
01304       DeclException2 (ExcInvalidIndex,
01305                       int, int,
01306                       << "The entry with index <" << arg1 << ',' << arg2
01307                       << "> does not exist.");
01308 
01312       DeclException0 (ExcSourceEqualsDestination);
01313 
01317       DeclException4 (ExcAccessToNonLocalElement,
01318                       int, int, int, int,
01319                       << "You tried to access element (" << arg1
01320                       << "/" << arg2 << ")"
01321                       << " of a distributed matrix, but only rows "
01322                       << arg3 << " through " << arg4
01323                       << " are stored locally and can be accessed.");
01324 
01328       DeclException2 (ExcAccessToNonPresentElement,
01329                       int, int,
01330                       << "You tried to access element (" << arg1
01331                       << "/" << arg2 << ")"
01332                       << " of a sparse matrix, but it appears to not"
01333                       << " exist in the Trilinos sparsity pattern.");
01335     private:
01336 
01344       std_cxx1x::shared_ptr<Epetra_Map> column_space_map;
01345 
01351       bool compressed;
01352 
01360       std_cxx1x::shared_ptr<Epetra_FECrsGraph> graph;
01361 
01362       friend class SparsityPatternIterators::const_iterator;
01363       friend class SparsityPatternIterators::const_iterator::Accessor;
01364   };
01365 
01366 
01367 
01368 // -------------------------- inline and template functions ----------------------
01369 
01370 
01371 #ifndef DOXYGEN
01372 
01373   namespace SparsityPatternIterators
01374   {
01375 
01376     inline
01377     const_iterator::Accessor::
01378     Accessor (const SparsityPattern *sp,
01379               const unsigned int     row,
01380               const unsigned int     index)
01381                     :
01382                     sparsity_pattern(const_cast<SparsityPattern*>(sp)),
01383                     a_row(row),
01384                     a_index(index)
01385     {
01386       visit_present_row ();
01387     }
01388 
01389 
01390     inline
01391     unsigned int
01392     const_iterator::Accessor::row() const
01393     {
01394       Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern());
01395       return a_row;
01396     }
01397 
01398 
01399 
01400     inline
01401     unsigned int
01402     const_iterator::Accessor::column() const
01403     {
01404       Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern());
01405       return (*colnum_cache)[a_index];
01406     }
01407 
01408 
01409 
01410     inline
01411     unsigned int
01412     const_iterator::Accessor::index() const
01413     {
01414       Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern());
01415       return a_index;
01416     }
01417 
01418 
01419 
01420     inline
01421     const_iterator::
01422     const_iterator(const SparsityPattern *sp,
01423                    const unsigned int     row,
01424                    const unsigned int     index)
01425                     :
01426                     accessor(sp, row, index)
01427     {}
01428 
01429 
01430 
01431     inline
01432     const_iterator &
01433     const_iterator::operator++ ()
01434     {
01435       Assert (accessor.a_row < accessor.sparsity_pattern->n_rows(),
01436               ExcIteratorPastEnd());
01437 
01438       ++accessor.a_index;
01439 
01440                                         // If at end of line: do one
01441                                         // step, then cycle until we
01442                                         // find a row with a nonzero
01443                                         // number of entries.
01444       if (accessor.a_index >= accessor.colnum_cache->size())
01445         {
01446           accessor.a_index = 0;
01447           ++accessor.a_row;
01448 
01449           while ((accessor.a_row < accessor.sparsity_pattern->n_rows())
01450                  &&
01451                  (accessor.sparsity_pattern->row_length(accessor.a_row) == 0))
01452             ++accessor.a_row;
01453 
01454           accessor.visit_present_row();
01455         }
01456       return *this;
01457     }
01458 
01459 
01460 
01461     inline
01462     const_iterator
01463     const_iterator::operator++ (int)
01464     {
01465       const const_iterator old_state = *this;
01466       ++(*this);
01467       return old_state;
01468     }
01469 
01470 
01471 
01472     inline
01473     const const_iterator::Accessor &
01474     const_iterator::operator* () const
01475     {
01476       return accessor;
01477     }
01478 
01479 
01480 
01481     inline
01482     const const_iterator::Accessor *
01483     const_iterator::operator-> () const
01484     {
01485       return &accessor;
01486     }
01487 
01488 
01489 
01490     inline
01491     bool
01492     const_iterator::
01493     operator == (const const_iterator& other) const
01494     {
01495       return (accessor.a_row == other.accessor.a_row &&
01496               accessor.a_index == other.accessor.a_index);
01497     }
01498 
01499 
01500 
01501     inline
01502     bool
01503     const_iterator::
01504     operator != (const const_iterator& other) const
01505     {
01506       return ! (*this == other);
01507     }
01508 
01509 
01510 
01511     inline
01512     bool
01513     const_iterator::
01514     operator < (const const_iterator& other) const
01515     {
01516       return (accessor.row() < other.accessor.row() ||
01517               (accessor.row() == other.accessor.row() &&
01518                accessor.index() < other.accessor.index()));
01519     }
01520 
01521   }
01522 
01523 
01524 
01525   inline
01526   SparsityPattern::const_iterator
01527   SparsityPattern::begin() const
01528   {
01529     return const_iterator(this, 0, 0);
01530   }
01531 
01532 
01533 
01534   inline
01535   SparsityPattern::const_iterator
01536   SparsityPattern::end() const
01537   {
01538     return const_iterator(this, n_rows(), 0);
01539   }
01540 
01541 
01542 
01543   inline
01544   SparsityPattern::const_iterator
01545   SparsityPattern::begin(const unsigned int r) const
01546   {
01547     Assert (r < n_rows(), ExcIndexRange(r, 0, n_rows()));
01548     if (row_length(r) > 0)
01549       return const_iterator(this, r, 0);
01550     else
01551       return end (r);
01552   }
01553 
01554 
01555 
01556   inline
01557   SparsityPattern::const_iterator
01558   SparsityPattern::end(const unsigned int r) const
01559   {
01560     Assert (r < n_rows(), ExcIndexRange(r, 0, n_rows()));
01561 
01562                                      // place the iterator on the first entry
01563                                      // past this line, or at the end of the
01564                                      // matrix
01565     for (unsigned int i=r+1; i<n_rows(); ++i)
01566       if (row_length(i) > 0)
01567         return const_iterator(this, i, 0);
01568 
01569                                      // if there is no such line, then take the
01570                                      // end iterator of the matrix
01571     return end();
01572   }
01573 
01574 
01575 
01576   inline
01577   bool
01578   SparsityPattern::in_local_range (const unsigned int index) const
01579   {
01580     int begin, end;
01581     begin = graph->RowMap().MinMyGID();
01582     end = graph->RowMap().MaxMyGID()+1;
01583 
01584     return ((index >= static_cast<unsigned int>(begin)) &&
01585             (index < static_cast<unsigned int>(end)));
01586   }
01587 
01588 
01589 
01590   inline
01591   bool
01592   SparsityPattern::is_compressed () const
01593   {
01594     return compressed;
01595   }
01596 
01597 
01598 
01599   inline
01600   bool
01601   SparsityPattern::empty () const
01602   {
01603     return ((n_rows() == 0) && (n_cols() == 0));
01604   }
01605 
01606 
01607 
01608   inline
01609   void
01610   SparsityPattern::add (const unsigned int i,
01611                         const unsigned int j)
01612   {
01613     add_entries (i, &j, &j+1);
01614   }
01615 
01616 
01617 
01618   template <typename ForwardIterator>
01619   inline
01620   void
01621   SparsityPattern::add_entries (const unsigned int row,
01622                                 ForwardIterator    begin,
01623                                 ForwardIterator    end,
01624                                 const bool         /*indices_are_sorted*/)
01625   {
01626     if (begin == end)
01627       return;
01628 
01629     int * col_index_ptr = (int*)(&*begin);
01630     const int n_cols = static_cast<int>(end - begin);
01631     compressed = false;
01632 
01633     const int ierr = graph->InsertGlobalIndices (1, (int*)&row,
01634                                                  n_cols, col_index_ptr);
01635 
01636     AssertThrow (ierr >= 0, ExcTrilinosError(ierr));
01637   }
01638 
01639 
01640 
01641   inline
01642   const Epetra_FECrsGraph &
01643   SparsityPattern::trilinos_sparsity_pattern () const
01644   {
01645     return *graph;
01646   }
01647 
01648 
01649 
01650   inline
01651   const Epetra_Map &
01652   SparsityPattern::domain_partitioner () const
01653   {
01654     return static_cast<const Epetra_Map&>(graph->DomainMap());
01655   }
01656 
01657 
01658 
01659   inline
01660   const Epetra_Map &
01661   SparsityPattern::range_partitioner () const
01662   {
01663     return static_cast<const Epetra_Map&>(graph->RangeMap());
01664   }
01665 
01666 
01667 
01668   inline
01669   const Epetra_Map &
01670   SparsityPattern::row_partitioner () const
01671   {
01672     return static_cast<const Epetra_Map&>(graph->RowMap());
01673   }
01674 
01675 
01676 
01677   inline
01678   const Epetra_Map &
01679   SparsityPattern::col_partitioner () const
01680   {
01681     return static_cast<const Epetra_Map&>(graph->ColMap());
01682   }
01683 
01684 
01685 
01686   inline
01687   const Epetra_Comm &
01688   SparsityPattern::trilinos_communicator () const
01689   {
01690     return graph->RangeMap().Comm();
01691   }
01692 
01693 
01694 
01695   inline
01696   SparsityPattern::SparsityPattern  (const IndexSet     &parallel_partitioning,
01697                                      const MPI_Comm     &communicator,
01698                                      const unsigned int  n_entries_per_row)
01699                   :
01700                   compressed (false)
01701   {
01702     Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator,
01703                                                               false);
01704     reinit (map, map, n_entries_per_row);
01705   }
01706 
01707 
01708 
01709   inline
01710   SparsityPattern::SparsityPattern  (const IndexSet     &parallel_partitioning,
01711                                      const MPI_Comm     &communicator,
01712                                      const std::vector<unsigned int> &n_entries_per_row)
01713                   :
01714                   compressed (false)
01715   {
01716     Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator,
01717                                                               false);
01718     reinit (map, map, n_entries_per_row);
01719   }
01720 
01721 
01722 
01723   inline
01724   SparsityPattern::SparsityPattern  (const IndexSet     &row_parallel_partitioning,
01725                                      const IndexSet     &col_parallel_partitioning,
01726                                      const MPI_Comm     &communicator,
01727                                      const unsigned int  n_entries_per_row)
01728                   :
01729                   compressed (false)
01730   {
01731     Epetra_Map row_map =
01732       row_parallel_partitioning.make_trilinos_map (communicator, false);
01733     Epetra_Map col_map =
01734       col_parallel_partitioning.make_trilinos_map (communicator, false);
01735     reinit (row_map, col_map, n_entries_per_row);
01736   }
01737 
01738 
01739 
01740   inline
01741   SparsityPattern::
01742   SparsityPattern  (const IndexSet     &row_parallel_partitioning,
01743                     const IndexSet     &col_parallel_partitioning,
01744                     const MPI_Comm     &communicator,
01745                     const std::vector<unsigned int> &n_entries_per_row)
01746                   :
01747                   compressed (false)
01748   {
01749     Epetra_Map row_map =
01750       row_parallel_partitioning.make_trilinos_map (communicator, false);
01751     Epetra_Map col_map =
01752       col_parallel_partitioning.make_trilinos_map (communicator, false);
01753     reinit (row_map, col_map, n_entries_per_row);
01754   }
01755 
01756 
01757 
01758   inline
01759   void
01760   SparsityPattern::reinit (const IndexSet     &parallel_partitioning,
01761                            const MPI_Comm     &communicator,
01762                            const unsigned int  n_entries_per_row)
01763   {
01764     Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator,
01765                                                               false);
01766     reinit (map, map, n_entries_per_row);
01767   }
01768 
01769 
01770 
01771   inline
01772   void SparsityPattern::reinit (const IndexSet     &parallel_partitioning,
01773                                 const MPI_Comm     &communicator,
01774                                 const std::vector<unsigned int> &n_entries_per_row)
01775   {
01776     Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator,
01777                                                               false);
01778     reinit (map, map, n_entries_per_row);
01779   }
01780 
01781 
01782 
01783   inline
01784   void SparsityPattern::reinit (const IndexSet     &row_parallel_partitioning,
01785                                 const IndexSet     &col_parallel_partitioning,
01786                                 const MPI_Comm     &communicator,
01787                                 const unsigned int  n_entries_per_row)
01788   {
01789     Epetra_Map row_map =
01790       row_parallel_partitioning.make_trilinos_map (communicator, false);
01791     Epetra_Map col_map =
01792       col_parallel_partitioning.make_trilinos_map (communicator, false);
01793     reinit (row_map, col_map, n_entries_per_row);
01794   }
01795 
01796 
01797   inline
01798   void
01799   SparsityPattern::reinit (const IndexSet     &row_parallel_partitioning,
01800                            const IndexSet     &col_parallel_partitioning,
01801                            const MPI_Comm     &communicator,
01802                            const std::vector<unsigned int> &n_entries_per_row)
01803   {
01804     Epetra_Map row_map =
01805       row_parallel_partitioning.make_trilinos_map (communicator, false);
01806     Epetra_Map col_map =
01807       col_parallel_partitioning.make_trilinos_map (communicator, false);
01808     reinit (row_map, col_map, n_entries_per_row);
01809   }
01810 
01811 
01812 
01813   template<typename SparsityType>
01814   inline
01815   void
01816   SparsityPattern::reinit (const IndexSet     &row_parallel_partitioning,
01817                            const IndexSet     &col_parallel_partitioning,
01818                            const SparsityType &nontrilinos_sparsity_pattern,
01819                            const MPI_Comm     &communicator,
01820                            const bool          exchange_data)
01821   {
01822     Epetra_Map row_map =
01823       row_parallel_partitioning.make_trilinos_map (communicator, false);
01824     Epetra_Map col_map =
01825       col_parallel_partitioning.make_trilinos_map (communicator, false);
01826     reinit (row_map, col_map, nontrilinos_sparsity_pattern, exchange_data);
01827   }
01828 
01829 
01830 
01831   template<typename SparsityType>
01832   inline
01833   void
01834   SparsityPattern::reinit (const IndexSet     &parallel_partitioning,
01835                            const SparsityType &nontrilinos_sparsity_pattern,
01836                            const MPI_Comm     &communicator,
01837                            const bool          exchange_data)
01838   {
01839     Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator,
01840                                                               false);
01841     reinit (map, map, nontrilinos_sparsity_pattern, exchange_data);
01842   }
01843 
01844 #endif // DOXYGEN
01845 }
01846 
01847 
01848 DEAL_II_NAMESPACE_CLOSE
01849 
01850 
01851 #endif // DEAL_II_USE_TRILINOS
01852 
01853 
01854 /*--------------------   trilinos_sparsity_pattern.h     --------------------*/
01855 
01856 #endif
01857 /*--------------------   trilinos_sparsity_pattern.h     --------------------*/
01858 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Wed May 23 2012 12:03:31 by doxygen 1.7.3