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
|
/***************************************************************************
gf.cc - Grid Function
data for every element of a data hierarchy
-------------------
begin : Sun Jun 11 2000
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.cc,v 1.2 2001/03/19 21:30:19 eschnett Exp $
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <cassert>
#include "defs.hh"
#if !defined(TMPL_IMPLICIT) || !defined(GF_HH)
# include "gf.hh"
#endif
// Constructors
template<class T,int D>
gf<T,D>::gf (const string name, th<D>& t, dh<D>& d,
const int tmin, const int tmax)
: generic_gf<D>(name, t, d, tmin, tmax)
{
recompose();
}
// Destructors
template<class T,int D>
gf<T,D>::~gf () { }
// Access to the data
template<class T,int D>
const data<T,D>* gf<T,D>::operator() (int tl, int rl, int c, int ml) const {
assert (tl>=tmin && tl<=tmax);
assert (rl>=0 && rl<h.reflevels());
assert (c>=0 && c<h.components(rl));
assert (ml>=0 && ml<h.mglevels(rl,c));
return (const data<T,D>*)storage[tl-tmin][rl][c][ml];
}
template<class T,int D>
data<T,D>* gf<T,D>::operator() (int tl, int rl, int c, int ml) {
assert (tl>=tmin && tl<=tmax);
assert (rl>=0 && rl<h.reflevels());
assert (c>=0 && c<h.components(rl));
assert (ml>=0 && ml<h.mglevels(rl,c));
return (data<T,D>*)storage[tl-tmin][rl][c][ml];
}
// Output
template<class T,int D>
ostream& gf<T,D>::out (ostream& os) const {
os << "gf<" STR(T) "," << D << ">:\"" << name << "\","
<< "dt=[" << tmin << ":" << tmax<< "]";
return os;
}
#if defined(TMPL_EXPLICIT)
#define INSTANTIATE(T) \
template class gf<T,3>;
#include "instantiate"
#undef INSTANTIATE
#endif
|