lumpedPointInterpolator.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::lumpedPointInterpolator
28 
29 Description
30  A simple linear interpolator between two locations, which are
31  referenced by index.
32 
33  When the interpolator is built for based on searching for nearest and
34  next-nearest points, the interpolation will typically cover a (0-0.5) range
35  rather than a (0-1) range. The (0.5-1) range implies a flip in the
36  relationship of nearest vs. next-nearest.
37 
38 SourceFiles
39  lumpedPointInterpolatorI.H
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef lumpedPointInterpolator_H
44 #define lumpedPointInterpolator_H
45 
46 #include "Pair.H"
47 #include "triFace.H"
48 #include "scalarList.H"
49 #include "barycentric2D.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class lumpedPointInterpolator Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62  // Private Data
63 
64  //- The id of the nearest point
65  label nearest_;
66 
67  //- The id of the neighbour point(s)
68  label next1_, next2_;
69 
70  //- The interpolation weight for the neighbour point(s)
71  scalar weight1_, weight2_;
72 
73 
74 public:
75 
76  // Constructors
77 
78  //- Default construct, with zero weighting and invalid ids
79  inline lumpedPointInterpolator();
80 
81  //- Construct with nearest id
82  explicit inline lumpedPointInterpolator(const label id);
83 
84 
85  //- Destructor
86  ~lumpedPointInterpolator() = default;
87 
88 
89  // Member Functions
90 
91  // Access
92 
93  //- Valid if there is an associated nearest point
94  inline bool valid() const;
95 
96  //- The nearest control point, or -1 if invalid
97  inline label nearest() const;
98 
99  //- The first neighbour control point - identical to next1()
100  inline label next() const;
101 
102  //- The first neighbour control point, or -1 if invalid
103  inline label next1() const;
104 
105  //- The second neighbour control point, or -1 if invalid
106  inline label next2() const;
107 
108  //- The weighting for the nearest point
109  inline scalar weight0() const;
110 
111  //- The weighting for the first neighbour point,
112  //- this also corresponds to the logical location (interval 0-1)
113  inline scalar weight1() const;
114 
115  //- The weighting for the second neighbour point,
116  //- this also corresponds to the logical location (interval 0-1)
117  inline scalar weight2() const;
118 
119 
120  // Edit
121 
122  //- Assign the nearest point, clearing any neighbour
123  inline void nearest(const label id);
124 
125  //- Assign single neighbour control point and its weight
126  inline void next(const label id, const scalar weight);
127 
128  //- Assign the neighbour control point and its weight
129  inline void next
130  (
131  const label id,
132  const scalar weight,
133  const label position
134  );
135 
136  //- Assign all control points and their weights
137  // The triFace points [0,1,2] correspond to [nearest,next1,next2],
138  // respectively
139  inline void set(const triFace& ids, const barycentric2D& weights);
140 
141 
142  // Evalulate
143 
144  //- Linear interpolated value between nearest and next locations
145  template<class T>
146  inline T interpolate(const UList<T>& input) const;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
157 
158 #endif
159 
160 // ************************************************************************* //
scalar weight2() const
The weighting for the second neighbour point, this also corresponds to the logical location (interval...
scalar weight1() const
The weighting for the first neighbour point, this also corresponds to the logical location (interval ...
label next2() const
The second neighbour control point, or -1 if invalid.
~lumpedPointInterpolator()=default
Destructor.
T interpolate(const UList< T > &input) const
Linear interpolated value between nearest and next locations.
lumpedPointInterpolator()
Default construct, with zero weighting and invalid ids.
label nearest() const
The nearest control point, or -1 if invalid.
label next1() const
The first neighbour control point, or -1 if invalid.
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant...
Definition: Barycentric2D.H:50
A simple linear interpolator between two locations, which are referenced by index.
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:65
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:48
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:99
bool valid() const
Valid if there is an associated nearest point.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
scalar weight0() const
The weighting for the nearest point.
label next() const
The first neighbour control point - identical to next1()
Namespace for OpenFOAM.