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 "patchProbes.H"
27 #include "volFields.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 void Foam::patchProbes::sampleAndWrite
36 const GeometricField<Type, fvPatchField, volMesh>& vField
39 Field<Type> values(sample(vField));
41 if (Pstream::master())
43 unsigned int w = IOstream::defaultPrecision() + 7;
44 OFstream& probeStream = *probeFilePtrs_[vField.name()];
46 probeStream << setw(w) << vField.time().value();
48 forAll(values, probeI)
50 probeStream << ' ' << setw(w) << values[probeI];
58 void Foam::patchProbes::sampleAndWrite
60 const fieldGroup<Type>& fields
63 forAll(fields, fieldI)
69 GeometricField<Type, fvPatchField, volMesh>
74 mesh_.time().timeName(),
86 objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
90 iter != objectRegistry::end()
92 == GeometricField<Type, fvPatchField, volMesh>::typeName
98 <GeometricField<Type, fvPatchField, volMesh> >
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 Foam::tmp<Foam::Field<Type> >
113 Foam::patchProbes::sample
115 const GeometricField<Type, fvPatchField, volMesh>& vField
118 const Type unsetVal(-VGREAT*pTraits<Type>::one);
120 tmp<Field<Type> > tValues
122 new Field<Type>(this->size(), unsetVal)
125 Field<Type>& values = tValues();
127 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
129 forAll(*this, probeI)
131 label faceI = elementList_[probeI];
135 label patchI = patches.whichPatch(faceI);
136 label localFaceI = patches[patchI].whichFace(faceI);
137 values[probeI] = vField.boundaryField()[patchI][localFaceI];
141 Pstream::listCombineGather(values, isNotEqOp<Type>());
142 Pstream::listCombineScatter(values);
149 Foam::tmp<Foam::Field<Type> >
150 Foam::patchProbes::sample(const word& fieldName) const
154 mesh_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
162 // ************************************************************************* //