~njansson/dolfin/hpc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2007 Ola Skavhaug.
// Licensed under the GNU LGPL Version 2.1.
//
// Modified by Garth N. Wells, 2008.
//
// First added:  2007-12-06
// Last changed: 2008-05-18

#ifndef __UBLAS_FACTORY_H
#define __UBLAS_FACTORY_H

#include "uBlasMatrix.h"
#include "uBlasVector.h"
#include "SparsityPattern.h"
#include "LinearAlgebraFactory.h"


namespace dolfin
{
  // Forward declaration
  template< class T> class uBlasMatrix;

  template<class Mat = ublas_sparse_matrix>
  class uBlasFactory: public LinearAlgebraFactory
  {
  public:

    /// Destructor
    virtual ~uBlasFactory() {}

    /// Create empty matrix
    uBlasMatrix<Mat>* createMatrix() const
    { return new uBlasMatrix<Mat>(); }

    /// Create empty sparsity pattern 
    SparsityPattern* createPattern() const
    { return new SparsityPattern(); }

    /// Create empty vector
    uBlasVector* createVector() const
    { return new uBlasVector(); }

    static uBlasFactory<Mat>& instance() 
    { return factory; }

  private:

    /// Private Constructor
    uBlasFactory() {}

    // Singleton instanc
    static uBlasFactory<Mat> factory;
  };
}

// Initialise static data
template<class Mat> dolfin::uBlasFactory<Mat> dolfin::uBlasFactory<Mat>::factory;


#endif