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

/** \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
    /// Destructor.
123
124
    virtual ~ProblemInstatScal();

125
    /// Initialisation of the problem.
126
127
128
129
    virtual void initialize(Flag initFlag,
			    ProblemInstat *adoptProblem = NULL,
			    Flag adoptFlag = INIT_NOTHING);

130
    /// Used in \ref initialize().
131
    virtual void createUhOld();
132
 
133
    /// Implementation of ProblemTimeInterface::initTimestep().
134
135
    virtual void initTimestep(AdaptInfo *adaptInfo);

136
    /// Implementation of ProblemTimeInterface::closeTimestep().
137
138
    virtual void closeTimestep(AdaptInfo *adaptInfo);
  
139
140
141
    /// Returns \ref problemStat.
    inline ProblemScal* getStatProblem() 
    { 
142
      return problemStat; 
143
    }
144

145
146
147
    /// Returns \ref oldSolution.
    inline DOFVector<double> *getOldSolution() 
    { 
148
      return oldSolution; 
149
    }
150

151
    /// Used by \ref problemInitial
152
153
    virtual void transferInitialSolution(AdaptInfo *adaptInfo);  

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

156
    virtual void deserialize(std::istream &in) {}
157
158
   
  protected:
159
    /// Space problem solved in each timestep.
160
161
    ProblemScal* problemStat;

162
    /// Solution of the last timestep.
163
164
165
166
167
168
169
170
171
172
173
174
175
176
    DOFVector<double>* oldSolution;
  };


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

182
    /// Destructor.
183
184
    virtual ~ProblemInstatVec();

185
    /// Initialisation of the problem.
186
187
188
189
    virtual void initialize(Flag initFlag,
			    ProblemInstat *adoptProblem = NULL,
			    Flag adoptFlag = INIT_NOTHING);

190
    /// Used in \ref initialize().
191
192
    virtual void createUhOld();

193
    /// Implementation of ProblemTimeInterface::initTimestep().
194
195
    virtual void initTimestep(AdaptInfo *adaptInfo);

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

205
206
207
    /// Returns \ref oldSolution.
    inline SystemVector *getOldSolution() 
    { 
208
      return oldSolution; 
Thomas Witkowski's avatar
Thomas Witkowski committed
209
    }
210

211
    /// Used by \ref problemInitial
212
213
    virtual void transferInitialSolution(AdaptInfo *adaptInfo);  

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

Thomas Witkowski's avatar
Thomas Witkowski committed
216
    virtual void deserialize(std::istream &in) {}
217
218

  protected:
219
    /// Space problem solved in each timestep.
220
221
    ProblemVec* problemStat;

222
    /// Solution of the last timestep.
223
224
225
226
227
228
    SystemVector *oldSolution;
  };

}

#endif