1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
3
* MAUS is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 3 of the License, or
6
* (at your option) any later version.
8
* MAUS is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with MAUS. If not, see <http://www.gnu.org/licenses/>.
17
#ifndef _SRC_LEGACY_INTERFACE_INTERPOLATION_TRILINEARINTERPOLATOR_HH_
18
#define _SRC_LEGACY_INTERFACE_INTERPOLATION_TRILINEARINTERPOLATOR_HH_
20
#include "src/legacy/Interface/Interpolation/Interpolator3dGridTo1d.hh"
22
/** TriLinearInterpolator performs a linear interpolation in x then y then z
24
* Performs a linear interpolation in x then y then z returning a 1D value.
26
class TriLinearInterpolator : public Interpolator3dGridTo1d {
28
/** Constructor for grids with constant spacing
30
* \param grid 3d mesh on which data is stored - adds a reference to *this
31
* into the mesh smart pointer thing.
32
* \param F function data with points on each element of the grid. Indexing
33
* goes like [index_x][index_y][index_z]. Interpolator3dGridTo1d now
35
* All the data handling is done at Interpolator3dGridTo1d
37
inline TriLinearInterpolator(ThreeDGrid *grid, double ***F);
41
* Deep copies the mesh and the function data
43
TriLinearInterpolator(const TriLinearInterpolator& tli);
45
/** Destructor - removes reference from the mesh and from the function data
47
inline ~TriLinearInterpolator();
49
/** Get the interpolated value of the function at some point
51
* First does bound checking, then makes linear interpolations using the
52
* standard 1d interpolation formula \n
53
* \f$y(x) \approx \frac{\Delta y}{\Delta x} dx + y_0\f$ \n
54
* \f$y(x) \approx \frac{y_1(x_1)-y_0(x_0)}{dx}(x-x_0) + y_0\f$ \n
55
* Interpolate along 4 x grid lines to make a 2D problem, then interpolate
56
* along 2 y grid lines to make a 1D problem, then finally interpolate in z
59
void F(const double Point[3], double Value[1]) const;
61
/** Copy function (can be called on parent class) */
62
inline TriLinearInterpolator* Clone() const;
65
TriLinearInterpolator::TriLinearInterpolator(ThreeDGrid *grid, double ***F)
66
: Interpolator3dGridTo1d(grid, F) {
69
TriLinearInterpolator::~TriLinearInterpolator() {
72
TriLinearInterpolator* TriLinearInterpolator::Clone() const {
73
return new TriLinearInterpolator(*this);