PatchToPatchInterpolation.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) 2011-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::PatchToPatchInterpolation
28 
29 Description
30  Interpolation class dealing with transfer of data between two
31  primitivePatches
32 
33 SourceFiles
34  PatchToPatchInterpolation.C
35  PatchToPatchInterpolate.C
36  CalcPatchToPatchWeights.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef PatchToPatchInterpolation_H
41 #define PatchToPatchInterpolation_H
42 
43 #include "className.H"
44 #include "labelList.H"
45 #include "scalarField.H"
46 #include "pointField.H"
47 #include "FieldFields.H"
48 #include "faceList.H"
49 #include "intersection.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class PatchToPatchInterpolationName Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 TemplateName(PatchToPatchInterpolation);
61 
62 
63 /*---------------------------------------------------------------------------*\
64  Class PatchToPatchInterpolation Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class FromPatch, class ToPatch>
69 :
70  public PatchToPatchInterpolationName
71 {
72  // Private data
73 
74  //- Reference to the source patch
75  const FromPatch& fromPatch_;
76 
77  //- Reference to the target patch
78  const ToPatch& toPatch_;
79 
80  //- Type of intersection algorithm to use in projection
82 
83  //- Direction projection to use in projection
85 
86 
87  // Static data
88 
89  //- Relative merge tolerance for projected points missing the target
90  // Expressed as the fraction of min involved edge size
91  static scalar projectionTol_;
92 
93 
94  // Point addressing
95 
96  //- Face into which each point of target patch is projected
97  mutable labelList* pointAddressingPtr_;
98 
99  //- Weighting factors
100  mutable FieldField<Field, scalar>* pointWeightsPtr_;
101 
102  //- Distance to intersection for patch points
103  mutable scalarField* pointDistancePtr_;
104 
105  // Face addressing
106 
107  //- Face into which each face centre of target patch is projected
108  mutable labelList* faceAddressingPtr_;
109 
110  //- Weighting factors
111  mutable FieldField<Field, scalar>* faceWeightsPtr_;
112 
113  //- Distance to intersection for patch face centres
114  mutable scalarField* faceDistancePtr_;
115 
116 
117  // Private Member Functions
118 
119  //- No copy construct
121 
122  //- No copy assignment
123  void operator=(const PatchToPatchInterpolation&) = delete;
124 
125  //- Calculate point weights
126  void calcPointAddressing() const;
127 
128  //- Calculate face weights
129  void calcFaceAddressing() const;
130 
131  //- Clear all geometry and addressing
132  void clearOut();
133 
134 
135  //- Return reference to point addressing
136  const labelList& pointAddr() const;
137 
138  //- Return reference to point weights
139  const FieldField<Field, scalar>& pointWeights() const;
140 
141  //- Return reference to face addressing
142  const labelList& faceAddr() const;
143 
144  //- Return reference to face weights
145  const FieldField<Field, scalar>& faceWeights() const;
146 
147 
148  // Private static data members
149 
150  //- Direct hit tolerance
151  static const scalar directHitTol;
152 
153 
154 public:
155 
156  // Constructors
157 
158  //- Construct from components
160  (
161  const FromPatch& fromPatch,
162  const ToPatch& toPatch,
165  );
166 
167 
168  //- Destructor
170 
171 
172  // Member Functions
173 
174  //- Set the projection tolerance, returning the previous value
175  static scalar setProjectionTol(const scalar t)
176  {
177  if (t < -VSMALL)
178  {
180  << abort(FatalError);
181  }
182 
183  scalar oldTol = projectionTol_;
184  projectionTol_ = t;
185 
186  return oldTol;
187  }
188 
189  //- Return ype of intersection algorithm to use in projection
191  {
192  return alg_;
193  }
194 
195  //- Return direction projection to use in projection
197  {
198  return dir_;
199  }
200 
201  //- Return distance to intersection for patch points
203 
204  //- Return distance to intersection for patch face centres
206 
207  //- Correct weighting factors for moving mesh.
208  bool movePoints();
209 
210 
211  //- Interpolate point field
212  template<class Type>
213  tmp<Field<Type>> pointInterpolate(const Field<Type>& pf) const;
214 
215  template<class Type>
216  tmp<Field<Type>> pointInterpolate(const tmp<Field<Type>>& tpf) const;
217 
218  //- Interpolate face field
219  template<class Type>
220  tmp<Field<Type>> faceInterpolate(const Field<Type>& pf) const;
221 
222  template<class Type>
223  tmp<Field<Type>> faceInterpolate(const tmp<Field<Type>>& tpf) const;
224 
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 #ifdef NoRepository
233  #include "PatchToPatchInterpolation.C"
234 #endif
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
Foam::intersection::direction
direction
Definition: intersection.H:66
intersection.H
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:53
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
scalarField.H
FieldFields.H
Foam::PatchToPatchInterpolation::faceInterpolate
tmp< Field< Type > > faceInterpolate(const Field< Type > &pf) const
Interpolate face field.
Definition: PatchToPatchInterpolate.C:107
Foam::intersection::FULL_RAY
Definition: intersection.H:74
Foam::PatchToPatchInterpolation::~PatchToPatchInterpolation
~PatchToPatchInterpolation()
Destructor.
Definition: PatchToPatchInterpolation.C:135
faceList.H
Foam::PatchToPatchInterpolation::projectionAlgo
intersection::algorithm projectionAlgo() const
Return ype of intersection algorithm to use in projection.
Definition: PatchToPatchInterpolation.H:189
labelList.H
Foam::Field< scalar >
Foam::PatchToPatchInterpolation::faceDistanceToIntersection
const scalarField & faceDistanceToIntersection() const
Return distance to intersection for patch face centres.
Definition: PatchToPatchInterpolation.C:160
className.H
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Foam::intersection::algorithm
algorithm
Definition: intersection.H:72
Foam::TemplateName
TemplateName(blendedSchemeBase)
Foam::PatchToPatchInterpolation::projectionDir
intersection::direction projectionDir() const
Return direction projection to use in projection.
Definition: PatchToPatchInterpolation.H:195
Foam::FatalError
error FatalError
Foam::PatchToPatchInterpolation::setProjectionTol
static scalar setProjectionTol(const scalar t)
Set the projection tolerance, returning the previous value.
Definition: PatchToPatchInterpolation.H:174
Foam::PatchToPatchInterpolation::pointInterpolate
tmp< Field< Type > > pointInterpolate(const Field< Type > &pf) const
Interpolate point field.
Definition: PatchToPatchInterpolate.C:43
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::intersection::VECTOR
Definition: intersection.H:68
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::PatchToPatchInterpolation::pointDistanceToIntersection
const scalarField & pointDistanceToIntersection() const
Return distance to intersection for patch points.
Definition: PatchToPatchInterpolation.C:146
pointField.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::List< label >
Foam::PatchToPatchInterpolation
Interpolation class dealing with transfer of data between two primitivePatches.
Definition: PatchToPatchInterpolation.H:67
Foam::PatchToPatchInterpolation::movePoints
bool movePoints()
Correct weighting factors for moving mesh.
Definition: PatchToPatchInterpolation.C:172
PatchToPatchInterpolation.C