OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Mesh.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <ostream>
29#include <vector>
30
31#ifndef _CLASSIC_FIELDS_MESH_H_
32#define _CLASSIC_FIELDS_MESH_H_
33
34namespace interpolation {
35
36class VectorMap;
37
49class Mesh {
50 public:
52 class Iterator;
53
55 inline Mesh();
57 virtual Mesh::Iterator begin() const = 0;
58
60 virtual Mesh::Iterator end() const = 0;
61
63 virtual Mesh* clone() = 0;
64
69 virtual Mesh* dual() const = 0;
70
72 inline virtual ~Mesh();
73
75 virtual void getPosition
76 (const Mesh::Iterator& it, double * position) const = 0;
77
79 virtual int getPositionDimension() const = 0;
80
82 virtual int toInteger(const Mesh::Iterator& lhs) const = 0;
83
85 virtual Mesh::Iterator getNearest(const double* position) const = 0;
86
87 protected:
90 (Mesh::Iterator& lhs, int difference) const = 0;
91
94 (Mesh::Iterator& lhs, int difference) const = 0;
95
98 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs) const = 0;
99
102 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs) const = 0;
103
105 virtual Mesh::Iterator& addOne(Mesh::Iterator& lhs) const = 0;
106
108 virtual Mesh::Iterator& subOne(Mesh::Iterator& lhs) const = 0;
109
111 virtual bool isGreater
112 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) const = 0;
113
114 public:
115 // Iterator needs to know about internal workings of the Mesh to work
116 // properly
121 friend Mesh::Iterator operator-
122 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
123 friend Mesh::Iterator operator+
124 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
125 friend Mesh::Iterator& operator-=
126 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
127 friend Mesh::Iterator& operator+=
128 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
129 friend Mesh::Iterator operator-
130 (const Mesh::Iterator& lhs, const int& rhs);
131 friend Mesh::Iterator operator+
132 (const Mesh::Iterator& lhs, const int& rhs);
133 friend Mesh::Iterator& operator-=
134 (Mesh::Iterator& lhs, const int& rhs);
135 friend Mesh::Iterator& operator+=
136 (Mesh::Iterator& lhs, const int& rhs);
137
138 friend bool operator==
139 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
140 friend bool operator!=
141 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
142 friend bool operator>=
143 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
144 friend bool operator<=
145 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
146 friend bool operator<
147 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
148 friend bool operator>
149 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
150};
151
152
170 public:
172 inline Iterator();
173
175 inline Iterator(const Mesh::Iterator& in);
176
183 inline Iterator(std::vector<int> state, const Mesh* mesh);
184
186 inline virtual ~Iterator();
187
189 inline const Mesh::Iterator& operator=(const Mesh::Iterator& rhs);
190
195 inline virtual void getPosition(double* point) const;
196
201 inline virtual std::vector<double> getPosition() const;
202
210 inline int toInteger() const;
211
213 inline std::vector<int> getState() const;
214
216 inline int& operator[](int i);
217
219 inline const int& operator[](int i) const;
220
222 inline const Mesh* getMesh() const;
223
225 virtual inline bool isOutOfBounds() const;
226
228 virtual inline void addState(const Mesh::Iterator& it);
229
230 friend class Mesh;
231 friend class ThreeDGrid;
232 friend class NDGrid;
233
238 friend Mesh::Iterator operator-
239 (const Mesh::Iterator& lhs, const int& difference);
240 friend Mesh::Iterator operator+
241 (const Mesh::Iterator& lhs, const int& difference);
242 friend Mesh::Iterator& operator-=
243 (Mesh::Iterator& lhs, const int& difference);
244 friend Mesh::Iterator& operator+=
245 (Mesh::Iterator& lhs, const int& difference);
246 friend Mesh::Iterator operator-
247 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
248 friend Mesh::Iterator operator+
249 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
250 friend Mesh::Iterator& operator-=
251 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
252 friend Mesh::Iterator& operator+=
253 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
254
255 friend bool operator==
256 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
257 friend bool operator!=
258 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
259 friend bool operator>=
260 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
261 friend bool operator<=
262 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
263 friend bool operator<
264 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
265 friend bool operator>
266 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
267
268 private:
269 const Mesh* mesh_m;
270 std::vector<int> state_m;
271};
272
275
278
281
284
287inline Mesh::Iterator operator-
288 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
289
291inline Mesh::Iterator operator+
292 (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
293
297inline Mesh::Iterator& operator-=
298 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
299
303inline Mesh::Iterator& operator+=
304 (Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
305
307inline Mesh::Iterator operator- (const Mesh::Iterator& lhs, const int& rhs);
308
310inline Mesh::Iterator operator+ (const Mesh::Iterator& lhs, const int& rhs);
311
313inline Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& rhs);
314
316inline Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& rhs);
317
319inline bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
320
322inline bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
323
327inline bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
328
332inline bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
333
337inline bool operator< (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
338
342inline bool operator> (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
343
346std::ostream& operator<<(std::ostream& out, const Mesh::Iterator& it);
347
348}
349
350#include "Fields/Interpolation/Mesh-inl.icc"
351
352#endif
353
Mesh::Iterator & operator--(Mesh::Iterator &lhs)
Mesh::Iterator operator+(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Mesh::Iterator operator-(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
bool operator<(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
bool operator==(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
bool operator>(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
bool operator>=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
bool operator!=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Mesh::Iterator & operator+=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
bool operator<=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
std::ostream & operator<<(std::ostream &out, const Mesh::Iterator &it)
Definition: Mesh.cpp:33
Mesh::Iterator & operator++(Mesh::Iterator &lhs)
Mesh::Iterator & operator-=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Base class for meshing routines.
Definition: Mesh.h:49
virtual Mesh::Iterator & addOne(Mesh::Iterator &lhs) const =0
virtual void getPosition(const Mesh::Iterator &it, double *position) const =0
friend Mesh::Iterator & operator++(Mesh::Iterator &lhs)
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const =0
virtual Mesh::Iterator & addEquals(Mesh::Iterator &lhs, int difference) const =0
virtual Mesh::Iterator & subOne(Mesh::Iterator &lhs) const =0
virtual int getPositionDimension() const =0
friend Mesh::Iterator & operator--(Mesh::Iterator &lhs)
virtual Mesh * dual() const =0
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, int difference) const =0
friend Mesh::Iterator operator--(Mesh::Iterator &lhs, int)
virtual bool isGreater(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const =0
virtual Mesh::Iterator getNearest(const double *position) const =0
virtual Mesh::Iterator end() const =0
virtual Mesh::Iterator & addEquals(Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const =0
virtual Mesh::Iterator begin() const =0
virtual int toInteger(const Mesh::Iterator &lhs) const =0
virtual Mesh * clone()=0
friend Mesh::Iterator operator++(Mesh::Iterator &lhs, int)
std::vector< int > state_m
Definition: Mesh.h:270
friend Mesh::Iterator & operator++(Mesh::Iterator &lhs)
virtual void addState(const Mesh::Iterator &it)
virtual std::vector< double > getPosition() const
Iterator(const Mesh::Iterator &in)
virtual void getPosition(double *point) const
virtual bool isOutOfBounds() const
friend Mesh::Iterator & operator--(Mesh::Iterator &lhs)
Iterator(std::vector< int > state, const Mesh *mesh)
const int & operator[](int i) const
friend Mesh::Iterator operator--(Mesh::Iterator &lhs, int)
std::vector< int > getState() const
const Mesh::Iterator & operator=(const Mesh::Iterator &rhs)
const Mesh * getMesh() const
friend Mesh::Iterator operator++(Mesh::Iterator &lhs, int)