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 "sampledSurfaces.H"
27 #include "volFields.H"
28 #include "ListListOps.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 void Foam::sampledSurfaces::sampleAndWrite
35 const GeometricField<Type, fvPatchField, volMesh>& vField
38 // interpolator for this field
39 autoPtr< interpolation<Type> > interpolator;
41 const word& fieldName = vField.name();
42 const fileName outputDir = outputPath_/vField.time().timeName();
46 const sampledSurface& s = operator[](surfI);
52 if (interpolator.empty())
54 interpolator = interpolation<Type>::New
61 values = s.interpolate(interpolator());
65 values = s.sample(vField);
68 if (Pstream::parRun())
70 // Collect values from all processors
71 List<Field<Type> > gatheredValues(Pstream::nProcs());
72 gatheredValues[Pstream::myProcNo()] = values;
73 Pstream::gatherList(gatheredValues);
75 if (Pstream::master())
77 // Combine values into single field
80 ListListOps::combine<Field<Type> >
83 accessOp<Field<Type> >()
87 // Renumber (point data) to correspond to merged points
88 if (mergeList_[surfI].pointsMap.size() == allValues.size())
90 inplaceReorder(mergeList_[surfI].pointsMap, allValues);
91 allValues.setSize(mergeList_[surfI].points.size());
94 // Write to time directory under outputPath_
95 // skip surface without faces (eg, a failed cut-plane)
96 if (mergeList_[surfI].faces.size())
102 mergeList_[surfI].points,
103 mergeList_[surfI].faces,
113 // Write to time directory under outputPath_
114 // skip surface without faces (eg, a failed cut-plane)
115 if (s.faces().size())
134 void Foam::sampledSurfaces::sampleAndWrite
136 fieldGroup<Type>& fields
141 forAll(fields, fieldI)
143 if (Pstream::master() && verbose_)
145 Pout<< "sampleAndWrite: " << fields[fieldI] << endl;
152 GeometricField<Type, fvPatchField, volMesh>
157 mesh_.time().timeName(),
169 objectRegistry::const_iterator iter =
170 mesh_.find(fields[fieldI]);
174 iter != objectRegistry::end()
176 == GeometricField<Type, fvPatchField, volMesh>::typeName
182 <GeometricField<Type, fvPatchField, volMesh> >
194 // ************************************************************************* //