pointToPointPlanarInterpolation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::pointToPointPlanarInterpolation
26 
27 Description
28  Interpolates between two sets of unstructured points using 2D Delaunay
29  triangulation. Used in e.g. timeVaryingMapped bcs.
30 
31 SourceFiles
32  pointToPointPlanarInterpolation.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef pointToPointPlanarInterpolation_H
37 #define pointToPointPlanarInterpolation_H
38 
39 #include "FixedList.H"
40 #include "coordinateSystem.H"
41 #include "instantList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class pointToPointPlanarInterpolation Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 {
54  // Private Data
55 
56  //- Perturbation factor
57  const scalar perturb_;
58 
59  //- Whether to use nearest point only (avoids triangulation, projection)
60  const bool nearestOnly_;
61 
62  //- Coordinate system
63  coordinateSystem referenceCS_;
64 
65  //- Number of source points (for checking)
66  label nPoints_;
67 
68  //- Current interpolation addressing to face centres of underlying
69  // patch
70  List<FixedList<label, 3>> nearestVertex_;
71 
72  //- Current interpolation factors to face centres of underlying
73  // patch
74  List<FixedList<scalar, 3>> nearestVertexWeight_;
75 
76  // Private Member Functions
77 
78  //- Calculate a local coordinate system from set of points
79  coordinateSystem calcCoordinateSystem(const pointField&) const;
80 
81  //- Calculate addressing and weights
82  void calcWeights
83  (
84  const pointField& sourcePoints,
85  const pointField& destPoints
86  );
87 
88 public:
89 
90  // Declare name of the class and its debug switch
91  ClassName("pointToPointPlanarInterpolation");
92 
93 
94  // Constructors
95 
96  //- Construct from 3D locations. Determines local coordinate system
97  // from sourcePoints and maps onto that. If nearestOnly skips any
98  // local coordinate system and triangulation and uses nearest vertex
99  // only
101  (
102  const pointField& sourcePoints,
103  const pointField& destPoints,
104  const scalar perturb,
105  const bool nearestOnly = false
106  );
107 
108  //- Construct from coordinate system and locations.
110  (
112  const pointField& sourcePoints,
113  const pointField& destPoints,
114  const scalar perturb
115  );
116 
117 
118  // Member Functions
119 
120  //- Return the coordinateSystem
121  const coordinateSystem& referenceCS() const
122  {
123  return referenceCS_;
124  }
125 
126  //- Number of source points
127  label sourceSize() const
128  {
129  return nPoints_;
130  }
131 
132  // patch
134  {
135  return nearestVertex_;
136  }
137 
138  //- Current interpolation factors to face centres of underlying
139  // patch
141  {
142  return nearestVertexWeight_;
143  }
144 
145  //- Helper: extract words of times
146  static wordList timeNames(const instantList&);
147 
148  //- Helper: find time. Return true if successful.
149  static bool findTime
150  (
151  const instantList& times,
152  const label startSampleTime,
153  const scalar timeVal,
154  label& lo,
155  label& hi
156  );
157 
158  //- Interpolate from field on source points to dest points
159  template<class Type>
160  tmp<Field<Type>> interpolate(const Field<Type>& sourceFld) const;
161 
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #ifdef NoRepository
173 #endif
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
Base class for other coordinate system specifications.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
ClassName("pointToPointPlanarInterpolation")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
label sourceSize() const
Number of source points.
static wordList timeNames(const instantList &)
Helper: extract words of times.
const List< FixedList< label, 3 > > & nearestVertex() const
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const
Current interpolation factors to face centres of underlying.
static bool findTime(const instantList &times, const label startSampleTime, const scalar timeVal, label &lo, label &hi)
Helper: find time. Return true if successful.
pointToPointPlanarInterpolation(const pointField &sourcePoints, const pointField &destPoints, const scalar perturb, const bool nearestOnly=false)
Construct from 3D locations. Determines local coordinate system.
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
const coordinateSystem & referenceCS() const
Return the coordinateSystem.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
Interpolates between two sets of unstructured points using 2D Delaunay triangulation. Used in e.g. timeVaryingMapped bcs.