FreeFOAM The Cross-Platform CFD Toolkit
pointPatchInterpolate.C
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) 1991-2010 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
25 
27 #include <finiteVolume/volFields.H>
28 #include <OpenFOAM/pointFields.H>
33 #include <OpenFOAM/transform.H>
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 template<class Type>
44 (
47  bool overrideFixedValue
48 ) const
49 {
50  if (debug)
51  {
52  Info<< "pointPatchInterpolation::interpolate("
53  << "const GeometricField<Type, fvPatchField, volMesh>&, "
54  << "GeometricField<Type, pointPatchField, pointMesh>&) : "
55  << "interpolating field from cells to points"
56  << endl;
57  }
58 
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
61  // patch
62 
63  const fvBoundaryMesh& bm = fvMesh_.boundary();
64  const pointBoundaryMesh& pbm = pointMesh::New(fvMesh_).boundary();
65 
66  forAll(bm, patchi)
67  {
68  if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
69  {
71 
72  // Only map the values corresponding to the points associated with
73  // faces, not "lone" points due to decomposition
75  (
76  pf.internalField(),
77  patchInterpolators_[patchi]
78  .faceToPointInterpolate(vf.boundaryField()[patchi])(),
79  bm[patchi].patch().meshPoints()
80  );
81 
82  if
83  (
84  overrideFixedValue
86  )
87  {
88  refCast<valuePointPatchField<Type> >(ppf) = ppf;
89  }
90  }
91  else if (bm[patchi].coupled())
92  {
93  // Initialise the "lone" points on the coupled patch to zero,
94  // these values are obtained from the couple-transfer
95 
96  const labelList& loneMeshPoints =
97  refCast<const coupledFacePointPatch>(pbm[patchi])
98  .loneMeshPoints();
99 
100  forAll(loneMeshPoints, i)
101  {
102  pf[loneMeshPoints[i]] = pTraits<Type>::zero;
103  }
104  }
105 
106  }
107 
108 
109  // Correct patch-patch boundary points by interpolation "around" corners
110  const labelListList& PointFaces = fvMesh_.pointFaces();
111 
112  forAll(patchPatchPoints_, pointi)
113  {
114  const label curPoint = patchPatchPoints_[pointi];
115  const labelList& curFaces = PointFaces[curPoint];
116 
117  label fI = 0;
118 
119  // Reset the boundary value before accumulation
120  pf[curPoint] = pTraits<Type>::zero;
121 
122  // Go through all the faces
123  forAll(curFaces, facei)
124  {
125  if (!fvMesh_.isInternalFace(curFaces[facei]))
126  {
127  label patchi =
128  fvMesh_.boundaryMesh().whichPatch(curFaces[facei]);
129 
130  if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
131  {
132  label faceInPatchi =
133  bm[patchi].patch().whichFace(curFaces[facei]);
134 
135  pf[curPoint] +=
136  patchPatchPointWeights_[pointi][fI]
137  *vf.boundaryField()[patchi][faceInPatchi];
138 
139  fI++;
140  }
141  }
142  }
143  }
144 
145  // Update coupled boundaries
147  {
148  if (pf.boundaryField()[patchi].coupled())
149  {
150  refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
151  .initSwapAdd(pf.internalField());
152  }
153  }
154 
156  {
157  if (pf.boundaryField()[patchi].coupled())
158  {
159  refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
160  .swapAdd(pf.internalField());
161  }
162  }
163 
164 
165  // Override constrained pointPatchField types with the constraint value.
166  // This relys on only constrained pointPatchField implementing the evaluate
167  // function
169 
170 
171  // Apply multiple constraints on edge/corner points
172  applyCornerConstraints(pf);
173 
174 
175  if (debug)
176  {
177  Info<< "pointPatchInterpolation::interpolate("
178  << "const GeometricField<Type, fvPatchField, volMesh>&, "
179  << "GeometricField<Type, pointPatchField, pointMesh>&) : "
180  << "finished interpolating field from cells to points"
181  << endl;
182  }
183 }
184 
185 
186 template<class Type>
188 (
190 ) const
191 {
192  forAll(patchPatchPointConstraintPoints_, pointi)
193  {
194  pf[patchPatchPointConstraintPoints_[pointi]] = transform
195  (
196  patchPatchPointConstraintTensors_[pointi],
197  pf[patchPatchPointConstraintPoints_[pointi]]
198  );
199  }
200 }
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // ************************ vim: set sw=4 sts=4 et: ************************ //