1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "volFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 //- comparison operator for probes class
42 void operator()(T& x, const T& y) const
44 const T unsetVal(-VGREAT*pTraits<T>::one);
50 // Note:chould check for y != unsetVal but multiple sample cells
51 // already handled in read().
55 // x is not set. y might be.
64 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
67 Foam::label Foam::probes::countFields
69 fieldGroup<Type>& fieldList,
70 const wordList& fieldTypes
73 fieldList.setSize(fieldNames_.size());
76 forAll(fieldNames_, fieldI)
81 == GeometricField<Type, fvPatchField, volMesh>::typeName
84 fieldList[nFields] = fieldNames_[fieldI];
89 fieldList.setSize(nFields);
96 void Foam::probes::sampleAndWrite
98 const GeometricField<Type, fvPatchField, volMesh>& vField
101 Field<Type> values = sample(vField);
103 if (Pstream::master())
105 unsigned int w = IOstream::defaultPrecision() + 7;
106 OFstream& probeStream = *probeFilePtrs_[vField.name()];
108 probeStream << setw(w) << vField.time().value();
110 forAll(values, probeI)
112 probeStream << ' ' << setw(w) << values[probeI];
119 template <class Type>
120 void Foam::probes::sampleAndWrite
122 const fieldGroup<Type>& fields
125 forAll(fields, fieldI)
131 GeometricField<Type, fvPatchField, volMesh>
136 obr_.time().timeName(),
137 refCast<const polyMesh>(obr_),
142 refCast<const fvMesh>(obr_)
148 objectRegistry::const_iterator iter = obr_.find(fields[fieldI]);
154 == GeometricField<Type, fvPatchField, volMesh>::typeName
160 <GeometricField<Type, fvPatchField, volMesh> >
171 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
174 Foam::tmp<Foam::Field<Type> >
177 const GeometricField<Type, fvPatchField, volMesh>& vField
180 const Type unsetVal(-VGREAT*pTraits<Type>::one);
182 tmp<Field<Type> > tValues
184 new Field<Type>(probeLocations_.size(), unsetVal)
187 Field<Type>& values = tValues();
189 forAll(probeLocations_, probeI)
191 if (cellList_[probeI] >= 0)
193 values[probeI] = vField[cellList_[probeI]];
197 Pstream::listCombineGather(values, isNotEqOp<Type>());
198 Pstream::listCombineScatter(values);
205 Foam::tmp<Foam::Field<Type> >
206 Foam::probes::sample(const word& fieldName) const
210 obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
218 // ************************************************************************* //