~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to dolfin/la/DefaultFactory.cpp

  • Committer: Kent-Andre Mardal
  • Date: 2008-05-19 14:21:52 UTC
  • mfrom: (2668.5.1 trunk)
  • mto: (2668.1.16 trunk)
  • mto: This revision was merged to the branch mainline in revision 2670.
  • Revision ID: kent-and@simula.no-20080519142152-7zb7r4htl7111izh
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2008 Anders Logg.
 
2
// Licensed under the GNU LGPL Version 2.1.
 
3
//
 
4
// First added:  2008-05-17
 
5
// Last changed: 2008-05-17
 
6
 
 
7
#include <dolfin/parameter/parameters.h>
 
8
#include "uBlasFactory.h"
 
9
#include "PETScFactory.h"
 
10
#include "EpetraFactory.h"
 
11
#include "DefaultFactory.h"
 
12
 
 
13
using namespace dolfin;
 
14
 
 
15
//-----------------------------------------------------------------------------
 
16
GenericMatrix* DefaultFactory::createMatrix() const
 
17
{
 
18
  return factory().createMatrix();
 
19
}
 
20
//-----------------------------------------------------------------------------
 
21
GenericVector* DefaultFactory::createVector() const
 
22
{
 
23
  return factory().createVector();
 
24
}
 
25
//-----------------------------------------------------------------------------
 
26
GenericSparsityPattern * DefaultFactory::createPattern() const
 
27
{
 
28
  return factory().createPattern();
 
29
}
 
30
//-----------------------------------------------------------------------------
 
31
LinearAlgebraFactory& DefaultFactory::factory() const
 
32
{
 
33
  // Fallback
 
34
  std::string default_backend = "uBLAS";
 
35
  typedef uBlasFactory<> DefaultFactory;
 
36
 
 
37
  // Get backend from parameter system
 
38
  std::string backend = dolfin_get("linear algebra backend");
 
39
 
 
40
  // Choose backend
 
41
  if (backend == "uBLAS")
 
42
  {
 
43
    return uBlasFactory<>::instance();
 
44
  }
 
45
  else if (backend == "PETSc")
 
46
  {
 
47
#ifdef HAS_PETSC
 
48
    return PETScFactory::instance();
 
49
#endif
 
50
  }
 
51
  else if (backend == "Epetra")
 
52
  {
 
53
#ifdef HAS_TRILINOS
 
54
    return EpetraFactory::instance();
 
55
#endif
 
56
  }
 
57
 
 
58
  // Fallback
 
59
  message("Linear algebra backend \"" + backend + "\" not available, using " + default_backend + ".");
 
60
  return DefaultFactory::instance();
 
61
}
 
62
//-----------------------------------------------------------------------------