1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "pointPatchInterpolation.H"
28 #include "volFields.H"
29 #include "pointFields.H"
30 #include "emptyFvPatch.H"
31 #include "valuePointPatchField.H"
32 #include "coupledPointPatchField.H"
33 #include "coupledFacePointPatch.H"
34 #include "transform.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 void pointPatchInterpolation::interpolate
46 const GeometricField<Type, fvPatchField, volMesh>& vf,
47 GeometricField<Type, pointPatchField, pointMesh>& pf,
48 bool overrideFixedValue
53 Info<< "pointPatchInterpolation::interpolate("
54 << "const GeometricField<Type, fvPatchField, volMesh>&, "
55 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
56 << "interpolating field from cells to points"
60 // Interpolate patch values: over-ride the internal values for the points
61 // on the patch with the interpolated point values from the faces of the
64 const fvBoundaryMesh& bm = fvMesh_.boundary();
65 const pointBoundaryMesh& pbm = pointMesh::New(fvMesh_).boundary();
69 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
71 pointPatchField<Type>& ppf = pf.boundaryField()[patchi];
73 // Only map the values corresponding to the points associated with
74 // faces, not "lone" points due to decomposition
75 ppf.setInInternalField
78 patchInterpolators_[patchi]
79 .faceToPointInterpolate(vf.boundaryField()[patchi])(),
80 bm[patchi].patch().meshPoints()
86 && isA<valuePointPatchField<Type> >(ppf)
89 refCast<valuePointPatchField<Type> >(ppf) = ppf;
92 else if (bm[patchi].coupled())
94 // Initialise the "lone" points on the coupled patch to zero,
95 // these values are obtained from the couple-transfer
97 const labelList& loneMeshPoints =
98 refCast<const coupledFacePointPatch>(pbm[patchi])
101 forAll(loneMeshPoints, i)
103 pf[loneMeshPoints[i]] = pTraits<Type>::zero;
110 // Correct patch-patch boundary points by interpolation "around" corners
111 const labelListList& PointFaces = fvMesh_.pointFaces();
113 forAll(patchPatchPoints_, pointi)
115 const label curPoint = patchPatchPoints_[pointi];
116 const labelList& curFaces = PointFaces[curPoint];
120 // Reset the boundary value before accumulation
121 pf[curPoint] = pTraits<Type>::zero;
123 // Go through all the faces
124 forAll(curFaces, facei)
126 if (!fvMesh_.isInternalFace(curFaces[facei]))
129 fvMesh_.boundaryMesh().whichPatch(curFaces[facei]);
131 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
134 bm[patchi].patch().whichFace(curFaces[facei]);
137 patchPatchPointWeights_[pointi][fI]
138 *vf.boundaryField()[patchi][faceInPatchi];
146 // Update coupled boundaries
147 forAll(pf.boundaryField(), patchi)
149 if (pf.boundaryField()[patchi].coupled())
151 refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
152 .initSwapAdd(pf.internalField());
156 forAll(pf.boundaryField(), patchi)
158 if (pf.boundaryField()[patchi].coupled())
160 refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
161 .swapAdd(pf.internalField());
166 // Override constrained pointPatchField types with the constraint value.
167 // This relys on only constrained pointPatchField implementing the evaluate
169 pf.correctBoundaryConditions();
172 // Apply multiple constraints on edge/corner points
173 applyCornerConstraints(pf);
178 Info<< "pointPatchInterpolation::interpolate("
179 << "const GeometricField<Type, fvPatchField, volMesh>&, "
180 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
181 << "finished interpolating field from cells to points"
188 void pointPatchInterpolation::applyCornerConstraints
190 GeometricField<Type, pointPatchField, pointMesh>& pf
193 forAll(patchPatchPointConstraintPoints_, pointi)
195 pf[patchPatchPointConstraintPoints_[pointi]] = transform
197 patchPatchPointConstraintTensors_[pointi],
198 pf[patchPatchPointConstraintPoints_[pointi]]
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 } // End namespace Foam
208 // ************************************************************************* //