OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
Mesh-inl.icc
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 <vector>
29 
30 namespace interpolation {
31 // inline declarations for Mesh class - keep them in a separate file to keep the
32 // header file clean.
33 
35 }
36 
38 }
39 
41 }
42 
44  : mesh_m(in.mesh_m), state_m(in.state_m) {
45 }
46 
47 Mesh::Iterator::Iterator(std::vector<int> state, const Mesh* mesh)
48  : mesh_m(mesh), state_m(state) {
49 }
50 
52 }
53 
55  return mesh_m->toInteger(*this);
56 }
57 
58 std::vector<int> Mesh::Iterator::getState() const {
59  return state_m;
60 }
61 
63  return state_m[i];
64 }
65 
66 const int& Mesh::Iterator::operator[](int i) const {
67  return state_m[i];
68 }
69 
70 const Mesh* Mesh::Iterator::getMesh() const {
71  return mesh_m;
72 }
73 
75  mesh_m = rhs.mesh_m;
76  state_m = rhs.state_m;
77  return *this;
78 }
79 
80 void Mesh::Iterator::getPosition(double* point) const {
81  mesh_m->getPosition(*this, point);
82 }
83 
84 std::vector<double> Mesh::Iterator::getPosition() const {
85  std::vector<double> PointV(mesh_m->getPositionDimension());
86  mesh_m->getPosition(*this, &PointV[0]);
87  return PointV;
88 }
89 
91  return lhs.mesh_m->addOne(lhs);
92 }
93 
95  return lhs.mesh_m->subOne(lhs);
96 }
97 
99  Mesh::Iterator copy = lhs;
100  lhs.mesh_m->addOne(lhs);
101  return copy;
102 }
103 
105  Mesh::Iterator copy = lhs;
106  lhs.mesh_m->subOne(lhs);
107  return copy;
108 }
109 
110 Mesh::Iterator operator-
111  (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
112  Mesh::Iterator lhsCopy(lhs);
113  Mesh::Iterator lhsNew(lhs.mesh_m->subEquals(lhsCopy, rhs));
114  return lhsNew;
115 }
116 
117 Mesh::Iterator operator- (const Mesh::Iterator& lhs, const int& difference) {
118  Mesh::Iterator lhsCopy(lhs);
119  Mesh::Iterator lhsNew(lhs.mesh_m->subEquals(lhsCopy, difference));
120  return lhsNew;
121 }
122 
123 Mesh::Iterator operator+
124  (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
125  Mesh::Iterator lhsCopy(lhs);
126  Mesh::Iterator lhsNew(lhs.mesh_m->addEquals(lhsCopy, rhs));
127  return lhsNew;
128 }
129 
130 Mesh::Iterator operator+ (const Mesh::Iterator& lhs, const int& difference) {
131  Mesh::Iterator lhsCopy(lhs);
132  Mesh::Iterator lhsNew(lhs.mesh_m->addEquals(lhsCopy, difference));
133  return lhsNew;
134 }
135 
136 
138  return lhs.mesh_m->addEquals(lhs, rhs);
139 }
140 
142  return lhs.mesh_m->subEquals(lhs, rhs);
143 }
144 
145 Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& rhs) {
146  return lhs.mesh_m->addEquals(lhs, rhs);
147 }
148 
149 Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& rhs) {
150  return lhs.mesh_m->subEquals(lhs, rhs);
151 }
152 
153 
154 bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
155  if (lhs.mesh_m->isGreater(lhs, rhs) || lhs == rhs) return true;
156  return false;
157 }
158 
159 bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
160  if (lhs.mesh_m->isGreater(lhs, rhs)) return false;
161  return true;
162 }
163 
164 bool operator>(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
165  return !(lhs <= rhs);
166 }
167 
168 bool operator<(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
169  return !(lhs >= rhs);
170 }
171 
172 bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
173  if (lhs.state_m == rhs.state_m)
174  return true;
175  return false;
176 }
177 
178 bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
179  if (lhs.mesh_m == rhs.mesh_m && lhs.state_m == rhs.state_m)
180  return false;
181  return true;
182 }
183 
185  if (!mesh_m) {
186  return true;
187  }
188  Mesh::Iterator first = mesh_m->begin();
189  Mesh::Iterator last = mesh_m->end()-1;
190  for (size_t i = 0; i < state_m.size(); ++i) {
191  if (state_m[i] < first[i] || state_m[i] > last[i]) {
192  return true;
193  }
194  }
195  return false;
196 }
197 
199  for (size_t i = 0; i < state_m.size(); ++i)
200  state_m[i] += it.state_m[i];
201 }
202 
203 }
204 
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a copy
Definition: LICENSE:87
friend bool operator>(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:164
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
Definition: LICENSE:43
friend bool operator>=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:154
virtual void addState(const Mesh::Iterator &it)
Definition: Mesh-inl.icc:198
Base class for meshing routines.
Definition: Mesh.h:49
std::vector< int > state_m
Definition: Mesh.h:270
friend Mesh::Iterator operator+(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:124
friend bool operator==(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:172
const Mesh * getMesh() const
Definition: Mesh-inl.icc:70
virtual bool isGreater(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const =0
virtual Mesh::Iterator & addOne(Mesh::Iterator &lhs) const =0
friend bool operator<(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:168
virtual std::vector< double > getPosition() const
Definition: Mesh-inl.icc:84
virtual bool isOutOfBounds() const
Definition: Mesh-inl.icc:184
friend Mesh::Iterator operator--(Mesh::Iterator &lhs, int)
Definition: Mesh-inl.icc:104
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, int difference) const =0
friend Mesh::Iterator operator-(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:111
friend bool operator<=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:159
const Mesh::Iterator & operator=(const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:74
friend Mesh::Iterator & operator-=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:141
friend Mesh::Iterator operator++(Mesh::Iterator &lhs, int)
Definition: Mesh-inl.icc:98
friend bool operator!=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:178
virtual Mesh::Iterator & subOne(Mesh::Iterator &lhs) const =0
std::vector< int > getState() const
Definition: Mesh-inl.icc:58
virtual Mesh::Iterator & addEquals(Mesh::Iterator &lhs, int difference) const =0
friend Mesh::Iterator & operator+=(Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Definition: Mesh-inl.icc:137