AdaptInfo.cpp 2.55 KB
Newer Older
1
2
3
4
#include "AdaptInfo.hpp"

// std c++ headers
#include <iostream>
5
#include <string>
6

7
#include <amdis/Initfile.hpp>
8
9
10
11

namespace AMDiS
{

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


28
29
  AdaptInfo::AdaptInfo(std::string const& name)
    : name_(name)
30
31
  {
    // init();
32
    Parameters::get(name + "->start time", startTime);
33
    time = startTime;
34

35
36
37
38
39
40
41
42
43
    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);
44
45
46
47
48
  }


  void AdaptInfo::printTimeErrorLowInfo() const
  {
49
    for (auto const& scalContent : scalContents)
50
    {
51
      auto i = scalContent.first;
52
53
54
      std::cout << "    Time error estimate     ["<<i<<"] = "
                << getTimeEstCombined(i) << "\n"
                << "    Time error estimate sum ["<<i<<"] = "
55
                << scalContent.second.est_t_sum << "\n"
56
                << "    Time error estimate max ["<<i<<"] = "
57
                << scalContent.second.est_t_max << "\n"
58
                << "    Time error low bound    ["<<i<<"] = "
59
                << scalContent.second.timeErrLow << "\n"
60
                << "    Time error high bound   ["<<i<<"] = "
61
                << scalContent.second.timeTolerance << "\n";
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    }
  }

  void AdaptInfo::reset()
  {
    spaceIteration = -1;
    timestepIteration = 0;
    timeIteration = 0;
    time = 0.0;
    timestep = 0.0;
    timestepNumber = 0;
    solverIterations = 0;
    solverResidual = 0.0;

76
    Parameters::get(name_ + "->timestep", timestep);
77
78
79
80
    lastProcessedTimestep=timestep;
  }

} // end namespace AMDiS