Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef XPETRA_VECTORFACTORY_HPP
00047 #define XPETRA_VECTORFACTORY_HPP
00048
00049 #include "Xpetra_ConfigDefs.hpp"
00050
00051 #include "Xpetra_Vector.hpp"
00052
00053 #ifdef HAVE_XPETRA_TPETRA
00054 #include "Xpetra_TpetraVector.hpp"
00055 #endif
00056 #ifdef HAVE_XPETRA_EPETRA
00057 #include "Xpetra_EpetraVector.hpp"
00058 #include "Xpetra_EpetraIntVector.hpp"
00059 #endif
00060
00061 #include "Xpetra_Exceptions.hpp"
00062
00063 namespace Xpetra {
00064
00065 template <class Scalar, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00066 class VectorFactory {
00067
00068 private:
00070 VectorFactory() {}
00071
00072 public:
00073
00075 static RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, bool zeroOut=true) {
00076 XPETRA_MONITOR("VectorFactory::Build");
00077
00078 #ifdef HAVE_XPETRA_TPETRA
00079 if (map->lib() == UseTpetra)
00080 return rcp( new TpetraVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> (map, zeroOut) );
00081 #endif
00082
00083 XPETRA_FACTORY_ERROR_IF_EPETRA(map->lib());
00084 XPETRA_FACTORY_END;
00085 }
00086
00087 };
00088
00089 template <>
00090 class VectorFactory<double, int, int> {
00091
00092 typedef double Scalar;
00093 typedef int LocalOrdinal;
00094 typedef int GlobalOrdinal;
00095 typedef Kokkos::DefaultNode::DefaultNodeType Node;
00096
00097 private:
00099 VectorFactory() {}
00100
00101 public:
00102
00103 static RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, bool zeroOut=true) {
00104 XPETRA_MONITOR("VectorFactory::Build");
00105
00106 #ifdef HAVE_XPETRA_TPETRA
00107 if (map->lib() == UseTpetra)
00108 return rcp( new TpetraVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> (map, zeroOut) );
00109 #endif
00110
00111 #ifdef HAVE_XPETRA_EPETRA
00112 if (map->lib() == UseEpetra)
00113 return rcp( new EpetraVector(map, zeroOut) );
00114 #endif
00115
00116 XPETRA_FACTORY_END;
00117 }
00118
00119 };
00120
00121 template <>
00122 class VectorFactory<int, int, int> {
00123
00124 typedef int Scalar;
00125 typedef int LocalOrdinal;
00126 typedef int GlobalOrdinal;
00127 typedef Kokkos::DefaultNode::DefaultNodeType Node;
00128
00129 private:
00131 VectorFactory() {}
00132
00133 public:
00134
00135 static RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, bool zeroOut=true) {
00136 XPETRA_MONITOR("VectorFactory::Build");
00137
00138 #ifdef HAVE_XPETRA_TPETRA
00139 if (map->lib() == UseTpetra)
00140 return rcp( new TpetraVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> (map, zeroOut) );
00141 #endif
00142
00143 #ifdef HAVE_XPETRA_EPETRA
00144 if (map->lib() == UseEpetra)
00145 return rcp( new EpetraIntVector(map, zeroOut) );
00146 #endif
00147
00148 XPETRA_FACTORY_END;
00149 }
00150
00151 };
00152
00153 }
00154
00155 #define XPETRA_VECTORFACTORY_SHORT
00156 #endif
00157