AdaptParaReal.h 3.28 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
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
42
43
44
45
46
47
48
49
50
51
52
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file parareal/AdaptInfo.h */

#ifndef AMDIS_PARAREAL_ADAPTINFO_H
#define AMDIS_PARAREAL_ADAPTINFO_H

#include "AdaptInstationary.h"
#include "parareal/ProblemBase.h"

namespace AMDiS {

  class AdaptParaReal : public AdaptInstationary
  {
  public:
    AdaptParaReal(const char *name, 
		  ProblemIterationInterface *problemStat,
		  AdaptInfo *info,
		  ProblemTimeInterface *problemInstat,
		  ParaRealProblemBase< DOFVector<double> > *paraProb,
		  AdaptInfo *initialInfo,
		  time_t initialTimestamp = 0)
      : AdaptInstationary(name, problemStat, info, problemInstat, initialInfo, initialTimestamp),
	coarseTimestep(0.0),
	fineTimestep(0.0),
	pararealIter(1),
	pararealProb(paraProb)
    {
      GET_PARAMETER(0, static_cast<std::string>(name) + "->coarse timestep", "%f", &coarseTimestep);
      GET_PARAMETER(0, static_cast<std::string>(name) + "->timestep", "%f", &fineTimestep);
      GET_PARAMETER(0, static_cast<std::string>(name) + "->parareal iteration", "%d", &pararealIter);
      
      TEST_EXIT(fineTimestep > 0.0)("fineTimestep must be greater than zero!\n");
      TEST_EXIT(coarseTimestep > 0.0)("coarseTimestep must be greater than zero!\n");
      TEST_EXIT(fineTimestep < coarseTimestep)("fineTimestep must be smaller than coarseTimestep!\n");
53
      TEST_EXIT(pararealIter >= 0)("ParaReal Iterations must be >= 0!\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    }

    /** \brief
     * Here, the parareal algorithm is executed.
     */
    virtual int adapt();

  protected:
    /** \brief
     * Timestep for the coarse time grid.
     */
    double coarseTimestep;
    
    /** \brief
     * Timestep for the fine time grid.
     */
    double fineTimestep;
    
    /** \brief
     * Number of parareal iterations.
     */
    int pararealIter;
    
    /** \brief
     * Pointer to the parareal problem.
     */
    ParaRealProblemBase< DOFVector<double> > *pararealProb;
  };

}

#endif // AMDIS_PARAREAL_ADAPTINFO