OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 _OPALX_FIELDS_MESH_H_
32#define _OPALX_FIELDS_MESH_H_
33
34namespace interpolation {
35
36 class VectorMap;
37
49 class 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(const Mesh::Iterator& it, double* position) const = 0;
76
78 virtual int getPositionDimension() const = 0;
79
81 virtual int toInteger(const Mesh::Iterator& lhs) const = 0;
82
84 virtual Mesh::Iterator getNearest(const double* position) const = 0;
85
86 protected:
88 virtual Mesh::Iterator& addEquals(Mesh::Iterator& lhs, int difference) const = 0;
89
91 virtual Mesh::Iterator& subEquals(Mesh::Iterator& lhs, int difference) const = 0;
92
94 virtual Mesh::Iterator& addEquals(Mesh::Iterator& lhs, const Mesh::Iterator& rhs) const = 0;
95
97 virtual Mesh::Iterator& subEquals(Mesh::Iterator& lhs, const Mesh::Iterator& rhs) const = 0;
98
100 virtual Mesh::Iterator& addOne(Mesh::Iterator& lhs) const = 0;
101
103 virtual Mesh::Iterator& subOne(Mesh::Iterator& lhs) const = 0;
104
106 virtual bool isGreater(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) const = 0;
107
108 public:
109 // Iterator needs to know about internal workings of the Mesh to work
110 // properly
119 friend Mesh::Iterator operator-(const Mesh::Iterator& lhs, const int& rhs);
120 friend Mesh::Iterator operator+(const Mesh::Iterator& lhs, const int& rhs);
121 friend Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& rhs);
122 friend Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& rhs);
123
124 friend bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
125 friend bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
126 friend bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
127 friend bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
128 friend bool operator<(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
129 friend bool operator>(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
130 };
131
149 public:
151 inline Iterator();
152
154 inline Iterator(const Mesh::Iterator& in);
155
162 inline Iterator(std::vector<int> state, const Mesh* mesh);
163
165 inline virtual ~Iterator();
166
168 inline const Mesh::Iterator& operator=(const Mesh::Iterator& rhs);
169
174 inline virtual void getPosition(double* point) const;
175
180 inline virtual std::vector<double> getPosition() const;
181
189 inline int toInteger() const;
190
192 inline std::vector<int> getState() const;
193
195 inline int& operator[](int i);
196
198 inline const int& operator[](int i) const;
199
201 inline const Mesh* getMesh() const;
202
204 virtual inline bool isOutOfBounds() const;
205
207 virtual inline void addState(const Mesh::Iterator& it);
208
209 friend class Mesh;
210 friend class ThreeDGrid;
211 friend class NDGrid;
212
217 friend Mesh::Iterator operator-(const Mesh::Iterator& lhs, const int& difference);
218 friend Mesh::Iterator operator+(const Mesh::Iterator& lhs, const int& difference);
219 friend Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& difference);
220 friend Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& difference);
225
226 friend bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
227 friend bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
228 friend bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
229 friend bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
230 friend bool operator<(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
231 friend bool operator>(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
232
233 private:
234 const Mesh* mesh_m;
235 std::vector<int> state_m;
236 };
237
240
243
246
249
253
256
261
266
268 inline Mesh::Iterator operator-(const Mesh::Iterator& lhs, const int& rhs);
269
271 inline Mesh::Iterator operator+(const Mesh::Iterator& lhs, const int& rhs);
272
274 inline Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& rhs);
275
277 inline Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& rhs);
278
280 inline bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
281
283 inline bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
284
288 inline bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
289
293 inline bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
294
298 inline bool operator<(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
299
303 inline bool operator>(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs);
304
307 std::ostream& operator<<(std::ostream& out, const Mesh::Iterator& it);
308
309} // namespace interpolation
310
311#include "Fields/Interpolation/Mesh-inl.icc"
312
313#endif
std::vector< int > state_m
Definition Mesh.h:235
friend Mesh::Iterator & operator-=(Mesh::Iterator &lhs, const int &difference)
friend bool operator>(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator operator-(const Mesh::Iterator &lhs, const int &difference)
friend Mesh::Iterator & operator++(Mesh::Iterator &lhs)
virtual void addState(const Mesh::Iterator &it)
friend bool operator<(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
virtual std::vector< double > getPosition() const
Iterator(const Mesh::Iterator &in)
friend bool operator!=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
virtual void getPosition(double *point) const
friend Mesh::Iterator operator-(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
virtual bool isOutOfBounds() const
friend Mesh::Iterator & operator--(Mesh::Iterator &lhs)
Iterator(std::vector< int > state, const Mesh *mesh)
friend Mesh::Iterator & operator+=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend bool operator==(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
const int & operator[](int i) const
friend bool operator<=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator operator--(Mesh::Iterator &lhs, int)
std::vector< int > getState() const
friend Mesh::Iterator operator+(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator operator+(const Mesh::Iterator &lhs, const int &difference)
friend Mesh::Iterator & operator+=(Mesh::Iterator &lhs, const int &difference)
friend Mesh::Iterator & operator-=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
const Mesh::Iterator & operator=(const Mesh::Iterator &rhs)
friend bool operator>=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
const Mesh * getMesh() const
friend Mesh::Iterator operator++(Mesh::Iterator &lhs, int)
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 bool operator>(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator & operator++(Mesh::Iterator &lhs)
friend bool operator<(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator & operator-=(Mesh::Iterator &lhs, const int &rhs)
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const =0
virtual Mesh::Iterator & addEquals(Mesh::Iterator &lhs, int difference) const =0
friend bool operator!=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator operator-(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
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
friend Mesh::Iterator & operator+=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend bool operator==(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator & operator+=(Mesh::Iterator &lhs, const int &rhs)
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, int difference) const =0
friend bool operator<=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
friend Mesh::Iterator operator--(Mesh::Iterator &lhs, int)
virtual bool isGreater(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const =0
friend Mesh::Iterator operator+(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
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
friend Mesh::Iterator operator+(const Mesh::Iterator &lhs, const int &rhs)
friend Mesh::Iterator & operator-=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
virtual int toInteger(const Mesh::Iterator &lhs) const =0
friend Mesh::Iterator operator-(const Mesh::Iterator &lhs, const int &rhs)
friend bool operator>=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
virtual Mesh * clone()=0
friend Mesh::Iterator operator++(Mesh::Iterator &lhs, int)
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)