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 -------------------------------------------------------------------------------
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::pointToPointPlanarInterpolation
28 
29 Description
30  Interpolates between two sets of unstructured points using 2D Delaunay
31  triangulation. Used in e.g. timeVaryingMapped bcs.
32 
33 SourceFiles
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 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class pointToPointPlanarInterpolation Declaration
52 \*---------------------------------------------------------------------------*/
53 
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 
92 public:
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
151  const coordSystem::cartesian& referenceCS() const
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 // ************************************************************************* //
instantList.H
Foam::pointToPointPlanarInterpolation::nearestVertex
const List< FixedList< label, 3 > > & nearestVertex() const
Definition: pointToPointPlanarInterpolation.H:162
Foam::pointToPointPlanarInterpolation::referenceCS
const coordSystem::cartesian & referenceCS() const
Return the Cartesian reference coordinate system.
Definition: pointToPointPlanarInterpolation.H:150
Foam::pointToPointPlanarInterpolation::sourceSize
label sourceSize() const
Number of source points.
Definition: pointToPointPlanarInterpolation.H:156
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::pointToPointPlanarInterpolation
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
Definition: pointToPointPlanarInterpolation.H:53
Foam::pointToPointPlanarInterpolation::perturb
scalar perturb() const
Perturbation factor (for triangulation)
Definition: pointToPointPlanarInterpolation.H:138
Foam::pointToPointPlanarInterpolation::interpolate
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
cartesianCS.H
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:44
Foam::pointToPointPlanarInterpolation::nearestVertexWeight
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const
Current interpolation factors to face centres of underlying.
Definition: pointToPointPlanarInterpolation.H:169
Foam::pointToPointPlanarInterpolation::findTime
static bool findTime(const instantList &times, const label startSampleTime, const scalar timeVal, label &lo, label &hi)
Helper: find time. Return true if successful.
Definition: pointToPointPlanarInterpolation.C:404
Foam::pointToPointPlanarInterpolation::ClassName
ClassName("pointToPointPlanarInterpolation")
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::Field< vector >
pointToPointPlanarInterpolationTemplates.C
Foam::pointToPointPlanarInterpolation::nearestOnly
bool nearestOnly() const
Whether to use nearest point only (avoids triangulation, projection)
Definition: pointToPointPlanarInterpolation.H:144
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::coordSystem::cartesian
A Cartesian coordinate system.
Definition: cartesianCS.H:69
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::FixedList< label, 3 >
Foam::pointToPointPlanarInterpolation::clone
autoPtr< pointToPointPlanarInterpolation > clone() const
Construct and return a clone.
Definition: pointToPointPlanarInterpolation.C:372
FixedList.H
Foam::pointToPointPlanarInterpolation::timeNames
static wordList timeNames(const instantList &)
Helper: extract words of times.
Definition: pointToPointPlanarInterpolation.C:389
Foam::coordinateSystem
Base class for coordinate system specification, the default coordinate system type is cartesian .
Definition: coordinateSystem.H:132
Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
pointToPointPlanarInterpolation(const pointField &sourcePoints, const pointField &destPoints, const scalar perturb, const bool nearestOnly=false)
Construct from 3D locations. Determines local coordinate system.
Definition: pointToPointPlanarInterpolation.C:315