All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Xpetra_CrsGraphFactory.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //             Xpetra: A linear algebra interface package
00006 //                  Copyright 2012 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact
00039 //                    Jonathan Hu       (jhu@sandia.gov)
00040 //                    Andrey Prokopenko (aprokop@sandia.gov)
00041 //                    Ray Tuminaro      (rstumin@sandia.gov)
00042 //
00043 // ***********************************************************************
00044 //
00045 // @HEADER
00046 #ifndef XPETRA_CRSGRAPHFACTORY_HPP
00047 #define XPETRA_CRSGRAPHFACTORY_HPP
00048 
00049 #include "Xpetra_ConfigDefs.hpp"
00050 
00051 #include "Xpetra_CrsGraph.hpp"
00052 
00053 #ifdef HAVE_XPETRA_TPETRA
00054 #include "Xpetra_TpetraCrsGraph.hpp"
00055 #endif
00056 
00057 #ifdef HAVE_XPETRA_EPETRA
00058 #include "Xpetra_EpetraCrsGraph.hpp"
00059 #endif
00060 
00061 #include "Xpetra_Exceptions.hpp"
00062 
00063 namespace Xpetra {
00064 
00065   template <class LocalOrdinal = CrsGraph<>::local_ordinal_type,
00066             class GlobalOrdinal =
00067               typename CrsGraph<LocalOrdinal>::global_ordinal_type,
00068             class Node =
00069               typename CrsGraph<LocalOrdinal, GlobalOrdinal>::node_type>
00070   class CrsGraphFactory {
00071   private:
00073     CrsGraphFactory() {}
00074 
00075   public:
00077     static Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
00078     Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, ProfileType pftype=DynamicProfile) {
00079       XPETRA_MONITOR("CrsGraphFactory::Build");
00080 
00081 #ifdef HAVE_XPETRA_TPETRA
00082       if (map->lib() == UseTpetra)
00083         return rcp( new TpetraCrsGraph<LocalOrdinal, GlobalOrdinal, Node> (map, NumVectors, pftype) );
00084 #endif
00085 
00086       XPETRA_FACTORY_ERROR_IF_EPETRA(map->lib());
00087       XPETRA_FACTORY_END;
00088       return null;
00089     }
00090   };
00091 
00092   template <>
00093   class CrsGraphFactory<int, int> {
00094 
00095     typedef int LocalOrdinal;
00096     typedef int GlobalOrdinal;
00097     typedef CrsGraph<int, GlobalOrdinal>::node_type Node;
00098 
00099   private:
00101     CrsGraphFactory() {}
00102 
00103   public:
00104 
00105     static RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
00106     Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, ProfileType pftype=DynamicProfile) {
00107       XPETRA_MONITOR("CrsGraphFactory::Build");
00108 
00109 #ifdef HAVE_XPETRA_TPETRA
00110       if (map->lib() == UseTpetra)
00111         return rcp( new TpetraCrsGraph<LocalOrdinal, GlobalOrdinal, Node> (map, NumVectors, pftype) );
00112 #endif
00113 
00114 #ifdef HAVE_XPETRA_EPETRA
00115 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
00116       if (map->lib() == UseEpetra)
00117         return rcp( new EpetraCrsGraphT<int>(map, NumVectors, pftype) );
00118 #endif
00119 #endif
00120 
00121       XPETRA_FACTORY_END;
00122       return null;
00123     }
00124 
00125   };
00126 
00127 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
00128   template <>
00129   class CrsGraphFactory<int, long long> {
00130 
00131     typedef int LocalOrdinal;
00132     typedef long long GlobalOrdinal;
00133     typedef CrsGraph<int, GlobalOrdinal>::node_type Node;
00134 
00135   private:
00137     CrsGraphFactory() {}
00138 
00139   public:
00140 
00141     static RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
00142     Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, ProfileType pftype=DynamicProfile) {
00143       XPETRA_MONITOR("CrsGraphFactory::Build");
00144 
00145 #ifdef HAVE_XPETRA_TPETRA
00146       if (map->lib() == UseTpetra)
00147         return rcp( new TpetraCrsGraph<LocalOrdinal, GlobalOrdinal, Node> (map, NumVectors, pftype) );
00148 #endif
00149 
00150 #ifdef HAVE_XPETRA_EPETRA
00151 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
00152       if (map->lib() == UseEpetra)
00153         return rcp( new EpetraCrsGraphT<long long>(map, NumVectors, pftype) );
00154 #endif
00155 #endif
00156 
00157       XPETRA_FACTORY_END;
00158       return null;
00159     }
00160 
00161   };
00162 #endif // HAVE_TEUCHOS_LONG_LONG_INT
00163 }
00164 
00165 #define XPETRA_CRSGRAPHFACTORY_SHORT
00166 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines