Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_EpetraCrsMatrix_MatrixAdapter_def.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Amesos2: Templated Direct Sparse Solver Package
4 //
5 // Copyright 2011 NTESS and the Amesos2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 
11 #ifndef AMESOS2_EPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
12 #define AMESOS2_EPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
13 
14 #include <Epetra_LocalMap.h>
15 #include <Epetra_Import.h>
16 
19 #include "Amesos2_MatrixAdapter_def.hpp"
20 
21 
22 namespace Amesos2 {
23 
24  ConcreteMatrixAdapter<Epetra_CrsMatrix>::ConcreteMatrixAdapter(RCP<Epetra_CrsMatrix> m)
25  : AbstractConcreteMatrixAdapter<Epetra_RowMatrix,Epetra_CrsMatrix>(m) // CrsMatrix inherits from RowMatrix virtually, so a dynamic cast is necessary
26  {}
27 
28  Teuchos::RCP<const MatrixAdapter<Epetra_CrsMatrix> >
29  ConcreteMatrixAdapter<Epetra_CrsMatrix>::get_impl(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map, EDistribution /* distribution */) const
30  {
31  using Teuchos::as;
32  using Teuchos::rcp;
33  using Teuchos::rcpFromRef;
34 
35  RCP<const Epetra_Map> o_map, t_map;
36  o_map = rcpFromRef(this->mat_->RowMap());
37  t_map = Util::tpetra_map_to_epetra_map<local_ordinal_t,global_ordinal_t,global_size_t,node_t>(*map);
38 
39  RCP<Epetra_CrsMatrix> t_mat = rcp(new Epetra_CrsMatrix(Copy, *t_map, this->getMaxRowNNZ()));
40 
41  Epetra_Import importer(*t_map, *o_map);
42  t_mat->Import(*(this->mat_), importer, Insert);
43 
44  t_mat->FillComplete(); // Must be in local form for later extraction of rows
45 
46  return( rcp(new ConcreteMatrixAdapter<Epetra_CrsMatrix>(t_mat)) );
47  }
48 
49 } // end namespace Amesos2
50 
51 #endif // AMESOS2_EPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
Definitions for the Epetra_RowMatrix abstract adapter.
Specialization of the ConcreteMatrixAdapter for Epetra_CrsMatrix. Inherits all its functionality from...
EDistribution
Definition: Amesos2_TypeDecl.hpp:89