OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Interpolator3dGridTo1d.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_INTERPOLATOR3DGRIDTO1D_H_
29#define _CLASSIC_FIELDS_INTERPOLATOR3DGRIDTO1D_H_
30
33
34namespace interpolation {
35
45 public:
54 inline Interpolator3dGridTo1d(ThreeDGrid* grid, double ***F);
55
61
63 inline virtual ~Interpolator3dGridTo1d();
64
66 inline virtual void function
67 (const Mesh::Iterator& point, double* value) const {
68 VectorMap::function(point, value);
69 }
70
72 virtual void function(const double Point[3], double Value[1]) const = 0;
73
75 virtual Interpolator3dGridTo1d* clone() const = 0;
76
78 inline int getNumberOfXCoords() const;
79
81 inline int getNumberOfYCoords() const;
82
85 inline int getNumberOfZCoords() const;
86
88 inline unsigned int getPointDimension() const;
89
91 inline unsigned int getValueDimension() const;
92
94 inline ThreeDGrid* getMesh() const;
95
100 inline void setGrid(ThreeDGrid* grid);
101
106 inline void setX(int nCoords, double* x);
107
112 inline void setY(int nCoords, double* y);
113
118 inline void setZ(int nCoords, double* z);
119
122 inline void setF(double*** inF);
123
126 void deleteFunc(double*** func);
127
130 inline double*** function() const;
131
134 inline void setAll(ThreeDGrid* grid, double *** F);
135
137 inline void clear();
138 protected:
140 double ***f_m;
141};
142
144 : coordinates_m(nullptr), f_m(nullptr) {
145 setAll(grid, F);
146}
147
149 : coordinates_m(nullptr), f_m(nullptr) {
150}
151
153 clear();
154}
155
157 return coordinates_m->xSize();
158}
159
161 return coordinates_m->ySize();
162}
163
165 return coordinates_m->zSize();
166}
167
169 return 3;
170}
171
173 return 1;
174}
175
177 return coordinates_m;
178}
179
180void Interpolator3dGridTo1d::setF(double*** inF) {
182 f_m = inF;
183}
184
186 if (coordinates_m != nullptr)
187 coordinates_m->remove(this);
188 grid->add(this);
189 coordinates_m = grid;
190}
191
192void Interpolator3dGridTo1d::setX(int nCoords, double* x) {
193 if (coordinates_m != nullptr)
194 coordinates_m->setX(nCoords, x);
195}
196
197void Interpolator3dGridTo1d::setY(int nCoords, double* y) {
198 if (coordinates_m != nullptr)
199 coordinates_m->setY(nCoords, y);
200}
201
202void Interpolator3dGridTo1d::setZ(int nCoords, double* z) {
203 if (coordinates_m != nullptr)
204 coordinates_m->setZ(nCoords, z);
205}
206
208 return f_m;
209}
210
212 setGrid(grid);
213 setF(F);
214}
215
218 coordinates_m->remove(this);
219}
220
221}
222#endif // _CLASSIC_FIELDS_INTERPOLATOR3DGRIDTO1D_HH_
Definition: Value.h:24
virtual void function(const Mesh::Iterator &point, double *value) const
virtual void function(const double Point[3], double Value[1]) const =0
virtual Interpolator3dGridTo1d * clone() const =0
void setAll(ThreeDGrid *grid, double ***F)
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