AdaptInfo.cpp 2.59 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
#include <config.h>
2

3
4
5
6
#include "AdaptInfo.hpp"

// std c++ headers
#include <iostream>
7
#include <string>
8

9
#include <amdis/Initfile.hpp>
10
11
12
13

namespace AMDiS
{

14
  AdaptInfo::ScalContent::ScalContent(std::string const& prefix)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  {
    Parameters::get(prefix + "->tolerance", spaceTolerance);
    Parameters::get(prefix + "->time tolerance", timeTolerance);
    Parameters::get(prefix + "->time relative tolerance", timeRelativeTolerance);
    Parameters::get(prefix + "->coarsen allowed", coarsenAllowed);
    Parameters::get(prefix + "->refinement allowed", refinementAllowed);
    Parameters::get(prefix + "->sum factor", fac_sum);
    Parameters::get(prefix + "->max factor", fac_max);

    if (timeTolerance == 0.0 && timeRelativeTolerance == 0.0)
      timeTolerance = 1.0;
    timeErrLow = timeTolerance * 0.3;
  }


30
31
  AdaptInfo::AdaptInfo(std::string const& name)
    : name_(name)
32
33
  {
    // init();
Praetorius, Simon's avatar
Praetorius, Simon committed
34
35
    Parameters::get(name + "->start time", startTime_);
    time_ = startTime_;
36

Praetorius, Simon's avatar
Praetorius, Simon committed
37
38
39
40
41
42
43
44
45
    Parameters::get(name + "->timestep", timestep_);
    Parameters::get(name + "->end time", endTime_);
    Parameters::get(name + "->max iteration", maxSpaceIteration_);
    Parameters::get(name + "->max timestep iteration", maxTimestepIteration_);
    Parameters::get(name + "->max time iteration", maxTimeIteration_);
    Parameters::get(name + "->min timestep", minTimestep_);
    Parameters::get(name + "->max timestep", maxTimestep_);
    Parameters::get(name + "->number of timesteps", nTimesteps_);
    Parameters::get(name + "->time tolerance", globalTimeTolerance_);
46
47
48
49
50
  }


  void AdaptInfo::printTimeErrorLowInfo() const
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
51
    for (auto const& scalContent : scalContents_)
52
    {
53
      auto i = scalContent.first;
54
      std::cout << "    Time error estimate     ["<<i<<"] = "
Praetorius, Simon's avatar
Praetorius, Simon committed
55
                << timeEstCombined(i) << "\n"
56
                << "    Time error estimate sum ["<<i<<"] = "
57
                << scalContent.second.est_t_sum << "\n"
58
                << "    Time error estimate max ["<<i<<"] = "
59
                << scalContent.second.est_t_max << "\n"
60
                << "    Time error low bound    ["<<i<<"] = "
61
                << scalContent.second.timeErrLow << "\n"
62
                << "    Time error high bound   ["<<i<<"] = "
63
                << scalContent.second.timeTolerance << "\n";
64
65
66
67
68
    }
  }

  void AdaptInfo::reset()
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
69
70
71
72
73
74
75
76
    spaceIteration_ = -1;
    timestepIteration_ = 0;
    timeIteration_ = 0;
    time_ = 0.0;
    timestep_ = 0.0;
    timestepNumber_ = 0;
    solverIterations_ = 0;
    solverResidual_ = 0.0;
77

Praetorius, Simon's avatar
Praetorius, Simon committed
78
79
    Parameters::get(name_ + "->timestep", timestep_);
    lastProcessedTimestep_ = timestep_;
80
81
82
  }

} // end namespace AMDiS