OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
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
36namespace 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 != nullptr)
189 coordinates_m->remove(this);
190 grid->add(this);
191 coordinates_m = grid;
192}
193
194void Interpolator3dGridTo3d::setX(int nCoords, double* x) {
195 if (coordinates_m != nullptr)
196 coordinates_m->setX(nCoords, x);
197}
198
199void Interpolator3dGridTo3d::setY(int nCoords, double* y) {
200 if (coordinates_m != nullptr)
201 coordinates_m->setY(nCoords, y);
202}
203
204void Interpolator3dGridTo3d::setZ(int nCoords, double* z) {
205 if (coordinates_m != nullptr)
206 coordinates_m->setZ(nCoords, z);
207}
208
210 double ***Bx, double ***By, double ***Bz,
211 interpolationAlgorithm /*algo*/)
212 : coordinates_m(nullptr) {
213 for (int i = 0; i < 3; i++)
214 interpolator_m[i] = nullptr;
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
Interpolator3dGridTo1d is an abstraction for lookup on a 3D mesh to get a 1D value.
Interpolator3dGridTo3d interpolates from 3d grid to a 3d vector.
int getNumberOfXCoords() const
Number of x coordinates in the grid.
interpolationAlgorithm
Enumerator encoding possible interpolation routines.
void setX(int nCoords, double *x)
Set x coordinates in the mesh to an arbitrary set of points.
int getNumberOfZCoords() const
Number of z coordinates in the grid.
Interpolator3dGridTo1d * interpolator_m[3]
int getNumberOfYCoords() const
Number of y coordinates in the grid.
void function(const double Point[3], double Value[3]) const
Return the interpolated data.
void functionPrime(const double Point[3], double Value[3], int axis) const
Do not use (just raises exception) - der.
unsigned int getPointDimension() const
Dimension of input points.
void setAll(ThreeDGrid *grid, double ***Bx, double ***By, double ***Bz, interpolationAlgorithm algo=TRILINEAR)
Set function and mesh data.
void setY(int nCoords, double *y)
Set y coordinates in the mesh to an arbitrary set of points.
ThreeDGrid * getMesh() const
Return a pointer to the mesh.
void setZ(int nCoords, double *z)
Set z coordinates in the mesh to an arbitrary set of points.
~Interpolator3dGridTo3d()
Delete member interpolators and remove *this from the mesh smart pointer.
unsigned int getValueDimension() const
Dimension of output values.
void setGrid(ThreeDGrid *grid)
Reset the mesh.
Interpolator3dGridTo3d(ThreeDGrid *grid, double ***Bx, double ***By, double ***Bz, interpolationAlgorithm algo=TRILINEAR)
Constructor for grids with constant spacing.
virtual void function(const Mesh::Iterator &point, double *value) const
Call function at a particular point in the mesh.
Interpolator3dGridTo3d * clone() const
Copy function (can be called on parent class)
Used to loop over some, or all, points in the mesh, as in stl Enables e.g.
ThreeDGrid holds grid information for a rectangular grid used in e.g.
Definition: ThreeDGrid.h:57
void setY(int nYCoords, double *y)
Reset y grid points - note may need to set SetConstantSpacing()
Definition: ThreeDGrid.h:450
void setZ(int nZCoords, double *z)
Reset z grid points - note may need to set SetConstantSpacing()
Definition: ThreeDGrid.h:454
int zSize() const
Get size of z data.
Definition: ThreeDGrid.h:161
void remove(VectorMap *map)
Remove *map from the maps_m list if it has not already been removed.
Definition: ThreeDGrid.cpp:245
int xSize() const
Get size of x data.
Definition: ThreeDGrid.h:155
void setX(int nXCoords, double *x)
Reset x grid points - note may need to set SetConstantSpacing()
Definition: ThreeDGrid.h:446
void add(VectorMap *map)
Add *map to the maps_m list if it has not already been added.
Definition: ThreeDGrid.cpp:257
int ySize() const
Get size of y data.
Definition: ThreeDGrid.h:158
VectorMap is an abstract class that defines mapping from one vector to another.
Definition: VectorMap.h:46
virtual void function(const double *point, double *value) const =0
Pure virtual function to fill the array value with data evaluated at point.