Xpetra_MapExtractorFactory.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 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
39 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 /*
47  * Xpetra_MapExtractorFactory.hpp
48  *
49  * Created on: Aug 22, 2011
50  * Author: wiesner
51  */
52 
53 // WARNING: This code is experimental. Backwards compatibility should not be expected.
54 
55 #ifndef XPETRA_MAPEXTRACTORFACTORY_HPP_
56 #define XPETRA_MAPEXTRACTORFACTORY_HPP_
57 
58 #include <Kokkos_DefaultNode.hpp>
59 
60 #include <Xpetra_MapExtractor.hpp>
61 
62 #ifdef HAVE_XPETRA_TPETRA
64 #endif
65 #ifdef HAVE_XPETRA_EPETRA
67 #endif
68 
69 namespace Xpetra
70 {
71  // factory class
72  template <class Scalar, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
76 #ifdef HAVE_XPETRA_TPETRA
79 #endif
80  private:
83 
84  public:
86  static Teuchos::RCP<MapExtractorClass> Build(const Teuchos::RCP<const MapClass>& fullmap, const std::vector<Teuchos::RCP<const MapClass> >& maps)
87  {
88 #ifdef HAVE_XPETRA_TPETRA
89  const Teuchos::RCP<const TpetraMapClass> &tMap = Teuchos::rcp_dynamic_cast<const TpetraMapClass>(fullmap);
90  if (tMap != null)
91  {
92  Teuchos::RCP<TpetraMapExtractorClass> tMapExtractor = Teuchos::rcp(new TpetraMapExtractorClass(tMap,maps));
93  return Teuchos::rcp_dynamic_cast<MapExtractorClass>(tMapExtractor);
94  }
95 #endif
96 
97  XPETRA_FACTORY_ERROR_IF_EPETRA(fullmap->lib());
98 
100  }
101 
103 #ifdef HAVE_XPETRA_TPETRA
104  static Teuchos::RCP<TpetraMapExtractorClass> Build(const Teuchos::RCP<const TpetraMapClass>& fullmap, const std::vector<Teuchos::RCP<const TpetraMapClass> >& maps)
105  {
106  const Teuchos::RCP<const TpetraMapClass> &tMap = Teuchos::rcp_dynamic_cast<const TpetraMapClass>(fullmap);
107  if (tMap != null)
108  //return Teuchos::rcp( new TpetraMultiVectorClass(map, NumVectors, zeroOut) );
109  return Teuchos::rcp(new TpetraMapExtractorClass(tMap,maps));
110 
112  }
113 #endif
114 
115  };
116 
117 
118  // factory class
119  template <>
120  class MapExtractorFactory<double,int,int> {
121  typedef int LocalOrdinal;
122  typedef int GlobalOrdinal;
123  typedef double Scalar;
127 #ifdef HAVE_XPETRA_TPETRA
130 #endif
131  private:
134 
135  public:
137  static Teuchos::RCP<MapExtractorClass> Build(const Teuchos::RCP<const MapClass>& fullmap, const std::vector<Teuchos::RCP<const MapClass> >& maps)
138  {
139 #ifdef HAVE_XPETRA_EPETRA
140  const RCP<const EpetraMap> &eMap = Teuchos::rcp_dynamic_cast<const EpetraMap>(fullmap);
141  if (eMap != null)
142  return Teuchos::rcp(new Xpetra::EpetraMapExtractor(eMap,maps));
143 #endif
144 #ifdef HAVE_XPETRA_TPETRA
145  const Teuchos::RCP<const TpetraMapClass> &tMap = Teuchos::rcp_dynamic_cast<const TpetraMapClass>(fullmap);
146  if (tMap != null)
147  {
148  Teuchos::RCP<TpetraMapExtractorClass> tMapExtractor = Teuchos::rcp(new TpetraMapExtractorClass(tMap,maps));
149  return Teuchos::rcp_dynamic_cast<MapExtractorClass>(tMapExtractor);
150  }
151 #endif
152 
154  }
155 
157 #ifdef HAVE_XPETRA_TPETRA
158  static Teuchos::RCP<TpetraMapExtractorClass> Build(const Teuchos::RCP<const TpetraMapClass>& fullmap, const std::vector<Teuchos::RCP<const TpetraMapClass> >& maps)
159  {
160  const Teuchos::RCP<const TpetraMapClass> &tMap = Teuchos::rcp_dynamic_cast<const TpetraMapClass>(fullmap);
161  if (tMap != null)
162  //return Teuchos::rcp( new TpetraMultiVectorClass(map, NumVectors, zeroOut) );
163  return Teuchos::rcp(new TpetraMapExtractorClass(tMap,maps));
164 
166  }
167 #endif
168 
170 #ifdef HAVE_XPETRA_EPETRA
171  static Teuchos::RCP<Xpetra::EpetraMapExtractor> Build(const Teuchos::RCP<const Xpetra::EpetraMap>& fullmap, const std::vector<Teuchos::RCP<const Xpetra::EpetraMap> >& maps)
172  {
173  const RCP<const EpetraMap> &eMap = Teuchos::rcp_dynamic_cast<const EpetraMap>(fullmap);
174  if (eMap != null)
175  return Teuchos::rcp(new Xpetra::EpetraMapExtractor(eMap,maps));
176 
178  }
179 #endif
180  };
181 }
182 
183 
184 #endif /* XPETRA_MAPEXTRACTORFACTORY_HPP_ */
TpetraMapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraMapExtractorClass
Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > MapExtractorClass
Xpetra namespace
static Teuchos::RCP< Xpetra::EpetraMapExtractor > Build(const Teuchos::RCP< const Xpetra::EpetraMap > &fullmap, const std::vector< Teuchos::RCP< const Xpetra::EpetraMap > > &maps)
Constructor for Epetra.
TpetraMapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraMapExtractorClass
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > MapClass
static Teuchos::RCP< TpetraMapExtractorClass > Build(const Teuchos::RCP< const TpetraMapClass > &fullmap, const std::vector< Teuchos::RCP< const TpetraMapClass > > &maps)
Constructor for Tpetra.
Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > MapExtractorClass
static Teuchos::RCP< TpetraMapExtractorClass > Build(const Teuchos::RCP< const TpetraMapClass > &fullmap, const std::vector< Teuchos::RCP< const TpetraMapClass > > &maps)
Constructor for Tpetra.
MapExtractorFactory()
Private construtor, since this is a static class.
#define XPETRA_FACTORY_END
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > MapClass
static Teuchos::RCP< MapExtractorClass > Build(const Teuchos::RCP< const MapClass > &fullmap, const std::vector< Teuchos::RCP< const MapClass > > &maps)
Constructor specifying the maps (and indirectly the used LINALG library (Tpetra vs Epetra)) ...
MapExtractorFactory()
Private construtor, since this is a static class.
static Teuchos::RCP< MapExtractorClass > Build(const Teuchos::RCP< const MapClass > &fullmap, const std::vector< Teuchos::RCP< const MapClass > > &maps)
Constructor specifying the maps (and indirectly the used LINALG library (Tpetra vs Epetra)) ...
TpetraMap< LocalOrdinal, GlobalOrdinal, Node > TpetraMapClass
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
TpetraMap< LocalOrdinal, GlobalOrdinal, Node > TpetraMapClass