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_Vector.hpp>
61 #include <Tpetra_Map.hpp>
62 
63 #include <Epetra_MultiVector.h>
64 
65 #include "Amesos2_MultiVecAdapter_decl.hpp"
66 
67 namespace Amesos2 {
68 
74  template <>
75  class MultiVecAdapter<Epetra_MultiVector>
76  {
77  public:
78 
79  // public type definitions
80  typedef double scalar_t;
81  typedef int local_ordinal_t;
82  typedef Tpetra::Map<>::global_ordinal_type global_ordinal_t;
83  typedef size_t global_size_t;
84  typedef Tpetra::Map<>::node_type node_t;
85  typedef Epetra_MultiVector multivec_t;
86 
87  friend Teuchos::RCP<MultiVecAdapter<multivec_t> > createMultiVecAdapter<>(Teuchos::RCP<multivec_t>);
88  friend Teuchos::RCP<const MultiVecAdapter<multivec_t> > createConstMultiVecAdapter<>(Teuchos::RCP<const multivec_t>);
89 
90 
91  static const char* name;
92 
93 
94  protected:
97 
103  MultiVecAdapter( const Teuchos::RCP<multivec_t>& m );
104 
105 
106  public:
107 
108  ~MultiVecAdapter() = default;
109 
110 
112  bool isLocallyIndexed() const;
113 
114  bool isGloballyIndexed() const;
115 
116 
123  Teuchos::RCP<const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> >
124  getMap() const;
125 
127  const Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
128 
129 
131  size_t getLocalLength() const;
132 
133 
135  size_t getLocalNumVectors() const;
136 
137 
139  global_size_t getGlobalLength() const;
140 
141 
143  size_t getGlobalNumVectors() const;
144 
145 
147  size_t getStride() const;
148 
149 
151  bool isConstantStride() const;
152 
153 
155  Teuchos::RCP<const Tpetra::Vector<scalar_t,local_ordinal_t,global_ordinal_t,node_t> >
156  getVector( size_t j ) const;
157 
158 
166  Teuchos::RCP<Tpetra::Vector<scalar_t,local_ordinal_t,global_ordinal_t,node_t> >
167  getVectorNonConst( size_t j );
168 
169 
171  double * getMVPointer_impl() const;
172 
178  void get1dCopy( const Teuchos::ArrayView<scalar_t>& A,
179  size_t lda,
180  Teuchos::Ptr<
181  const Tpetra::Map<local_ordinal_t,
182  global_ordinal_t,
183  node_t> > distribution_map,
184  EDistribution distribution) const;
185 
186 
204  Teuchos::ArrayRCP<scalar_t> get1dViewNonConst( bool local = false );
205 
206 
217  void put1dData( const Teuchos::ArrayView<const scalar_t>& new_data,
218  size_t lda,
219  Teuchos::Ptr<
220  const Tpetra::Map<local_ordinal_t,
221  global_ordinal_t,
222  node_t> > source_map,
223  EDistribution distribution );
224 
225 
226 
228  std::string description() const;
229 
230 
232  void describe( Teuchos::FancyOStream& os,
233  const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
234 
235 
236  private:
237 
239  Teuchos::RCP<multivec_t> mv_;
240 
241  mutable Teuchos::RCP<Epetra_Import> importer_;
242  mutable Teuchos::RCP<Epetra_Export> exporter_;
243 
244  mutable Teuchos::RCP<const Epetra_BlockMap> mv_map_;
245 
246  }; // end class MultiVecAdapter<NewMultiVec>
247 
248 } // end namespace Amesos2
249 
250 
251 #endif // AMESOS2_EPETRA_MULTIVEC_ADAPTER_DECL_HPP
Teuchos::RCP< multivec_t > mv_
The multi-vector this adapter wraps.
Definition: Amesos2_EpetraMultiVecAdapter_decl.hpp:239
EDistribution
Definition: Amesos2_TypeDecl.hpp:123
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176