ParallelDomainProblem.h 5.53 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file ParallelDomainProblem.h */

#ifndef AMDIS_PARALLELDOMAINPROBLEM_H
#define AMDIS_PARALLELDOMAINPROBLEM_H

#include <map>
#include <vector>

#include "ProblemTimeInterface.h"
#include "ProblemIterationInterface.h"
30
#include "FiniteElemSpace.h"
31
#include "AdaptInfo.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
32
#include "InteriorBoundary.h"
33
#include "petscao.h"
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "mpi.h"

namespace AMDiS {

  class ProblemScal;
  class ProblemInstatScal;
  class ParMetisPartitioner;
  class Mesh;

  class ParallelDomainProblemBase : public ProblemIterationInterface,
                                    public ProblemTimeInterface
  {
  public:
    ParallelDomainProblemBase(const std::string& name,
			      ProblemIterationInterface *iterationIF,
			      ProblemTimeInterface *timeIF,
50
			      FiniteElemSpace *feSpace);
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

    virtual ~ParallelDomainProblemBase() {}

    void initParallelization(AdaptInfo *adaptInfo);

    void exitParallelization(AdaptInfo *adaptInfo);    

    /// Set for each element on the partitioning level the number of leaf elements.
    double setElemWeights(AdaptInfo *adaptInfo);

    void partitionMesh(AdaptInfo *adaptInfo);

    virtual void setTime(AdaptInfo *adaptInfo) {}

    virtual void initTimestep(AdaptInfo *adaptInfo) {}

    virtual void closeTimestep(AdaptInfo *adaptInfo) {}

    virtual void solveInitialProblem(AdaptInfo *adaptInfo) {}
  
    virtual void transferInitialSolution(AdaptInfo *adaptInfo) {}

73
74
75
76
77
78
79
80
81
    virtual void beginIteration(AdaptInfo *adaptInfo) {
      iterationIF->beginIteration(adaptInfo);
    }

    virtual Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION);

    virtual void endIteration(AdaptInfo *adaptInfo) {
      iterationIF->endIteration(adaptInfo);
    }
82
83
84
85
86
87
88

    virtual int getNumProblems() {}

    inline virtual const std::string& getName() { 
      return name; 
    }

89
90
91
92
93
94
95
96
97
98
    /// Returns pointer to \ref applicationOrdering.
    AO* getApplicationOrdering() {
      return &applicationOrdering;
    }

    /// Returns \ref nRankDOFs, the number of DOFs in the rank mesh.
    int getNumberRankDOFs() {
      return nRankDOFs;
    }

99
100
101
102
103
104
105
    virtual ProblemStatBase *getProblem(int number = 0) {}

    virtual void serialize(std::ostream&) {}

    virtual void deserialize(std::istream&) {}
    
  protected:
106
107
108
109
110
111
    ///
    ProblemIterationInterface *iterationIF;

    ///
    ProblemTimeInterface *timeIF;

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
    /// The rank of the current process.
    int mpiRank;

    /// Overall number of processes.
    int mpiSize;

    /** \brief
     * MPI communicator collected all processes, which should
     * be used for calculation. The Debug procces is not included
     * in this communicator.
     */
    MPI::Intracomm mpiComm;

    /// Name of the problem (as used in the init files)
    std::string name;

128
129
130
    /// Finite element space of the problem.
    FiniteElemSpace *feSpace;

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    /// Mesh of the problem.
    Mesh *mesh;

    /// Pointer to the paritioner which is used to devide a mesh into partitions.
    ParMetisPartitioner *partitioner;

    /// Weights for the elements, i.e., the number of leaf elements within this element.
    std::map<int, double> elemWeights;

    /// Is true, if the mesh was not partitioned before, otherwise it's false.
    bool initialPartitionMesh;

    /** \brief
     * Stores to every coarse element index the number of the partition it 
     * corresponds to.
     */
    std::map<int, int> partitionVec;

    /** \brief
     * Stores an old partitioning of elements. To every element index the number
     * of the parition it corresponds to is stored.
     */
    std::map<int, int> oldPartitionVec;    
154
155
156
157
158
159

    /// Petsc application ordering
    AO applicationOrdering;

    /// Number of DOFs in the rank mesh.
    int nRankDOFs;
Thomas Witkowski's avatar
Thomas Witkowski committed
160
161
162
163
164
165
166
167

    /** \brief 
     * Defines the interioir boundaries of the domain that result from partitioning
     * the whole mesh.
     */
    InteriorBoundary interiorBoundary;

    std::map<const DegreeOfFreedom*, int> boundaryDofs;
168
169
170
171
172
173
174
175
176
177
178
179
180
  };

  class ParallelDomainProblemScal : public ParallelDomainProblemBase
  {
  public:
    ParallelDomainProblemScal(const std::string& name,
			      ProblemScal *problem,
			      ProblemInstatScal *problemInstat);

  };
}

#endif // AMDIS_PARALLELDOMAINPROBLEM_H