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  Copyright (C) 2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::pointToPointPlanarInterpolation
29 
30 Description
31  Interpolates between two sets of unstructured points using 2D Delaunay
32  triangulation. Used in e.g. timeVaryingMapped bcs.
33 
34 SourceFiles
35  pointToPointPlanarInterpolation.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_pointToPointPlanarInterpolation_H
40 #define Foam_pointToPointPlanarInterpolation_H
41 
42 #include "FixedList.H"
43 #include "instantList.H"
44 #include "Pair.H"
45 #include "cartesianCS.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class pointToPointPlanarInterpolation Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 {
58  // Private Data
59 
60  //- Perturbation factor
61  scalar perturb_;
62 
63  //- Use nearest point only (avoids triangulation, projection)
64  bool nearestOnly_;
65 
66  //- Cartesian reference coordinate system
67  coordSystem::cartesian referenceCS_;
68 
69  //- Number of source points (for checking)
70  label nPoints_;
71 
72  //- Interpolation addressing to face centres of underlying patch
73  List<FixedList<label, 3>> nearestVertex_;
74 
75  //- Interpolation factors to face centres of underlying 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  static coordSystem::cartesian calcCoordinateSystem(const pointField&);
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  // Generated Methods
99 
100  //- Copy construct
102  (
104  ) = default;
105 
106  //- Copy assignment
108  (
110  ) = default;
111 
112 
113  // Constructors
114 
115  //- Construct from 3D locations.
116  // Determines local coordinate system
117  // from sourcePoints and maps onto that. If nearestOnly skips any
118  // local coordinate system and triangulation and uses nearest vertex
119  // only
121  (
122  const pointField& sourcePoints,
123  const pointField& destPoints,
124  const scalar perturb,
125  const bool nearestOnly = false
126  );
127 
128  //- Construct from coordinate system and locations.
130  (
132  const pointField& sourcePoints,
133  const pointField& destPoints,
134  const scalar perturb
135  );
136 
137  //- Construct from components
139  (
140  const scalar perturb,
141  const bool nearestOnly,
143  const label sourceSize,
146  );
147 
148  //- Construct and return a clone
150  {
152  }
153 
154 
155  // Member Functions
156 
157  //- Perturbation factor (for triangulation)
158  scalar perturb() const noexcept
159  {
160  return perturb_;
161  }
162 
163  //- Whether to use nearest point only (avoids triangulation, projection)
164  bool nearestOnly() const noexcept
165  {
166  return nearestOnly_;
167  }
168 
169  //- Return the Cartesian reference coordinate system
171  {
172  return referenceCS_;
173  }
174 
175  //- Number of source points
176  label sourceSize() const noexcept
177  {
178  return nPoints_;
179  }
180 
181  //- Number of target points
182  label targetSize() const noexcept
183  {
184  return nearestVertex_.size();
185  }
186 
187  //- Interpolation addressing to face centres of underlying patch
189  {
190  return nearestVertex_;
191  }
193  //- Interpolation factors to face centres of underlying patch
195  {
196  return nearestVertexWeight_;
197  }
198 
199  //- Helper: extract words of times
200  static wordList timeNames(const instantList& times);
201 
202  //- Interpolate from field on source points to dest points
203  template<class Type>
204  tmp<Field<Type>> interpolate(const Field<Type>& sourceFld) const;
205 
206  //- Interpolate from field on source points to dest points
207  template<class Type>
208  tmp<Field<Type>> interpolate(const tmp<Field<Type>>& tsource) const;
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
Base class for coordinate system specification, the default coordinate system type is cartesian ...
static wordList timeNames(const instantList &times)
Helper: extract words of times.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
ClassName("pointToPointPlanarInterpolation")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const noexcept
Interpolation factors to face centres of underlying patch.
scalar perturb() const noexcept
Perturbation factor (for triangulation)
A Cartesian coordinate system.
Definition: cartesianCS.H:65
label targetSize() const noexcept
Number of target points.
label sourceSize() const noexcept
Number of source points.
const direction noexcept
Definition: Scalar.H:258
bool nearestOnly() const noexcept
Whether to use nearest point only (avoids triangulation, projection)
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
const List< FixedList< label, 3 > > & nearestVertex() const noexcept
Interpolation addressing to face centres of underlying patch.
autoPtr< pointToPointPlanarInterpolation > clone() const
Construct and return a clone.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
const coordSystem::cartesian & referenceCS() const noexcept
Return the Cartesian reference coordinate system.
pointToPointPlanarInterpolation(const pointToPointPlanarInterpolation &)=default
Copy construct.
Namespace for OpenFOAM.
Interpolates between two sets of unstructured points using 2D Delaunay triangulation. Used in e.g. timeVaryingMapped bcs.