FreeFOAM The Cross-Platform CFD Toolkit
volPointInterpolate.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 
26 #include "volPointInterpolation.H"
27 #include <finiteVolume/volFields.H>
28 #include <OpenFOAM/pointFields.H>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 template<class Type>
40 (
43 ) const
44 {
45  if (debug)
46  {
47  Info<< "volPointInterpolation::interpolateInternalField("
48  << "const GeometricField<Type, fvPatchField, volMesh>&, "
49  << "GeometricField<Type, pointPatchField, pointMesh>&) : "
50  << "interpolating field from cells to points"
51  << endl;
52  }
53 
54  const labelListList& pointCells = vf.mesh().pointCells();
55 
56  // Multiply volField by weighting factor matrix to create pointField
57  forAll(pointCells, pointi)
58  {
59  const scalarList& pw = pointWeights_[pointi];
60  const labelList& ppc = pointCells[pointi];
61 
62  pf[pointi] = pTraits<Type>::zero;
63 
64  forAll(ppc, pointCelli)
65  {
66  pf[pointi] += pw[pointCelli]*vf[ppc[pointCelli]];
67  }
68  }
69 }
70 
71 
72 template<class Type>
74 (
77 ) const
78 {
79  if (debug)
80  {
81  Info<< "volPointInterpolation::interpolate("
82  << "const GeometricField<Type, fvPatchField, volMesh>&, "
83  << "GeometricField<Type, pointPatchField, pointMesh>&) : "
84  << "interpolating field from cells to points"
85  << endl;
86  }
87 
88  interpolateInternalField(vf, pf);
89 
90  // Interpolate to the patches preserving fixed value BCs
91  boundaryInterpolator_.interpolate(vf, pf, false);
92 }
93 
94 
95 template<class Type>
98 (
100  const wordList& patchFieldTypes
101 ) const
102 {
103  wordList types(patchFieldTypes);
104 
105  const pointMesh& pMesh = pointMesh::New(vf.mesh());
106 
107  // If the last patch of the pointBoundaryMesh is the global patch
108  // it must be added to the list of patchField types
109  if
110  (
111  isType<globalPointPatch>
112  (
113  pMesh.boundary()[pMesh.boundary().size() - 1]
114  )
115  )
116  {
117  types.setSize(types.size() + 1);
118  types[types.size()-1] = pMesh.boundary()[types.size()-1].type();
119  }
120 
121  // Construct tmp<pointField>
123  (
125  (
126  IOobject
127  (
128  "volPointInterpolate(" + vf.name() + ')',
129  vf.instance(),
130  pMesh.thisDb()
131  ),
132  pMesh,
133  vf.dimensions(),
134  types
135  )
136  );
137 
138  interpolateInternalField(vf, tpf());
139 
140  // Interpolate to the patches overriding fixed value BCs
141  boundaryInterpolator_.interpolate(vf, tpf(), true);
142 
143  return tpf;
144 }
145 
146 
147 template<class Type>
150 (
152  const wordList& patchFieldTypes
153 ) const
154 {
155  // Construct tmp<pointField>
157  interpolate(tvf(), patchFieldTypes);
158  tvf.clear();
159  return tpf;
160 }
161 
162 
163 template<class Type>
166 (
168 ) const
169 {
170  const pointMesh& pm = pointMesh::New(vf.mesh());
171 
173  (
175  (
176  IOobject
177  (
178  "volPointInterpolate(" + vf.name() + ')',
179  vf.instance(),
180  pm.thisDb()
181  ),
182  pm,
183  vf.dimensions()
184  )
185  );
186 
187  interpolateInternalField(vf, tpf());
188  boundaryInterpolator_.interpolate(vf, tpf(), false);
189 
190  return tpf;
191 }
192 
193 
194 template<class Type>
197 (
199 ) const
200 {
201  // Construct tmp<pointField>
203  interpolate(tvf());
204  tvf.clear();
205  return tpf;
206 }
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // ************************ vim: set sw=4 sts=4 et: ************************ //