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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pointPatchInterpolation.H"
27 #include "volFields.H"
28 #include "pointFields.H"
29 #include "emptyFvPatch.H"
30 #include "valuePointPatchField.H"
31 #include "coupledPointPatchField.H"
32 #include "coupledFacePointPatch.H"
33 #include "transform.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 void pointPatchInterpolation::interpolate
45 const GeometricField<Type, fvPatchField, volMesh>& vf,
46 GeometricField<Type, pointPatchField, pointMesh>& pf,
47 bool overrideFixedValue
52 Info<< "pointPatchInterpolation::interpolate("
53 << "const GeometricField<Type, fvPatchField, volMesh>&, "
54 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
55 << "interpolating field from cells to points"
59 // Interpolate patch values: over-ride the internal values for the points
60 // on the patch with the interpolated point values from the faces of the
63 const fvBoundaryMesh& bm = fvMesh_.boundary();
64 const pointBoundaryMesh& pbm = pointMesh::New(fvMesh_).boundary();
68 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
70 pointPatchField<Type>& ppf = pf.boundaryField()[patchi];
72 // Only map the values corresponding to the points associated with
73 // faces, not "lone" points due to decomposition
74 ppf.setInInternalField
77 patchInterpolators_[patchi]
78 .faceToPointInterpolate(vf.boundaryField()[patchi])(),
79 bm[patchi].patch().meshPoints()
85 && isA<valuePointPatchField<Type> >(ppf)
88 refCast<valuePointPatchField<Type> >(ppf) = ppf;
91 else if (bm[patchi].coupled())
93 // Initialise the "lone" points on the coupled patch to zero,
94 // these values are obtained from the couple-transfer
96 const labelList& loneMeshPoints =
97 refCast<const coupledFacePointPatch>(pbm[patchi])
100 forAll(loneMeshPoints, i)
102 pf[loneMeshPoints[i]] = pTraits<Type>::zero;
109 // Correct patch-patch boundary points by interpolation "around" corners
110 const labelListList& PointFaces = fvMesh_.pointFaces();
112 forAll(patchPatchPoints_, pointi)
114 const label curPoint = patchPatchPoints_[pointi];
115 const labelList& curFaces = PointFaces[curPoint];
119 // Reset the boundary value before accumulation
120 pf[curPoint] = pTraits<Type>::zero;
122 // Go through all the faces
123 forAll(curFaces, facei)
125 if (!fvMesh_.isInternalFace(curFaces[facei]))
128 fvMesh_.boundaryMesh().whichPatch(curFaces[facei]);
130 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
133 bm[patchi].patch().whichFace(curFaces[facei]);
136 patchPatchPointWeights_[pointi][fI]
137 *vf.boundaryField()[patchi][faceInPatchi];
145 // Update coupled boundaries
146 forAll(pf.boundaryField(), patchi)
148 if (pf.boundaryField()[patchi].coupled())
150 refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
151 .initSwapAdd(pf.internalField());
155 forAll(pf.boundaryField(), patchi)
157 if (pf.boundaryField()[patchi].coupled())
159 refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
160 .swapAdd(pf.internalField());
165 // Override constrained pointPatchField types with the constraint value.
166 // This relys on only constrained pointPatchField implementing the evaluate
168 pf.correctBoundaryConditions();
171 // Apply multiple constraints on edge/corner points
172 applyCornerConstraints(pf);
177 Info<< "pointPatchInterpolation::interpolate("
178 << "const GeometricField<Type, fvPatchField, volMesh>&, "
179 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
180 << "finished interpolating field from cells to points"
187 void pointPatchInterpolation::applyCornerConstraints
189 GeometricField<Type, pointPatchField, pointMesh>& pf
192 forAll(patchPatchPointConstraintPoints_, pointi)
194 pf[patchPatchPointConstraintPoints_[pointi]] = transform
196 patchPatchPointConstraintTensors_[pointi],
197 pf[patchPatchPointConstraintPoints_[pointi]]
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 } // End namespace Foam
207 // ************************************************************************* //