PetscSolver.h 2.15 KB
Newer Older
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
11
12
13
14
15
16
17
18
19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


20

Thomas Witkowski's avatar
Thomas Witkowski committed
21
/** \file PetscSolver.h */
22

23
24
#ifndef AMDIS_PETSC_SOLVER_H
#define AMDIS_PETSC_SOLVER_H
25

26
27
#include "parallel/PetscProblemStat.h"
#include "CreatorInterface.h"
28
29
30

namespace AMDiS {

31
32
33
34
35
36
37
38
39
  using namespace std;

  class PetscSolver
  {
  protected:
    PetscSolver(Mat& petscMatrix, MeshDistributor *dist, int n) 
      : matrix(petscMatrix),
	meshDistributor(dist),
	nComponents(n)
40
41
    {}

42
43
  public:
    virtual ~PetscSolver() {}
44

45
46
    /// Is used to create a PETSc solver and preconditioner object. This function may
    /// be overridden to create some special PETSc solver.
47
48
49
50
51
    virtual void providePetscSolver(KSP &solver, PC &pc) = 0;

    static PetscSolver* getPetscSolver(Mat& petscMatrix, 
				       MeshDistributor *dist, 
				       int n);
52

53
  protected:
54
55
56
57
58
    Mat& matrix;

    MeshDistributor *meshDistributor;

    int nComponents;
59
60
  };

61

62
63
64
65
66
67
68
69
70
71
  class PetscSolverGlobalMatrix : public PetscSolver
  {
  public:
    PetscSolverGlobalMatrix(Mat& petscMatrix, MeshDistributor *dist, int n)
      : PetscSolver(petscMatrix, dist, n)
    {}

    void providePetscSolver(KSP &solver, PC &pc);
  };

Thomas Witkowski's avatar
Thomas Witkowski committed
72
#ifdef HAVE_PETSC_DEV
73
74
75
76
77
78
79
80
81
  class PetscSolverSchur : public PetscSolver
  {
  public:
    PetscSolverSchur(Mat& petscMatrix, MeshDistributor *dist, int n)
      : PetscSolver(petscMatrix, dist, n)
    {}

    void providePetscSolver(KSP &solver, PC &pc);
  };
Thomas Witkowski's avatar
Thomas Witkowski committed
82
#endif
83
84

} // namespace AMDiS
85
86

#endif