AdaptInfo.cpp 3.04 KB
Newer Older
1
2
3
4
5
6
#include "AdaptInfo.hpp"

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

7
#include <amdis/Initfile.hpp>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

namespace AMDiS
{

  AdaptInfo::ScalContent::ScalContent(std::string prefix)
  {
    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 + "->refine bisections", refineBisections);
    Parameters::get(prefix + "->coarsen bisections", coarseBisections);
    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 name, int size)
    : name(name)
32
33
34
35
  {
    // init();
    Parameters::get(name + "->start time", startTime);
    time = startTime;
36

37
38
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);

    for (int i = 0; i < size; i++)
48
      scalContents.emplace_back(new ScalContent(name + "[" + std::to_string(i) + "]"));
49
50
51
52
53
  }


  void AdaptInfo::setScalContents(int newSize)
  {
54
    int oldSize = int(scalContents.size());
55

56
57
58
    if (newSize > oldSize) {
      for (int i = oldSize; i < newSize; ++i)
        scalContents.emplace_back(new ScalContent(name + "[" + std::to_string(i) + "]"));
59
60
61
62
63
64
    }
  }


  void AdaptInfo::printTimeErrorLowInfo() const
  {
65
    for (std::size_t i = 0; i < scalContents.size(); i++)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    {
      std::cout << "    Time error estimate     ["<<i<<"] = "
                << getTimeEstCombined(i) << "\n"
                << "    Time error estimate sum ["<<i<<"] = "
                << scalContents[i]->est_t_sum << "\n"
                << "    Time error estimate max ["<<i<<"] = "
                << scalContents[i]->est_t_max << "\n"
                << "    Time error low bound    ["<<i<<"] = "
                << scalContents[i]->timeErrLow << "\n"
                << "    Time error high bound   ["<<i<<"] = "
                << scalContents[i]->timeTolerance << "\n";
    }
  }

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

    Parameters::get(name + "->timestep", timestep);
    lastProcessedTimestep=timestep;
  }

} // end namespace AMDiS