AdaptStationary.cpp 1.25 KB
Newer Older
1
2
3
4
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

5
6
7
8
9
10
11
12
#include "AdaptStationary.hpp"

// AMDiS includes
#include "AdaptInfo.hpp"
#include "Flag.hpp"
#include "Initfile.hpp"
#include "ProblemIterationInterface.hpp"

13
14
namespace AMDiS {

15
AdaptStationary::AdaptStationary(std::string const& name,
16
                                 ProblemIterationInterface& problemIteration,
17
                                 AdaptInfo& adaptInfo)
18
  : AdaptBase(name, &problemIteration, adaptInfo)
19
{}
20

21

22
23
24
int AdaptStationary::adapt()
{
  // initial iteration
Praetorius, Simon's avatar
Praetorius, Simon committed
25
  if (adaptInfo_.spaceIteration() == -1)
26
  {
27
28
29
30
    problemIteration_->beginIteration(adaptInfo_);
    problemIteration_->oneIteration(adaptInfo_, NO_ADAPTION);
    problemIteration_->endIteration(adaptInfo_);
    adaptInfo_.incSpaceIteration();
31
32
  }

33
  // adaption loop
34
  while (!adaptInfo_.spaceToleranceReached() &&
Praetorius, Simon's avatar
Praetorius, Simon committed
35
36
          (adaptInfo_.spaceIteration() < adaptInfo_.maxSpaceIteration() ||
          adaptInfo_.maxSpaceIteration() < 0) )
37
  {
38

39
40
41
    problemIteration_->beginIteration(adaptInfo_);
    Flag adapted = problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION);
    problemIteration_->endIteration(adaptInfo_);
42
43
44
45

    if (adapted == Flag{0})
      break;

46
    adaptInfo_.incSpaceIteration();
47
48
  }

49
50
51
  return 0;
}

52
} // end namespace AMDiS