pointToPointPlanarInterpolation.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) 2012-2016 OpenFOAM Foundation
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::pointToPointPlanarInterpolation
28
29Description
30 Interpolates between two sets of unstructured points using 2D Delaunay
31 triangulation. Used in e.g. timeVaryingMapped bcs.
32
33SourceFiles
34 pointToPointPlanarInterpolation.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef pointToPointPlanarInterpolation_H
39#define pointToPointPlanarInterpolation_H
40
41#include "FixedList.H"
42#include "instantList.H"
43#include "cartesianCS.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class pointToPointPlanarInterpolation Declaration
52\*---------------------------------------------------------------------------*/
55{
56 // Private data
57
58 //- Perturbation factor
59 const scalar perturb_;
60
61 //- Whether to use nearest point only (avoids triangulation, projection)
62 const bool nearestOnly_;
63
64 //- Cartesian reference coordinate system
65 coordSystem::cartesian referenceCS_;
66
67 //- Number of source points (for checking)
68 label nPoints_;
69
70 //- Current interpolation addressing to face centres of underlying
71 // patch
72 List<FixedList<label, 3>> nearestVertex_;
73
74 //- Current interpolation factors to face centres of underlying
75 // patch
76 List<FixedList<scalar, 3>> nearestVertexWeight_;
77
78
79 // Private Member Functions
80
81 //- Calculate a local coordinate system from set of points
82 coordSystem::cartesian calcCoordinateSystem(const pointField&) const;
83
84 //- Calculate addressing and weights
85 void calcWeights
86 (
87 const pointField& sourcePoints,
88 const pointField& destPoints
89 );
90
91
92public:
93
94 // Declare name of the class and its debug switch
95 ClassName("pointToPointPlanarInterpolation");
96
97
98 // Constructors
99
100 //- Construct from 3D locations. Determines local coordinate system
101 // from sourcePoints and maps onto that. If nearestOnly skips any
102 // local coordinate system and triangulation and uses nearest vertex
103 // only
105 (
106 const pointField& sourcePoints,
107 const pointField& destPoints,
108 const scalar perturb,
109 const bool nearestOnly = false
110 );
111
112 //- Construct from coordinate system and locations.
114 (
116 const pointField& sourcePoints,
117 const pointField& destPoints,
118 const scalar perturb
119 );
120
121 //- Construct from components
123 (
124 const scalar perturb,
125 const bool nearestOnly,
127 const label sourceSize,
130 );
131
132 //- Construct and return a clone
134
135
136 // Member Functions
137
138 //- Perturbation factor (for triangulation)
139 scalar perturb() const
140 {
141 return perturb_;
142 }
143
144 //- Whether to use nearest point only (avoids triangulation, projection)
145 bool nearestOnly() const
146 {
147 return nearestOnly_;
148 }
149
150 //- Return the Cartesian reference coordinate system
152 {
153 return referenceCS_;
154 }
155
156 //- Number of source points
157 label sourceSize() const
158 {
159 return nPoints_;
160 }
161
162 // patch
164 {
165 return nearestVertex_;
166 }
167
168 //- Current interpolation factors to face centres of underlying
169 // patch
171 {
172 return nearestVertexWeight_;
173 }
174
175 //- Helper: extract words of times
176 static wordList timeNames(const instantList&);
177
178 //- Helper: find time. Return true if successful.
179 static bool findTime
180 (
181 const instantList& times,
182 const label startSampleTime,
183 const scalar timeVal,
184 label& lo,
185 label& hi
186 );
187
188 //- Interpolate from field on source points to dest points
189 template<class Type>
190 tmp<Field<Type>> interpolate(const Field<Type>& sourceFld) const;
191};
192
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196} // End namespace Foam
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200#ifdef NoRepository
202#endif
203
204// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206#endif
207
208// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A Cartesian coordinate system.
Definition: cartesianCS.H:72
Base class for coordinate system specification, the default coordinate system type is cartesian .
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
static bool findTime(const instantList &times, const label startSampleTime, const scalar timeVal, label &lo, label &hi)
Helper: find time. Return true if successful.
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
scalar perturb() const
Perturbation factor (for triangulation)
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const
Current interpolation factors to face centres of underlying.
autoPtr< pointToPointPlanarInterpolation > clone() const
Construct and return a clone.
const coordSystem::cartesian & referenceCS() const
Return the Cartesian reference coordinate system.
const List< FixedList< label, 3 > > & nearestVertex() const
ClassName("pointToPointPlanarInterpolation")
static wordList timeNames(const instantList &)
Helper: extract words of times.
label sourceSize() const
Number of source points.
bool nearestOnly() const
Whether to use nearest point only (avoids triangulation, projection)
A class for managing temporary objects.
Definition: tmp.H:65
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
List< instant > instantList
List of instants.
Definition: instantList.H:47