SubDomainSolver.h 3.2 KB
Newer Older
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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==  http://www.amdis-fem.org                                              ==
// ==                                                                        ==
// ============================================================================
//
// 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.



/** \file SubDomainSolver.h */

#ifndef AMDIS_SUBDOMAIN_SOLVER_H
#define AMDIS_SUBDOMAIN_SOLVER_H

#include <map>
#include <set>
#include <mpi.h>
#include <petsc.h>
#include "parallel/MeshDistributor.h"
#include "parallel/ParallelDofMapping.h"

namespace AMDiS {

  using namespace std;

  class SubDomainSolver {
  public:
    SubDomainSolver(MeshDistributor *md,
40
41
		    MPI::Intracomm mpiComm0,
		    MPI::Intracomm mpiComm1)
42
      : meshDistributor(md),
43
	level(0),
44
45
46
47
	mpiCommCoarseSpace(mpiComm0),
	mpiCommInterior(mpiComm1),
	coarseSpaceMap(NULL),
	interiorMap(NULL)
48
49
    {}

50
51
52
53
54
    void setLevel(int l) 
    {
      level = l;
    }

55
    void setDofMapping(ParallelDofMapping *coarseDofs,
56
		       ParallelDofMapping *interiorDofs);
57

58
59
60
61
62
63
    void fillPetscMatrix(Matrix<DOFMatrix*> *mat);

    void fillPetscRhs(SystemVector *vec);

    void solvePetscMatrix(SystemVector &vec, AdaptInfo *adaptInfo);

64
65
    void destroyVectorData();

66
67
68
    void destroyMatrixData();

    void solve(Vec &rhs, Vec &sol);
69

70
71
    void solveGlobal(Vec &rhs, Vec &sol);

72
73
    inline bool isCoarseSpace(const FiniteElemSpace *feSpace, 
			      DegreeOfFreedom dof)
74
    {
75
      return (*coarseSpaceMap)[feSpace].isSet(dof);
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    }

    inline Vec& getRhsCoarseSpace()
    {
      return rhsCoarseSpace;
    }

    inline Vec& getRhsInterior()
    {
      return rhsInterior;
    }

    inline Mat& getMatIntInt()
    {
      return matIntInt;
    }

    inline Mat& getMatCoarseCoarse()
    {
      return matCoarseCoarse;
    }

    inline Mat& getMatIntCoarse()
    {
      return matIntCoarse;
    }

    inline Mat& getMatCoarseInt()
    {
      return matCoarseInt;
    }

  protected:
    /// Returns a vector with the FE spaces of each row in the matrix. Thus, the
    /// resulting vector may contain the same FE space multiple times.
    vector<const FiniteElemSpace*> getFeSpaces(Matrix<DOFMatrix*> *mat);

    /// Returns a vector with the FE spaces of all components of a system vector.
    vector<const FiniteElemSpace*> getFeSpaces(SystemVector *vec);

116
117
118
  protected:
    MeshDistributor *meshDistributor;

119
120
    int level;

121
122
123
124
    int rStartInterior;

    int nGlobalOverallInterior;

125
126
127
128
129
130
131
132
133
134
135
    MPI::Intracomm mpiCommCoarseSpace;

    MPI::Intracomm mpiCommInterior;

    ParallelDofMapping* coarseSpaceMap;

    ParallelDofMapping* interiorMap;

    Vec rhsCoarseSpace;

    Vec rhsInterior;
136

137
    Mat matIntInt, matCoarseCoarse, matIntCoarse, matCoarseInt;
138

139
    KSP kspInterior;
140
141
142
143
  };
}

#endif