ProblemInstat.h 6.42 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
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
// ==                                                                        ==
// ============================================================================

/** \file ProblemInstat.h */

#ifndef AMDIS_PROBLEM_INSTAT_H_
#define AMDIS_PROBLEM_INSTAT_H_

#include "ProblemScal.h"
#include "ProblemVec.h"
#include "ProblemTimeInterface.h"
#include "AdaptInstationary.h"

namespace AMDiS {

  /**
   * \ingroup Problem
   *
   * \brief
   * Base class for ProblemInstatScal and ProblemInstatVec.
   */
  class ProblemInstat : public ProblemTimeInterface,
			public ProblemStatBase
  {
  public:
42
43
    /// Constructor.
    ProblemInstat(std::string probName,
44
		  ProblemStatBase *initialProb)
45
      : name(probName),
46
	initialProblem(initialProb ? initialProb : this)
47
    {}
48

49
    /// Destructor.
50
51
    virtual ~ProblemInstat();

52
    /// Initialisation of the problem.
53
54
55
56
    virtual void initialize(Flag initFlag,
			    ProblemInstat *adoptProblem = NULL,
			    Flag adoptFlag = INIT_NOTHING);

57
58
    virtual void solve(AdaptInfo* adaptInfo) {}

59
60
    virtual void solve(AdaptInfo *adaptInfo, bool fixedMatrix) 
    {
61
62
      solve(adaptInfo);
    }
63

64
    virtual void estimate(AdaptInfo *adaptInfo) {}
65

66
    virtual void buildBeforeRefine(AdaptInfo *adaptInfo, Flag) {}
67

68
    virtual void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag) {}
69

70
    virtual void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag, bool, bool) {}
71

72
73
    virtual Flag markElements(AdaptInfo *adaptInfo) 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
74
      return 0; 
75
    }
76

77
78
    virtual Flag refineMesh(AdaptInfo *adaptInfo) 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
79
      return 0; 
80
    }
81

82
83
    virtual Flag coarsenMesh(AdaptInfo *adaptInfo) 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
84
      return 0; 
85
    }
86

87
    /// Implementation of ProblemTimeInterface::closeTimestep().
88
    virtual void closeTimestep() {}
89

90
    /// Returns \ref name.
Thomas Witkowski's avatar
Thomas Witkowski committed
91
    inline std::string getName() 
92
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
93
      return name; 
94
    }
95

96
    /// Used by \ref problemInitial
97
98
    virtual void solveInitialProblem(AdaptInfo *adaptInfo);  

Thomas Witkowski's avatar
Thomas Witkowski committed
99

100
  protected:
101
    /// Name of the problem.
102
    std::string name;
103
104
105
106
107
108
109
110
111
112
113
114
115
116

    ProblemStatBase *initialProblem;
  };


  /**
   * \ingroup Problem
   *
   * \brief
   * Standard implementation of ProblemTimeInterface for a time dependent problems.
   */
  class ProblemInstatScal : public ProblemInstat
  {
  public:
117
    /// Constructs a ProblemInstatScal with prob as its stationary problem.
118
    ProblemInstatScal(std::string name,
119
120
121
		      ProblemScal *prob,
		      ProblemStatBase *initialProb = NULL);

122
123
124
125
    ProblemInstatScal(std::string name, ProblemScal& prob);

    ProblemInstatScal(std::string name, ProblemScal& prob, ProblemStatBase& initialProb);

126
    /// Destructor.
127
128
    virtual ~ProblemInstatScal();

129
    /// Initialisation of the problem.
130
131
132
133
    virtual void initialize(Flag initFlag,
			    ProblemInstat *adoptProblem = NULL,
			    Flag adoptFlag = INIT_NOTHING);

134
    /// Used in \ref initialize().
135
    virtual void createUhOld();
136
 
137
    /// Implementation of ProblemTimeInterface::initTimestep().
138
139
    virtual void initTimestep(AdaptInfo *adaptInfo);

140
    /// Implementation of ProblemTimeInterface::closeTimestep().
141
142
    virtual void closeTimestep(AdaptInfo *adaptInfo);
  
143
144
145
    /// Returns \ref problemStat.
    inline ProblemScal* getStatProblem() 
    { 
146
      return problemStat; 
147
    }
148

149
150
151
    /// Returns \ref oldSolution.
    inline DOFVector<double> *getOldSolution() 
    { 
152
      return oldSolution; 
153
    }
154

155
    /// Used by \ref problemInitial
156
157
    virtual void transferInitialSolution(AdaptInfo *adaptInfo);  

158
    virtual void serialize(std::ostream &out) {}
Thomas Witkowski's avatar
Thomas Witkowski committed
159

160
    virtual void deserialize(std::istream &in) {}
161
162
   
  protected:
163
    /// Space problem solved in each timestep.
164
165
    ProblemScal* problemStat;

166
    /// Solution of the last timestep.
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    DOFVector<double>* oldSolution;
  };


  /**
   * \ingroup Problem
   *
   * \brief
   * Standard implementation of ProblemTimeInterface for a time dependent 
   * vector valued problems.
   */
  class ProblemInstatVec : public ProblemInstat
  {
  public:
181
    /// Constructs a ProblemInstatVec with prob as its stationary problem.
182
    ProblemInstatVec(std::string name, 
183
184
185
		     ProblemVec *prob,
		     ProblemStatBase *initialProb = NULL);

186
    /// Destructor.
187
188
    virtual ~ProblemInstatVec();

189
    /// Initialisation of the problem.
190
191
192
193
    virtual void initialize(Flag initFlag,
			    ProblemInstat *adoptProblem = NULL,
			    Flag adoptFlag = INIT_NOTHING);

194
    /// Used in \ref initialize().
195
196
    virtual void createUhOld();

197
    /// Implementation of ProblemTimeInterface::initTimestep().
198
199
    virtual void initTimestep(AdaptInfo *adaptInfo);

200
    /// Implementation of ProblemTimeInterface::closeTimestep().
201
202
    virtual void closeTimestep(AdaptInfo *adaptInfo);
  
203
204
205
    /// Returns \ref problemStat.
    inline ProblemVec* getStatProblem() 
    {
206
      return problemStat; 
Thomas Witkowski's avatar
Thomas Witkowski committed
207
    }
208

209
210
211
    /// Returns \ref oldSolution.
    inline SystemVector *getOldSolution() 
    { 
212
      return oldSolution; 
Thomas Witkowski's avatar
Thomas Witkowski committed
213
    }
214

215
    /// Used by \ref problemInitial
216
217
    virtual void transferInitialSolution(AdaptInfo *adaptInfo);  

Thomas Witkowski's avatar
Thomas Witkowski committed
218
    virtual void serialize(std::ostream &out) {}
Thomas Witkowski's avatar
Thomas Witkowski committed
219

Thomas Witkowski's avatar
Thomas Witkowski committed
220
    virtual void deserialize(std::istream &in) {}
221
222

  protected:
223
    /// Space problem solved in each timestep.
224
225
    ProblemVec* problemStat;

226
    /// Solution of the last timestep.
227
228
229
230
231
232
    SystemVector *oldSolution;
  };

}

#endif