Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PackageA.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "PackageA.hpp"
11 
12 namespace A {
13 
14  // Creating an instance of this "object" registers A::FactoryA<MV,
15  // OP> with the central registry of packages' factories. That lets
16  // getLinearSolver create solvers from package A.
17  template<class MV, class OP, class NormType>
19  public:
21 #ifdef HAVE_TEUCHOSCORE_CXX11
22  typedef std::shared_ptr<Trilinos::Details::LinearSolverFactory<MV, OP, NormType> > ptr_type;
23 #else
25 #endif // HAVE_TEUCHOSCORE_CXX11
26 
27  ptr_type factory (new FactoryA<MV, OP, NormType> ());
28  Trilinos::Details::registerLinearSolverFactory<MV, OP, NormType> ("A", factory);
29  }
30  };
31 
32 } // namespace A
33 
34 namespace { // (anonymous)
35 
36  // For each triple of types (MV, OP, NormType) of interest, register
37  // A::FactoryA<MV, OP, NormType>. We use MV =
38  // Common::MultiVector<Scalar> and OP = Common::Operator<Scalar>
39  // here, for various Scalar types. NormType = Scalar simulates the
40  // case where Scalar is real (not complex).
41  //
42  // This is a stub of what you likely will want to do with Tpetra and
43  // its downstream solver packages. See the public documentation of
44  // Trilinos::Details::LinearSolverFactory for details.
45  //
46  // The ## operator in a macro appends two things. For example, with
47  // INSTMACRO( float ), registerer_##SCALAR becomes registerer_float.
48  // This ensures that the different instances of RegisterFactoryA
49  // have different names.
50 
51 #define INSTMACRO( SCALAR ) \
52  A::RegisterFactoryA< Common::MultiVector< SCALAR >, Common::Operator< SCALAR >, SCALAR > registerer_##SCALAR;
53 
54  //A::RegisterFactoryA< Common::MultiVector<double>, Common::Operator<double>, double > registerer_double;
55  INSTMACRO( double )
56 
57  //A::RegisterFactoryA< Common::MultiVector<float>, Common::Operator<float>, float > registerer_float;
58  INSTMACRO( float )
59 
60 } // namespace (anonymous)
#define INSTMACRO(SCALAR)
Definition: PackageA.cpp:51
Smart reference counting pointer class for automatic garbage collection.