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