aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/gf.cc
blob: 8a27f9eef3ffb81ffa7a1343afcd92d4e0509e84 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <cctk.h>

#include <cassert>

#include "defs.hh"

#include "gf.hh"

using namespace std;



// Constructors
template<typename T>
gf<T>::gf (const int varindex_, const operator_type transport_operator_,
           th& t_, dh& d_,
           const int prolongation_order_time_,
           const int vectorlength_, const int vectorindex_,
           ggf* const vectorleader_)
  : ggf(varindex_, transport_operator_,
        t_, d_, prolongation_order_time_,
        vectorlength_, vectorindex_, vectorleader_)
{
  recompose_crop ();
  for (int rl=0; rl<h.reflevels(); ++rl) {
    recompose_allocate (rl);
    recompose_free_old (rl);
  } // for rl
}

// Destructors
template<typename T>
gf<T>::~gf ()
{
  for (int rl=0; rl<h.reflevels(); ++rl) {
    recompose_free (rl);
  } // for rl
}



#if 0
// Access to the data
template<typename T>
const data<T>* gf<T>::operator() (int tl, int rl, int lc, int ml) const
{
  assert (rl>=0 and rl<h.reflevels());
  assert (lc>=0 and lc<h.local_components(rl));
  assert (ml>=0 and ml<h.mglevels());
  assert (tl>=0 and tl<timelevels(ml, rl));
  return (const data<T>*)storage.AT(ml).AT(rl).AT(lc).AT(tl);
}

template<typename T>
data<T>* gf<T>::operator() (int tl, int rl, int lc, int ml)
{
  assert (rl>=0 and rl<h.reflevels());
  assert (lc>=0 and lc<h.local_components(rl));
  assert (ml>=0 and ml<h.mglevels());
  if (not (tl>=0 and tl<timelevels(ml, rl))) {
    cerr << "gf<T>::operator() "
         << "vi=" << varindex << " name=" << (varindex>=0 ? CCTK_FullName(varindex) : "") << " "
         << "pot=" << prolongation_order_time << " "
         << "tl=" << tl << " rl=" << rl << " lc=" << lc << " ml=" << ml << "\n";
  }
  assert (tl>=0 and tl<timelevels(ml, rl));
  return (data<T>*)storage.AT(ml).AT(rl).AT(lc).AT(tl);
}
#endif



// Memory usage
template<typename T>
size_t
gf<T>::
memory ()
  const
{
  return ggf::memory();
}



// Output
template<typename T>
ostream& gf<T>::output (ostream& os) const
{
  T Tdummy;
  os << "gf<" << typestring(Tdummy) << ">:"
     << varindex << "[" << CCTK_VarName(varindex) << "],"
     << "tls=" << timelevels_;
  return os;
}



#define TYPECASE(N,T)				\
template class gf<T>;

#include "typecase.hh"

#undef TYPECASE