forked from applied-numerical-algorithms-group-lbnl/Chombo_4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChombo_DataIndex.H
175 lines (145 loc) · 3.44 KB
/
Chombo_DataIndex.H
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifdef CH_LANG_CC
/*
* _______ __
* / ___/ / ___ __ _ / / ___
* / /__/ _ \/ _ \/ V \/ _ \/ _ \
* \___/_//_/\___/_/_/_/_.__/\___/
* Please refer to Copyright.txt, in Chombo's root directory.
*/
#endif
#ifndef _Chombo_DATAINDEX_H_
#define _Chombo_DATAINDEX_H_
#include <cstdlib>
#include <iostream>
#include "Chombo_MayDay.H"
#include "Chombo_parstream.H"
#include "Chombo_NamespaceHeader.H"
#ifndef WRAPPER
class BoxLayout;
class DataIterator;
class LayoutIterator;
#endif /* WRAPPER */
using std::endl;
///An index for LayoutIterator
class LayoutIndex
{
public:
///
LayoutIndex();
virtual ~LayoutIndex()
{}
// default copy and assign should be fine.
///
bool operator == (const LayoutIndex& a_rhs) const;
bool eq(const LayoutIndex& a_rhs) const
{
return *this == a_rhs;
}
///
bool operator != (const LayoutIndex& a_rhs) const
{
return !(*this == a_rhs);
}
/// returns 'true' if this DataIndex has been null constructed.
bool isNull() const;
// not user function. breaks design encapsulation. method not intended for
// users. The alternative is to make this class a friend of BoxLayoutData<T>,
// which implicitly makes this class templated, which makes no bloody sense.
// The behaviour of this method is undefined for users. bvs
int intCode() const;
int datInd() const
{
#ifdef CH_MPI
return m_datInd;
#else
//no MPI means dataindex is just a layout index
return m_index;
#endif
}
LayoutIndex(const LayoutIndex& a_input)
{
m_index = a_input.m_index;
m_datInd = a_input.m_datInd;
m_layoutIntPtr = a_input.m_layoutIntPtr;
}
///
/**
Print to the given output stream in ASCII.
*/
virtual void output() const
{
pout() << *this << endl;
}
friend std::ostream& operator<< (std::ostream& os,
const LayoutIndex& dit);
private:
friend class DataIterator;
friend class LayoutIterator;
friend class TimedDataIterator;
friend class NeighborIterator;
friend class BoxLayout;
friend class DataIndex;
friend class DisjointBoxLayout;
int m_index;
int m_datInd;
const int* m_layoutIntPtr;
LayoutIndex(int a_indexIntoBoxes,
int a_indexIntoData,
const int* a_layoutID)
:
m_index (a_indexIntoBoxes),
m_datInd(a_indexIntoData),
m_layoutIntPtr(a_layoutID)
{}
};
class DataIndex : public LayoutIndex
{
public:
explicit DataIndex(const LayoutIndex& a_promotion)
:
LayoutIndex(a_promotion)
{}
DataIndex()
:
LayoutIndex()
{}
virtual ~DataIndex()
{}
private:
friend class LayoutIterator;
friend class DataIterator;
friend class TimedDataIterator;
friend class NeighborIterator;
friend class BoxLayout;
friend class Copier;
DataIndex(int a_indexIntoBox,
int a_indexIntoData,
const int* a_layoutID)
:
LayoutIndex(a_indexIntoBox, a_indexIntoData, a_layoutID)
{
}
};
#ifndef WRAPPER
inline LayoutIndex::LayoutIndex()
:
m_index(0),
m_layoutIntPtr(NULL)
{
}
inline bool LayoutIndex::operator == (const LayoutIndex& a_rhs) const
{
return (m_index == a_rhs.m_index);
}
inline int LayoutIndex::intCode() const
{
return m_index;
}
inline bool LayoutIndex::isNull() const
{
return m_layoutIntPtr == NULL;
}
#endif
//std::ostream& operator<<(std::ostream& os, const LayoutIndex& copier);
#include "Chombo_NamespaceFooter.H"
#endif