OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Interpolator3dGridTo3d.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 #ifndef _CLASSIC_FIELDS_INTERPOLATOR3DGRIDTO3D_HH_
29 #define _CLASSIC_FIELDS_INTERPOLATOR3DGRIDTO3D_HH_
30 
35 
36 namespace interpolation {
37 
54  public:
57 
71  double ***Bx, double ***By, double ***Bz,
73 
80 
84 
87  {return new Interpolator3dGridTo3d(*this);}
88 
96  void function(const double Point[3], double Value[3]) const;
97 
99  inline virtual void function
100  (const Mesh::Iterator& point, double* value) const {
101  VectorMap::function(point, value);
102  }
103 
106  void functionPrime(const double Point[3], double Value[3], int axis) const;
107 
109  inline int getNumberOfXCoords() const;
110 
112  inline int getNumberOfYCoords() const;
113 
115  inline int getNumberOfZCoords() const;
116 
118  inline unsigned int getPointDimension() const;
119 
121  inline unsigned int getValueDimension() const;
122 
124  inline ThreeDGrid* getMesh() const;
125 
130  inline void setGrid(ThreeDGrid* grid);
131 
136  inline void setX(int nCoords, double* x);
137 
142  inline void setY(int nCoords, double* y);
143 
148  inline void setZ(int nCoords, double* z);
149 
152  void setAll(ThreeDGrid* grid, double *** Bx, double *** By, double *** Bz,
154 
156  inline void clear();
157 
158  protected:
161 };
162 
164  return coordinates_m->xSize();
165 }
166 
168  return coordinates_m->ySize();
169 }
170 
172  return coordinates_m->zSize();
173 }
174 
176  return 3;
177 }
178 
180  return 3;
181 }
182 
184  return coordinates_m;
185 }
186 
188  if (coordinates_m != NULL)
189  coordinates_m->remove(this);
190  grid->add(this);
191  coordinates_m = grid;
192 }
193 
194 void Interpolator3dGridTo3d::setX(int nCoords, double* x) {
195  if (coordinates_m != NULL)
196  coordinates_m->setX(nCoords, x);
197 }
198 
199 void Interpolator3dGridTo3d::setY(int nCoords, double* y) {
200  if (coordinates_m != NULL)
201  coordinates_m->setY(nCoords, y);
202 }
203 
204 void Interpolator3dGridTo3d::setZ(int nCoords, double* z) {
205  if (coordinates_m != NULL)
206  coordinates_m->setZ(nCoords, z);
207 }
208 
210  double ***Bx, double ***By, double ***Bz,
211  interpolationAlgorithm /*algo*/)
212  : coordinates_m(NULL) {
213  for (int i = 0; i < 3; i++)
214  interpolator_m[i] = NULL;
215  setAll(grid, Bx, By, Bz);
216 }
217 
219  for (int i = 0; i < 3; i++)
220  delete interpolator_m[i];
221  coordinates_m->remove(this);
222 }
223 
224 }
225 
226 #endif
Definition: Value.h:24
Interpolator3dGridTo3d * clone() const
Interpolator3dGridTo1d * interpolator_m[3]
void functionPrime(const double Point[3], double Value[3], int axis) const
void setAll(ThreeDGrid *grid, double ***Bx, double ***By, double ***Bz, interpolationAlgorithm algo=TRILINEAR)
Interpolator3dGridTo3d(ThreeDGrid *grid, double ***Bx, double ***By, double ***Bz, interpolationAlgorithm algo=TRILINEAR)
void setY(int nYCoords, double *y)
Definition: ThreeDGrid.h:450
void setZ(int nZCoords, double *z)
Definition: ThreeDGrid.h:454
void remove(VectorMap *map)
Definition: ThreeDGrid.cpp:245
void setX(int nXCoords, double *x)
Definition: ThreeDGrid.h:446
void add(VectorMap *map)
Definition: ThreeDGrid.cpp:257
virtual void function(const double *point, double *value) const =0