1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
27 #include "volFields.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 //- comparison operator for probes class
41 void operator()(T& x, const T& y) const
43 const T unsetVal(-VGREAT*pTraits<T>::one);
49 // Note:chould check for y != unsetVal but multiple sample cells
50 // already handled in read().
54 // x is not set. y might be.
63 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
66 Foam::label Foam::probes::countFields
68 fieldGroup<Type>& fieldList,
69 const wordList& fieldTypes
72 fieldList.setSize(fieldNames_.size());
75 forAll(fieldNames_, fieldI)
80 == GeometricField<Type, fvPatchField, volMesh>::typeName
83 fieldList[nFields] = fieldNames_[fieldI];
88 fieldList.setSize(nFields);
95 void Foam::probes::sampleAndWrite
97 const GeometricField<Type, fvPatchField, volMesh>& vField
100 Field<Type> values = sample(vField);
102 if (Pstream::master())
104 unsigned int w = IOstream::defaultPrecision() + 7;
105 OFstream& probeStream = *probeFilePtrs_[vField.name()];
107 probeStream << setw(w) << vField.time().value();
109 forAll(values, probeI)
111 probeStream << ' ' << setw(w) << values[probeI];
118 template <class Type>
119 void Foam::probes::sampleAndWrite
121 const fieldGroup<Type>& fields
124 forAll(fields, fieldI)
130 GeometricField<Type, fvPatchField, volMesh>
135 obr_.time().timeName(),
136 refCast<const polyMesh>(obr_),
141 refCast<const fvMesh>(obr_)
147 objectRegistry::const_iterator iter = obr_.find(fields[fieldI]);
153 == GeometricField<Type, fvPatchField, volMesh>::typeName
159 <GeometricField<Type, fvPatchField, volMesh> >
170 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
173 Foam::tmp<Foam::Field<Type> >
176 const GeometricField<Type, fvPatchField, volMesh>& vField
179 const Type unsetVal(-VGREAT*pTraits<Type>::one);
181 tmp<Field<Type> > tValues
183 new Field<Type>(probeLocations_.size(), unsetVal)
186 Field<Type>& values = tValues();
188 forAll(probeLocations_, probeI)
190 if (elementList_[probeI] >= 0)
192 values[probeI] = vField[elementList_[probeI]];
196 Pstream::listCombineGather(values, isNotEqOp<Type>());
197 Pstream::listCombineScatter(values);
204 Foam::tmp<Foam::Field<Type> >
205 Foam::probes::sample(const word& fieldName) const
209 obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
217 // ************************************************************************* //