aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/th.cc
blob: 84b896b55fef4128c729ee70b5fb957c2a7595e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <cassert>
#include <cmath>
#include <iostream>

#include "cctk.h"

#include "defs.hh"
#include "gh.hh"

#include "th.hh"

using namespace std;



// Constructors
th::th (gh& h_, const CCTK_REAL basedelta)
  : h(h_), delta(basedelta)
{
  h.add(this);
}

// Destructors
th::~th ()
{
  h.remove(this);
}

// Modifiers
void th::recompose ()
{
  const int old_mglevels = times.size();
  times.resize(h.mglevels());
  deltas.resize(h.mglevels());
  for (int ml=0; ml<h.mglevels(); ++ml) {
    const int old_reflevels = times.at(ml).size();
    times.at(ml).resize(h.reflevels());
    deltas.at(ml).resize(h.reflevels());
    for (int rl=0; rl<h.reflevels(); ++rl) {
      if (old_mglevels==0) {
        times.at(ml).at(rl) = 0;
      } else if (rl < old_reflevels) {
        // do nothing
      } else {
        times.at(ml).at(rl) = times.at(ml).at(rl-1);
      }
      if (ml==0 and rl==0) {
	deltas.at(ml).at(rl) = delta;
      } else if (ml==0) {
	deltas.at(ml).at(rl) = deltas.at(ml).at(rl-1) / h.reffact;
      } else {
	deltas.at(ml).at(rl) = deltas.at(ml-1).at(rl) * h.mgfact;
      }
    }
  }
}



// Output
void th::output (ostream& os) const
{
  os << "th:"
     << "times={";
  const char * sep = "";
  for (int ml=0; ml<h.mglevels(); ++ml) {
    for (int rl=0; rl<h.reflevels(); ++rl) {
      os << sep
         << ml << ":" << rl << ":"
	 << times.at(ml).at(rl) << "(" << deltas.at(ml).at(rl) << ")";
      sep = ",";
    }
  }
  os << "}";
}