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 | Copyright (C) 2011-2015 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
96 
97  //- Weighting factors
99 
100  //- Distance to intersection for patch points
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
110 
111  //- Distance to intersection for patch face centres
112  mutable scalarField* faceDistancePtr_;
113 
114 
115  // Private Member Functions
116 
117  //- Disallow default bitwise copy construct
119 
120  //- Disallow default bitwise assignment
122 
123  //- Calculate point weights
124  void calcPointAddressing() const;
125 
126  //- Calculate face weights
127  void calcFaceAddressing() const;
128 
129  //- Clear all geometry and addressing
130  void clearOut();
131 
132 
133  //- Return reference to point addressing
134  const labelList& pointAddr() const;
135 
136  //- Return reference to point weights
138 
139  //- Return reference to face addressing
140  const labelList& faceAddr() const;
141 
142  //- Return reference to face weights
143  const FieldField<Field, scalar>& faceWeights() const;
144 
145 
146  // Private static data members
147 
148  //- Direct hit tolerance
149  static const scalar directHitTol;
150 
151 
152 public:
153 
154  // Constructors
155 
156  //- Construct from components
158  (
159  const FromPatch& fromPatch,
160  const ToPatch& toPatch,
163  );
164 
165 
166  //- Destructor
168 
169 
170  // Member Functions
171 
172  //- Set the projection tolerance, returning the previous value
173  static scalar setProjectionTol(const scalar t)
174  {
175  if (t < -VSMALL)
176  {
178  << abort(FatalError);
179  }
180 
181  scalar oldTol = projectionTol_;
182  projectionTol_ = t;
183 
184  return oldTol;
185  }
186 
187  //- Return ype of intersection algorithm to use in projection
189  {
190  return alg_;
191  }
192 
193  //- Return direction projection to use in projection
195  {
196  return dir_;
197  }
198 
199  //- Return distance to intersection for patch points
201 
202  //- Return distance to intersection for patch face centres
204 
205  //- Correct weighting factors for moving mesh.
206  bool movePoints();
207 
208 
209  //- Interpolate point field
210  template<class Type>
211  tmp<Field<Type> > pointInterpolate(const Field<Type>& pf) const;
212 
213  template<class Type>
214  tmp<Field<Type> > pointInterpolate(const tmp<Field<Type> >& tpf) const;
215 
216  //- Interpolate face field
217  template<class Type>
218  tmp<Field<Type> > faceInterpolate(const Field<Type>& pf) const;
219 
220  template<class Type>
221  tmp<Field<Type> > faceInterpolate(const tmp<Field<Type> >& tpf) const;
222 
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 #ifdef NoRepository
231 # include "PatchToPatchInterpolation.C"
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
Foam::intersection::direction
direction
Definition: intersection.H:63
Foam::PatchToPatchInterpolation::pointAddressingPtr_
labelList * pointAddressingPtr_
Face into which each point of target patch is projected.
Definition: PatchToPatchInterpolation.H:94
Foam::PatchToPatchInterpolation::faceAddressingPtr_
labelList * faceAddressingPtr_
Face into which each face centre of target patch is projected.
Definition: PatchToPatchInterpolation.H:105
intersection.H
Foam::FieldField
Generic field type.
Definition: FieldField.H:51
Foam::PatchToPatchInterpolation::operator=
void operator=(const PatchToPatchInterpolation &)
Disallow default bitwise assignment.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
scalarField.H
FieldFields.H
Foam::PatchToPatchInterpolation::alg_
intersection::algorithm alg_
Type of intersection algorithm to use in projection.
Definition: PatchToPatchInterpolation.H:78
Foam::PatchToPatchInterpolation::faceInterpolate
tmp< Field< Type > > faceInterpolate(const Field< Type > &pf) const
Interpolate face field.
Definition: PatchToPatchInterpolate.C:110
Foam::intersection::FULL_RAY
@ FULL_RAY
Definition: intersection.H:71
Foam::PatchToPatchInterpolation::faceAddr
const labelList & faceAddr() const
Return reference to face addressing.
Definition: PatchToPatchInterpolation.C:70
Foam::PatchToPatchInterpolation::~PatchToPatchInterpolation
~PatchToPatchInterpolation()
Destructor.
Definition: PatchToPatchInterpolation.C:134
Foam::PatchToPatchInterpolation::calcPointAddressing
void calcPointAddressing() const
Calculate point weights.
Definition: CalcPatchToPatchWeights.C:44
faceList.H
Foam::PatchToPatchInterpolation::directHitTol
static const scalar directHitTol
Direct hit tolerance.
Definition: PatchToPatchInterpolation.H:148
Foam::PatchToPatchInterpolation::projectionAlgo
intersection::algorithm projectionAlgo() const
Return ype of intersection algorithm to use in projection.
Definition: PatchToPatchInterpolation.H:187
Foam::PatchToPatchInterpolation::faceDistancePtr_
scalarField * faceDistancePtr_
Distance to intersection for patch face centres.
Definition: PatchToPatchInterpolation.H:111
labelList.H
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::PatchToPatchInterpolation::faceDistanceToIntersection
const scalarField & faceDistanceToIntersection() const
Return distance to intersection for patch face centres.
Definition: PatchToPatchInterpolation.C:159
Foam::PatchToPatchInterpolation::pointAddr
const labelList & pointAddr() const
Return reference to point addressing.
Definition: PatchToPatchInterpolation.C:44
className.H
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Foam::intersection::algorithm
algorithm
Definition: intersection.H:69
Foam::TemplateName
TemplateName(blendedSchemeBase)
Foam::PatchToPatchInterpolation::faceWeights
const FieldField< Field, scalar > & faceWeights() const
Return reference to face weights.
Definition: PatchToPatchInterpolation.C:83
Foam::PatchToPatchInterpolation::calcFaceAddressing
void calcFaceAddressing() const
Calculate face weights.
Definition: CalcPatchToPatchWeights.C:236
Foam::PatchToPatchInterpolation::projectionDir
intersection::direction projectionDir() const
Return direction projection to use in projection.
Definition: PatchToPatchInterpolation.H:193
Foam::FatalError
error FatalError
Foam::PatchToPatchInterpolation::setProjectionTol
static scalar setProjectionTol(const scalar t)
Set the projection tolerance, returning the previous value.
Definition: PatchToPatchInterpolation.H:172
Foam::PatchToPatchInterpolation::toPatch_
const ToPatch & toPatch_
Reference to the target patch.
Definition: PatchToPatchInterpolation.H:75
Foam::PatchToPatchInterpolation::pointInterpolate
tmp< Field< Type > > pointInterpolate(const Field< Type > &pf) const
Interpolate point field.
Definition: PatchToPatchInterpolate.C:41
Foam::PatchToPatchInterpolation::dir_
intersection::direction dir_
Direction projection to use in projection.
Definition: PatchToPatchInterpolation.H:81
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::intersection::VECTOR
@ VECTOR
Definition: intersection.H:65
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::PatchToPatchInterpolation::pointWeights
const FieldField< Field, scalar > & pointWeights() const
Return reference to point weights.
Definition: PatchToPatchInterpolation.C:57
Foam::PatchToPatchInterpolation::pointDistanceToIntersection
const scalarField & pointDistanceToIntersection() const
Return distance to intersection for patch points.
Definition: PatchToPatchInterpolation.C:145
pointField.H
Foam::PatchToPatchInterpolation::pointWeightsPtr_
FieldField< Field, scalar > * pointWeightsPtr_
Weighting factors.
Definition: PatchToPatchInterpolation.H:97
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
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::PatchToPatchInterpolation::fromPatch_
const FromPatch & fromPatch_
Reference to the source patch.
Definition: PatchToPatchInterpolation.H:72
Foam::PatchToPatchInterpolation::projectionTol_
static scalar projectionTol_
Relative merge tolerance for projected points missing the target.
Definition: PatchToPatchInterpolation.H:88
Foam::PatchToPatchInterpolation
Interpolation class dealing with transfer of data between two primitivePatches.
Definition: PatchToPatchInterpolation.H:65
Foam::PatchToPatchInterpolation::movePoints
bool movePoints()
Correct weighting factors for moving mesh.
Definition: PatchToPatchInterpolation.C:171
Foam::PatchToPatchInterpolation::PatchToPatchInterpolation
PatchToPatchInterpolation(const PatchToPatchInterpolation &)
Disallow default bitwise copy construct.
PatchToPatchInterpolation.C
Foam::PatchToPatchInterpolation::pointDistancePtr_
scalarField * pointDistancePtr_
Distance to intersection for patch points.
Definition: PatchToPatchInterpolation.H:100
Foam::PatchToPatchInterpolation::faceWeightsPtr_
FieldField< Field, scalar > * faceWeightsPtr_
Weighting factors.
Definition: PatchToPatchInterpolation.H:108
Foam::PatchToPatchInterpolation::clearOut
void clearOut()
Clear all geometry and addressing.
Definition: PatchToPatchInterpolation.C:95