~sophie-middleton08/maus/devel

« back to all changes in this revision

Viewing changes to src/legacy/Interface/Interpolation/TriLinearInterpolator.hh

  • Committer: Chris Rogers
  • Date: 2012-10-03 07:19:33 UTC
  • mfrom: (659.1.40 release-candidate)
  • Revision ID: chris.rogers@stfc.ac.uk-20121003071933-kgrhvl1ec6w2jmug
Tags: MAUS-v0.3, MAUS-v0.3.3
MAUS-v0.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
 
2
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 */
 
16
 
 
17
#ifndef _SRC_LEGACY_INTERFACE_INTERPOLATION_TRILINEARINTERPOLATOR_HH_
 
18
#define _SRC_LEGACY_INTERFACE_INTERPOLATION_TRILINEARINTERPOLATOR_HH_
 
19
 
 
20
#include "src/legacy/Interface/Interpolation/Interpolator3dGridTo1d.hh"
 
21
 
 
22
/** TriLinearInterpolator performs a linear interpolation in x then y then z
 
23
 *
 
24
 *  Performs a linear interpolation in x then y then z returning a 1D value.
 
25
 */
 
26
class TriLinearInterpolator : public Interpolator3dGridTo1d {
 
27
  public:
 
28
    /** Constructor for grids with constant spacing
 
29
     *
 
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
 
34
     *           owns this memory
 
35
     *  All the data handling is done at Interpolator3dGridTo1d
 
36
     */
 
37
    inline TriLinearInterpolator(ThreeDGrid *grid, double ***F);
 
38
 
 
39
    /** Copy constructor
 
40
     *
 
41
     *  Deep copies the mesh and the function data
 
42
     */
 
43
    TriLinearInterpolator(const TriLinearInterpolator& tli);
 
44
 
 
45
    /** Destructor - removes reference from the mesh and from the function data
 
46
     */
 
47
    inline ~TriLinearInterpolator();
 
48
 
 
49
    /** Get the interpolated value of the function at some point
 
50
     *
 
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
 
57
     *  to get the value.
 
58
     */
 
59
    void F(const double Point[3], double Value[1]) const;
 
60
 
 
61
    /** Copy function (can be called on parent class) */
 
62
    inline TriLinearInterpolator* Clone() const;
 
63
};
 
64
 
 
65
TriLinearInterpolator::TriLinearInterpolator(ThreeDGrid *grid, double ***F)
 
66
    : Interpolator3dGridTo1d(grid, F) {
 
67
}
 
68
 
 
69
TriLinearInterpolator::~TriLinearInterpolator() {
 
70
}
 
71
 
 
72
TriLinearInterpolator* TriLinearInterpolator::Clone() const {
 
73
    return new TriLinearInterpolator(*this);
 
74
}
 
75
 
 
76
#endif
 
77
 
 
78