Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_EpetraMultiVecAdapter_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Amesos2: Templated Direct Sparse Solver Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //
42 // @HEADER
43 
53 #ifndef AMESOS2_EPETRA_MULTIVEC_ADAPTER_DECL_HPP
54 #define AMESOS2_EPETRA_MULTIVEC_ADAPTER_DECL_HPP
55 
56 #include <Teuchos_RCP.hpp>
57 #include <Teuchos_Array.hpp>
58 #include <Teuchos_as.hpp>
59 
60 #include <Tpetra_DefaultPlatform.hpp>
61 #include <Tpetra_Vector.hpp>
62 #include <Tpetra_Map.hpp>
63 
64 #include <Epetra_MultiVector.h>
65 
66 #include "Amesos2_MultiVecAdapter_decl.hpp"
67 
68 namespace Amesos2 {
69 
75  template <>
76  class MultiVecAdapter<Epetra_MultiVector>
77  {
78  public:
79 
80  // public type definitions
81  typedef double scalar_t;
82  typedef int local_ordinal_t;
83  typedef int global_ordinal_t;
84  typedef size_t global_size_t;
85  typedef Tpetra::DefaultPlatform::DefaultPlatformType::NodeType node_t;
86  typedef Epetra_MultiVector multivec_t;
87 
88  friend Teuchos::RCP<MultiVecAdapter<multivec_t> > createMultiVecAdapter<>(Teuchos::RCP<multivec_t>);
89  friend Teuchos::RCP<const MultiVecAdapter<multivec_t> > createConstMultiVecAdapter<>(Teuchos::RCP<const multivec_t>);
90 
91 
92  static const char* name;
93 
94 
95  protected:
98 
104  MultiVecAdapter( const Teuchos::RCP<multivec_t>& m );
105 
106 
107  public:
108 
109  ~MultiVecAdapter()
110  { }
111 
112 
114  bool isLocallyIndexed() const;
115 
116  bool isGloballyIndexed() const;
117 
118 
125  Teuchos::RCP<const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> >
126  getMap() const;
127 
129  const Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
130 
131 
133  size_t getLocalLength() const;
134 
135 
137  size_t getLocalNumVectors() const;
138 
139 
141  global_size_t getGlobalLength() const;
142 
143 
145  size_t getGlobalNumVectors() const;
146 
147 
149  size_t getStride() const;
150 
151 
153  bool isConstantStride() const;
154 
155 
157  Teuchos::RCP<const Tpetra::Vector<scalar_t,local_ordinal_t,global_ordinal_t,node_t> >
158  getVector( size_t j ) const;
159 
160 
168  Teuchos::RCP<Tpetra::Vector<scalar_t,local_ordinal_t,global_ordinal_t,node_t> >
169  getVectorNonConst( size_t j );
170 
171 
177  void get1dCopy( const Teuchos::ArrayView<scalar_t>& A,
178  size_t lda,
179  Teuchos::Ptr<
180  const Tpetra::Map<local_ordinal_t,
181  global_ordinal_t,
182  node_t> > distribution_map ) const;
183 
184 
202  Teuchos::ArrayRCP<scalar_t> get1dViewNonConst( bool local = false );
203 
204 
215  void put1dData( const Teuchos::ArrayView<const scalar_t>& new_data,
216  size_t lda,
217  Teuchos::Ptr<
218  const Tpetra::Map<local_ordinal_t,
219  global_ordinal_t,
220  node_t> > source_map );
221 
222 
223 
225  std::string description() const;
226 
227 
229  void describe( Teuchos::FancyOStream& os,
230  const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
231 
232 
233  private:
234 
236  Teuchos::RCP<multivec_t> mv_;
237 
238  mutable Teuchos::RCP<Epetra_Import> importer_;
239  mutable Teuchos::RCP<Epetra_Export> exporter_;
240 
241  mutable Teuchos::RCP<const Epetra_BlockMap> mv_map_;
242 
243  }; // end class MultiVecAdapter<NewMultiVec>
244 
245 } // end namespace Amesos2
246 
247 
248 #endif // AMESOS2_EPETRA_MULTIVEC_ADAPTER_DECL_HPP
Teuchos::RCP< multivec_t > mv_
The multi-vector this adapter wraps.
Definition: Amesos2_EpetraMultiVecAdapter_decl.hpp:236
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:175