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 \*---------------------------------------------------------------------------*/
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 void Foam::probes::sampleAndWrite
68 const GeometricField<Type, fvPatchField, volMesh>& vField
71 Field<Type> values(sample(vField));
73 if (Pstream::master())
75 unsigned int w = IOstream::defaultPrecision() + 7;
76 OFstream& os = *probeFilePtrs_[vField.name()];
78 os << setw(w) << vField.time().value();
80 forAll(values, probeI)
82 os << ' ' << setw(w) << values[probeI];
90 void Foam::probes::sampleAndWrite
92 const fieldGroup<Type>& fields
95 forAll(fields, fieldI)
101 GeometricField<Type, fvPatchField, volMesh>
106 mesh_.time().timeName(),
118 objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
122 iter != objectRegistry::end()
124 == GeometricField<Type, fvPatchField, volMesh>::typeName
130 <GeometricField<Type, fvPatchField, volMesh> >
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 Foam::tmp<Foam::Field<Type> >
147 const GeometricField<Type, fvPatchField, volMesh>& vField
150 const Type unsetVal(-VGREAT*pTraits<Type>::one);
152 tmp<Field<Type> > tValues
154 new Field<Type>(this->size(), unsetVal)
157 Field<Type>& values = tValues();
159 forAll(*this, probeI)
161 if (elementList_[probeI] >= 0)
163 values[probeI] = vField[elementList_[probeI]];
167 Pstream::listCombineGather(values, isNotEqOp<Type>());
168 Pstream::listCombineScatter(values);
175 Foam::tmp<Foam::Field<Type> >
176 Foam::probes::sample(const word& fieldName) const
180 mesh_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
188 // ************************************************************************* //