Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::pointToPointPlanarInterpolation
29
30Description
31 Interpolates between two sets of unstructured points using 2D Delaunay
32 triangulation. Used in e.g. timeVaryingMapped bcs.
33
34SourceFiles
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
49namespace Foam
50{
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
92public:
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
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
170 const coordSystem::cartesian& referenceCS() const noexcept
171 {
172 return referenceCS_;
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>
209};
210
211
212// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213
214} // End namespace Foam
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218#ifdef NoRepository
220#endif
221
222// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223
224#endif
225
226// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A Cartesian coordinate system.
Definition cartesianCS.H:68
Base class for coordinate system specification, the default coordinate system type is cartesian .
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const noexcept
Interpolation factors to face centres of underlying patch.
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
static wordList timeNames(const instantList &times)
Helper: extract words of times.
label sourceSize() const noexcept
Number of source points.
label targetSize() const noexcept
Number of target points.
autoPtr< pointToPointPlanarInterpolation > clone() const
Construct and return a clone.
bool nearestOnly() const noexcept
Whether to use nearest point only (avoids triangulation, projection).
tmp< Field< Type > > interpolate(const tmp< Field< Type > > &tsource) const
Interpolate from field on source points to dest points.
const coordSystem::cartesian & referenceCS() const noexcept
Return the Cartesian reference coordinate system.
scalar perturb() const noexcept
Perturbation factor (for triangulation).
pointToPointPlanarInterpolation(const pointToPointPlanarInterpolation &)=default
Copy construct.
const List< FixedList< label, 3 > > & nearestVertex() const noexcept
Interpolation addressing to face centres of underlying patch.
ClassName("pointToPointPlanarInterpolation")
A class for managing temporary objects.
Definition tmp.H:75
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< instant > instantList
List of instants.
Definition instantList.H:41
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.