1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::PatchToPatchInterpolation
28 Interpolation class dealing with transfer of data between two
32 PatchToPatchInterpolation.C
33 PatchToPatchInterpolate.C
34 CalcPatchToPatchWeights.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef PatchToPatchInterpolation_H
39 #define PatchToPatchInterpolation_H
41 #include "className.H"
42 #include "labelList.H"
43 #include "scalarField.H"
44 #include "pointField.H"
45 #include "FieldFields.H"
47 #include "intersection.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 /*---------------------------------------------------------------------------*\
55 Class PatchToPatchInterpolationName Declaration
56 \*---------------------------------------------------------------------------*/
58 TemplateName(PatchToPatchInterpolation);
61 /*---------------------------------------------------------------------------*\
62 Class PatchToPatchInterpolation Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class FromPatch, class ToPatch>
66 class PatchToPatchInterpolation
68 public PatchToPatchInterpolationName
72 //- Reference to the source patch
73 const FromPatch& fromPatch_;
75 //- Reference to the target patch
76 const ToPatch& toPatch_;
78 //- Type of intersection algorithm to use in projection
79 intersection::algorithm alg_;
81 //- Direction projection to use in projection
82 intersection::direction dir_;
87 //- Relative merge tolerance for projected points missing the target
88 // Expressed as the fraction of min involved edge size
89 static scalar projectionTol_;
94 //- Face into which each point of target patch is projected
95 mutable labelList* pointAddressingPtr_;
98 mutable FieldField<Field, scalar>* pointWeightsPtr_;
100 //- Distance to intersection for patch points
101 mutable scalarField* pointDistancePtr_;
105 //- Face into which each face centre of target patch is projected
106 mutable labelList* faceAddressingPtr_;
108 //- Weighting factors
109 mutable FieldField<Field, scalar>* faceWeightsPtr_;
111 //- Distance to intersection for patch face centres
112 mutable scalarField* faceDistancePtr_;
115 // Private Member Functions
117 //- Disallow default bitwise copy construct
118 PatchToPatchInterpolation(const PatchToPatchInterpolation&);
120 //- Disallow default bitwise assignment
121 void operator=(const PatchToPatchInterpolation&);
123 //- Calculate point weights
124 void calcPointAddressing() const;
126 //- Calculate face weights
127 void calcFaceAddressing() const;
129 //- Clear all geometry and addressing
133 //- Return reference to point addressing
134 const labelList& pointAddr() const;
136 //- Return reference to point weights
137 const FieldField<Field, scalar>& pointWeights() const;
139 //- Return reference to face addressing
140 const labelList& faceAddr() const;
142 //- Return reference to face weights
143 const FieldField<Field, scalar>& faceWeights() const;
146 // Private static data members
148 //- Direct hit tolerance
149 static const scalar directHitTol;
156 //- Construct from components
157 PatchToPatchInterpolation
159 const FromPatch& fromPatch,
160 const ToPatch& toPatch,
161 const intersection::algorithm alg = intersection::FULL_RAY,
162 const intersection::direction dir = intersection::VECTOR
168 ~PatchToPatchInterpolation();
173 //- Set the projection tolerance, returning the previous value
174 static scalar setProjectionTol(const scalar t)
180 "scalar PatchToPatchInterpolation::"
181 "setProjectionTol(const scalar t)"
182 ) << "Negative projection tolerance. This is not allowed."
183 << abort(FatalError);
186 scalar oldTol = projectionTol_;
192 //- Return ype of intersection algorithm to use in projection
193 intersection::algorithm projectionAlgo() const
198 //- Return direction projection to use in projection
199 intersection::direction projectionDir() const
204 //- Return distance to intersection for patch points
205 const scalarField& pointDistanceToIntersection() const;
207 //- Return distance to intersection for patch face centres
208 const scalarField& faceDistanceToIntersection() const;
210 //- Correct weighting factors for moving mesh.
214 //- Interpolate point field
216 tmp<Field<Type> > pointInterpolate(const Field<Type>& pf) const;
219 tmp<Field<Type> > pointInterpolate(const tmp<Field<Type> >& tpf) const;
221 //- Interpolate face field
223 tmp<Field<Type> > faceInterpolate(const Field<Type>& pf) const;
226 tmp<Field<Type> > faceInterpolate(const tmp<Field<Type> >& tpf) const;
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 } // End namespace Foam
236 # include "PatchToPatchInterpolation.C"
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 // ************************************************************************* //