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

5
6
7
8
#include "AdaptInfo.hpp"

// std c++ headers
#include <iostream>
9
#include <string>
10

11
#include <amdis/Initfile.hpp>
12
13
14
15

namespace AMDiS
{

16
  AdaptInfo::ScalContent::ScalContent(std::string const& prefix)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  {
    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;
  }


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

Praetorius, Simon's avatar
Praetorius, Simon committed
39
40
41
42
43
44
45
46
47
    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_);
48
49
50
51
52
  }


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

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

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

} // end namespace AMDiS