1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "sampledPatchInternalField.H"
27 #include "interpolationCellPoint.H"
28 #include "PrimitivePatchInterpolation.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 Foam::tmp<Foam::Field<Type> >
34 Foam::sampledPatchInternalField::sampleField
36 const GeometricField<Type, fvPatchField, volMesh>& vField
40 tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels().size()));
41 Field<Type>& values = tvalues();
43 forAll(patchStart(), i)
45 // Get patchface wise data by sampling internal field
46 Field<Type> interpVals = vField.internalField();
47 mappers_[i].map().distribute(interpVals);
49 // Store at correct position in values
52 i < patchStart().size()-1
54 : patchFaceLabels().size()
57 for (label triI = patchStart()[i]; triI < end; triI++)
59 values[triI] = interpVals[patchFaceLabels()[triI]];
68 Foam::tmp<Foam::Field<Type> >
69 Foam::sampledPatchInternalField::interpolateField
71 const interpolation<Type>& interpolator
77 sz += mesh().boundaryMesh()[patchIDs()[i]].size();
80 Field<Type> allPatchVals(sz);
85 // See directMappedFixedValueFvPatchField
86 const mapDistribute& distMap = mappers_[i].map();
88 // Send back sample points to processor that holds the cell.
89 // Mark cells with point::max so we know which ones we need
90 // to interpolate (since expensive).
91 vectorField samples(mappers_[i].samplePoints());
92 distMap.reverseDistribute(mesh().nCells(), point::max, samples);
94 Field<Type> patchVals(mesh().nCells());
96 forAll(samples, cellI)
98 if (samples[cellI] != point::max)
100 patchVals[cellI] = interpolator.interpolate
108 distMap.distribute(patchVals);
110 // Now patchVals holds the interpolated data in patch face order.
112 SubList<Type>(allPatchVals, patchVals.size(), sz).assign(patchVals);
113 sz += patchVals.size();
116 // Interpolate to points. Reconstruct the patch of all faces to aid
119 labelList meshFaceLabels(allPatchVals.size());
121 forAll(patchIDs(), i)
123 const polyPatch& pp = mesh().boundaryMesh()[patchIDs()[i]];
126 meshFaceLabels[sz++] = pp.start()+i;
130 indirectPrimitivePatch allPatches
132 IndirectList<face>(mesh().faces(), meshFaceLabels),
136 return PrimitivePatchInterpolation<indirectPrimitivePatch>
139 ).faceToPointInterpolate(allPatchVals);
143 // ************************************************************************* //