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 | Copyright (C) 2012-2014 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
64 
65  //- Number of source points (for checking)
67 
68  //- Current interpolation addressing to face centres of underlying
69  // patch
71 
72  //- Current interpolation factors to face centres of underlying
73  // patch
75 
76  // Private Member Functions
77 
78  //- Calculate a local coordinate system from set of points
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
133  const List<FixedList<label, 3> >& nearestVertex() const
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 succesful.
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 // ************************************************************************* //
instantList.H
Foam::pointToPointPlanarInterpolation::referenceCS
const coordinateSystem & referenceCS() const
Return the coordinateSystem.
Definition: pointToPointPlanarInterpolation.H:120
Foam::pointToPointPlanarInterpolation::nearestVertex
const List< FixedList< label, 3 > > & nearestVertex() const
Definition: pointToPointPlanarInterpolation.H:132
Foam::pointToPointPlanarInterpolation::perturb_
const scalar perturb_
Perturbation factor.
Definition: pointToPointPlanarInterpolation.H:56
Foam::pointToPointPlanarInterpolation::referenceCS_
coordinateSystem referenceCS_
Coordinate system.
Definition: pointToPointPlanarInterpolation.H:62
Foam::pointToPointPlanarInterpolation::sourceSize
label sourceSize() const
Number of source points.
Definition: pointToPointPlanarInterpolation.H:126
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::pointToPointPlanarInterpolation::nearestOnly_
const bool nearestOnly_
Whether to use nearest point only (avoids triangulation, projection)
Definition: pointToPointPlanarInterpolation.H:59
Foam::pointToPointPlanarInterpolation
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
Definition: pointToPointPlanarInterpolation.H:51
Foam::pointToPointPlanarInterpolation::interpolate
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:42
Foam::pointToPointPlanarInterpolation::nearestVertexWeight
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const
Current interpolation factors to face centres of underlying.
Definition: pointToPointPlanarInterpolation.H:139
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 succesful.
Definition: pointToPointPlanarInterpolation.C:362
coordinateSystem.H
Foam::pointToPointPlanarInterpolation::ClassName
ClassName("pointToPointPlanarInterpolation")
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::pointToPointPlanarInterpolation::nearestVertex_
List< FixedList< label, 3 > > nearestVertex_
Current interpolation addressing to face centres of underlying.
Definition: pointToPointPlanarInterpolation.H:69
Foam::pointToPointPlanarInterpolation::nPoints_
label nPoints_
Number of source points (for checking)
Definition: pointToPointPlanarInterpolation.H:65
pointToPointPlanarInterpolationTemplates.C
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::pointToPointPlanarInterpolation::nearestVertexWeight_
List< FixedList< scalar, 3 > > nearestVertexWeight_
Current interpolation factors to face centres of underlying.
Definition: pointToPointPlanarInterpolation.H:73
Foam::List
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
Foam::pointToPointPlanarInterpolation::calcWeights
void calcWeights(const pointField &sourcePoints, const pointField &destPoints)
Calculate addressing and weights.
Definition: pointToPointPlanarInterpolation.C:132
FixedList.H
Foam::pointToPointPlanarInterpolation::calcCoordinateSystem
coordinateSystem calcCoordinateSystem(const pointField &) const
Calculate a local coordinate system from set of points.
Definition: pointToPointPlanarInterpolation.C:48
Foam::pointToPointPlanarInterpolation::timeNames
static wordList timeNames(const instantList &)
Helper: extract words of times.
Definition: pointToPointPlanarInterpolation.C:347
Foam::coordinateSystem
Base class for other coordinate system specifications.
Definition: coordinateSystem.H:85
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:311