aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/gf.hh
blob: 2711b4309a8555da2d37c2e539470e3b7e5ccbf3 (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
#ifndef GF_HH
#define GF_HH

#include <cassert>
#include <cmath>
#include <iostream>
#include <string>

#include "bbox.hh"
#include "bboxset.hh"
#include "data.hh"
#include "defs.hh"
#include "dh.hh"
#include "ggf.hh"
#include "th.hh"
#include "vect.hh"

using namespace std;



// A real grid function
template<typename T>
class gf: public ggf {

public:
  
  // Constructors
  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);
  
  // Destructors
  virtual ~gf ();
  
  
  
  // Helpers
  
  virtual gdata* typed_data (int tl, int rl, int lc, int ml) const
  {
    data<T>* const vl =
      this->vectorleader
      ? ((gf<T>*)this->vectorleader)->typed_data_pointer(tl,rl,lc,ml)
      : NULL;
    return new data<T>(this->varindex,
                       h.refcent, this->transport_operator,
                       this->vectorlength, this->vectorindex,
                       vl);
  }
  
  virtual gdata* new_typed_data () const
  {
    return new data<T>(this->varindex,
                       h.refcent, this->transport_operator,
                       1, 0, NULL);
  }
  
  
  
  // Access to the data
  
  data<T> const* typed_data_pointer (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 (data<T> const*)storage.AT(ml).AT(rl).AT(lc).AT(tl);
  }  
  data<T>* typed_data_pointer (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());
    assert (tl>=0 and tl<timelevels(ml, rl));
    return (data<T>*)storage.AT(ml).AT(rl).AT(lc).AT(tl);
  }  
  
  
  
  // Output
  virtual size_t memory () const CCTK_MEMBER_ATTRIBUTE_PURE;
  virtual ostream& output (ostream& os) const;
private:
  gf ();                        // canonical default construtor
  gf (const gf &);              // canonical copy construtor
  gf & operator= (const gf &);  // canonical copy

};



#endif // GF_HH