Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::lumpedPointInterpolator
28
29Description
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
38SourceFiles
39 lumpedPointInterpolatorI.H
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_lumpedPointInterpolator_H
44#define Foam_lumpedPointInterpolator_H
45
46#include "Pair.H"
47#include "triFace.H"
48#include "scalarList.H"
49#include "barycentric2D.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
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
74public:
75
76 // Constructors
77
78 //- Default construct, with zero weighting and invalid ids
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 //- True if there is an associated nearest point
94 inline bool good() const;
95
96 //- Same as good()
97 bool valid() const { return good(); }
98
99 //- The nearest control point, or -1 if !good()
100 inline label nearest() const;
101
102 //- The first neighbour control point - identical to next1()
103 inline label next() const;
104
105 //- The first neighbour control point, or -1 if !good()
106 inline label next1() const;
107
108 //- The second neighbour control point, or -1 if !good()
109 inline label next2() const;
110
111 //- The weighting for the nearest point
112 inline scalar weight0() const;
113
114 //- The weighting for the first neighbour point,
115 //- this also corresponds to the logical location (interval 0-1)
116 inline scalar weight1() const;
117
118 //- The weighting for the second neighbour point,
119 //- this also corresponds to the logical location (interval 0-1)
120 inline scalar weight2() const;
121
122
123 // Edit
124
125 //- Assign the nearest point, clearing any neighbour
126 inline void nearest(const label id);
127
128 //- Assign single neighbour control point and its weight
129 inline void next(const label id, const scalar weight);
130
131 //- Assign the neighbour control point and its weight
132 inline void next
133 (
134 const label id,
135 const scalar weight,
136 const label position
137 );
138
139 //- Assign all control points and their weights
140 // The triFace points [0,1,2] correspond to [nearest,next1,next2],
141 // respectively
142 inline void set(const triFace& ids, const barycentric2D& weights);
143
144
145 // Evalulate
146
147 //- Linear interpolated value between nearest and next locations
148 template<class T>
149 inline T interpolate(const UList<T>& input) const;
150};
151
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155} // End namespace Foam
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
160
161#endif
162
163// ************************************************************************* //
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
bool valid() const
Same as good().
T interpolate(const UList< T > &input) const
Linear interpolated value between nearest and next locations.
~lumpedPointInterpolator()=default
Destructor.
scalar weight2() const
The weighting for the second neighbour point, this also corresponds to the logical location (interval...
scalar weight0() const
The weighting for the nearest point.
label next2() const
The second neighbour control point, or -1 if !good().
void set(const triFace &ids, const barycentric2D &weights)
Assign all control points and their weights.
bool good() const
True if there is an associated nearest point.
lumpedPointInterpolator()
Default construct, with zero weighting and invalid ids.
label nearest() const
The nearest control point, or -1 if !good().
label next1() const
The first neighbour control point, or -1 if !good().
scalar weight1() const
The weighting for the first neighbour point, this also corresponds to the logical location (interval ...
label next() const
The first neighbour control point - identical to next1().
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition triFace.H:68
Namespace for OpenFOAM.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)