1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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,
36 const surfaceWriter<Type>& formatter
39 // interpolator for this field
40 autoPtr<interpolation<Type> > interpolator;
42 const word& fieldName = vField.name();
43 const fileName outputDir = outputPath_/vField.time().timeName();
47 const sampledSurface& s = operator[](surfI);
53 if (interpolator.empty())
55 interpolator = interpolation<Type>::New
62 values = s.interpolate(interpolator());
66 values = s.sample(vField);
69 if (Pstream::parRun())
71 // Collect values from all processors
72 List<Field<Type> > gatheredValues(Pstream::nProcs());
73 gatheredValues[Pstream::myProcNo()] = values;
74 Pstream::gatherList(gatheredValues);
76 if (Pstream::master())
78 // Combine values into single field
81 ListListOps::combine<Field<Type> >
84 accessOp<Field<Type> >()
88 // Renumber (point data) to correspond to merged points
89 if (mergeList_[surfI].pointsMap.size() == allValues.size())
91 inplaceReorder(mergeList_[surfI].pointsMap, allValues);
92 allValues.setSize(mergeList_[surfI].points.size());
95 // Write to time directory under outputPath_
96 // skip surface without faces (eg, a failed cut-plane)
97 if (mergeList_[surfI].faces.size())
103 mergeList_[surfI].points,
104 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())
133 void Foam::sampledSurfaces::sampleAndWrite
135 fieldGroup<Type>& fields
140 // create or use existing surfaceWriter
141 if (fields.formatter.empty())
143 fields.formatter = surfaceWriter<Type>::New(writeFormat_);
146 forAll(fields, fieldI)
148 if (Pstream::master() && verbose_)
150 Pout<< "sampleAndWrite: " << fields[fieldI] << endl;
157 GeometricField<Type, fvPatchField, volMesh>
162 mesh_.time().timeName(),
175 objectRegistry::const_iterator iter =
176 mesh_.find(fields[fieldI]);
180 iter != mesh_.objectRegistry::end()
182 == GeometricField<Type, fvPatchField, volMesh>::typeName
188 <GeometricField<Type, fvPatchField, volMesh> >
201 // ************************************************************************* //