From ec18c92f92fa6e909cd4d4dfbcd4b0f13df45b8c Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 22 Feb 2016 10:25:44 +0000 Subject: [PATCH 01/12] COMP: Updated version tag plus->stage --- etc/bashrc | 2 +- etc/cshrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 251cd34303..a57242ea8b 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -32,7 +32,7 @@ #------------------------------------------------------------------------------ export WM_PROJECT=OpenFOAM -export WM_PROJECT_VERSION=plus +export WM_PROJECT_VERSION=stage ################################################################################ # USER EDITABLE PART: Changes made here may be lost with the next upgrade diff --git a/etc/cshrc b/etc/cshrc index a7612b9852..87be39f952 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -31,7 +31,7 @@ #------------------------------------------------------------------------------ setenv WM_PROJECT OpenFOAM -setenv WM_PROJECT_VERSION plus +setenv WM_PROJECT_VERSION stage ################################################################################ # USER EDITABLE PART: Changes made here may be lost with the next upgrade From ec182c5f50adac485b22ab37cbdeefd066176478 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:25:30 +0000 Subject: [PATCH 02/12] ENH: Added surfaceReaders from old internal development line --- .../readers/ensight/ensightSurfaceReader.C | 416 ++++++++++++++++++ .../readers/ensight/ensightSurfaceReader.H | 191 ++++++++ .../ensight/ensightSurfaceReaderTemplates.C | 144 ++++++ .../sampledSurface/readers/surfaceReader.C | 51 +++ .../sampledSurface/readers/surfaceReader.H | 161 +++++++ .../sampledSurface/readers/surfaceReaderNew.C | 52 +++ 6 files changed, 1015 insertions(+) create mode 100644 src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C create mode 100644 src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.H create mode 100644 src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C create mode 100644 src/sampling/sampledSurface/readers/surfaceReader.C create mode 100644 src/sampling/sampledSurface/readers/surfaceReader.H create mode 100644 src/sampling/sampledSurface/readers/surfaceReaderNew.C diff --git a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C new file mode 100644 index 0000000000..1caabd5ad9 --- /dev/null +++ b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.C @@ -0,0 +1,416 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "ensightSurfaceReader.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(ensightSurfaceReader, 0); + addToRunTimeSelectionTable(surfaceReader, ensightSurfaceReader, fileName); +} + + +void Foam::ensightSurfaceReader::skip(const label n, IFstream& is) const +{ + label i = 0; + token t; + while (is.good() && (i < n)) + { + is >> t; + i++; + + if (debug) + { + Info<< "Skipping token " << t << endl; + } + } + + if (i != n) + { + WarningInFunction + << "Requested to skip " << n << "tokens, but stream exited after " + << i << " tokens. Last token read: " << t + << endl; + } +} + + +void Foam::ensightSurfaceReader::debugSection +( + const word& expected, + IFstream& is +) const +{ + word actual(is); + + if (expected != actual) + { + FatalIOErrorInFunction(is) + << "Expected section header '" << expected + << "' but read the word '" << actual << "'" + << exit(FatalIOError); + } +} + + +void Foam::ensightSurfaceReader::readCase(IFstream& is) +{ + if (debug) + { + InfoInFunction<< endl; + } + + if (!is.good()) + { + FatalErrorInFile + << "Cannot read file " << is.name() + << exit(FatalError); + } + + // Read the file + debugSection("FORMAT", is); + skip(3, is); // type: ensight gold + + debugSection("GEOMETRY", is); + readSkip(is, 2, meshFileName_); + + debugSection("VARIABLE", is); + + DynamicList fieldNames(10); + DynamicList fieldFileNames(10); + word fieldName; + word fieldFileName; + while (is.good()) + { + word primitiveType(is); // scalar, vector + + if (primitiveType == "TIME") + { + break; + } + + readSkip(is, 3, fieldName); // p, U etc + fieldNames.append(fieldName); + + is >> fieldFileName; // surfaceName.****.fieldName + fieldFileNames.append(fieldFileName); + } + fieldNames_.transfer(fieldNames); + fieldFileNames_.transfer(fieldFileNames); + + if (debug) + { + Info<< "fieldNames: " << fieldNames << nl + << "fieldFileNames: " << fieldFileNames << endl; + } + + // Start reading time information + skip(3, is); // time set: 1 + readSkip(is, 3, nTimeSteps_); + readSkip(is, 3, timeStartIndex_); + readSkip(is, 2, timeIncrement_); + + if (debug) + { + Info<< "nTimeSteps: " << nTimeSteps_ << nl + << "timeStartIndex: " << timeStartIndex_ << nl + << "timeIncrement: " << timeIncrement_ << endl; + } + + // Read the time values + skip(2, is); // time values: + timeValues_.setSize(nTimeSteps_); + for (label i = 0; i < nTimeSteps_; i++) + { + scalar t(readScalar(is)); + + timeValues_[i].value() = t; + // TODO: use character representation of t directly instead of + // regenerating from scalar value + timeValues_[i].name() = Foam::name(t); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::ensightSurfaceReader::ensightSurfaceReader(const fileName& fName) +: + surfaceReader(fName), + baseDir_(fName.path()), + meshFileName_(), + fieldNames_(), + fieldFileNames_(), + nTimeSteps_(0), + timeStartIndex_(0), + timeIncrement_(1), + timeValues_(), + surfPtr_(NULL) +{ + IFstream is(fName); + readCase(is); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::ensightSurfaceReader::~ensightSurfaceReader() +{} + + +// * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * // + +const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry() +{ + if (debug) + { + InfoInFunction<< endl; + } + + if (!surfPtr_.valid()) + { + IFstream is(baseDir_/meshFileName_); + + if (!is.good()) + { + FatalErrorInFile + << "Cannot read file " << is.name() + << exit(FatalError); + } + + token t; + while (is.good()) + { + is >> t; + + if (t.isWord()) + { + word wordToken = t.wordToken(); + if (wordToken == "coordinates") + { + break; + } + } + } + + label nPoints(readLabel(is)); + + if (debug) + { + Info<< "nPoints: " << nPoints << endl; + } + + pointField points(nPoints); + { + scalarField x(nPoints); + for (label dir = 0; dir < 3; dir++) + { + forAll(points, pointI) + { + x[pointI] = readScalar(is); + } + + points.replace(dir, x); + } + } + + + // Read faces - may be a mix of tris, quads and polys + DynamicList faces(ceil(nPoints/3)); + + while (is.good()) + { + token t(is); + + if (is.eof()) + { + break; + } + + word faceType(t.wordToken()); + + if (debug) + { + Info<< "faceType: " << faceType << endl; + } + + label nFace(readLabel(is)); + + if (debug) + { + Info<< "nFace: " << nFace << endl; + } + + if (faceType == "tria3") + { + label np = 3; + for (label faceI = 0; faceI < nFace; faceI++) + { + face f(np); + for (label fpI = 0; fpI < np; fpI++) + { + f[fpI] = readLabel(is); + } + + faces.append(f); + } + } + else if (faceType == "quad4") + { + label np = 4; + for (label faceI = 0; faceI < nFace; faceI++) + { + face f(np); + for (label fpI = 0; fpI < np; fpI++) + { + f[fpI] = readLabel(is); + } + + faces.append(f); + } + } + else if (faceType == "nsided") + { + labelList np(nFace); + for (label faceI = 0; faceI < nFace; faceI++) + { + np[faceI] = readLabel(is); + } + for (label faceI = 0; faceI < nFace; faceI++) + { + face f(np[faceI]); + for (label fpI = 0; fpI < f.size(); fpI++) + { + f[fpI] = readLabel(is); + } + + faces.append(f); + } + } + else if (faceType != "") + { + WarningInFunction + << "Unknown face type: " << faceType + << ". Aborting read and continuing with current elements " + << "only" << endl; + } + } + + if (debug) + { + Info<< "read nFaces: " << faces.size() << endl; + } + + forAll(faces, faceI) + { + face& f = faces[faceI]; + + forAll(f, fpI) + { + f[fpI]--; + } + } + + surfPtr_.reset(new meshedSurface(xferMove(points), faces.xfer())); + } + + return surfPtr_(); +} + + +Foam::instantList Foam::ensightSurfaceReader::times() const +{ + return timeValues_; +} + + +Foam::wordList Foam::ensightSurfaceReader::fieldNames +( + const label timeIndex +) const +{ + return fieldNames_; +} + + +Foam::tmp > Foam::ensightSurfaceReader::field +( + const label timeIndex, + const label fieldIndex, + const scalar& refValue +) const +{ + return readField(timeIndex, fieldIndex); +} + + +Foam::tmp > Foam::ensightSurfaceReader::field +( + const label timeIndex, + const label fieldIndex, + const vector& refValue +) const +{ + return readField(timeIndex, fieldIndex); +} + + +Foam::tmp > +Foam::ensightSurfaceReader::field +( + const label timeIndex, + const label fieldIndex, + const sphericalTensor& refValue +) const +{ + return readField(timeIndex, fieldIndex); +} + + +Foam::tmp > Foam::ensightSurfaceReader::field +( + const label timeIndex, + const label fieldIndex, + const symmTensor& refValue +) const +{ + return readField(timeIndex, fieldIndex); +} + + +Foam::tmp > Foam::ensightSurfaceReader::field +( + const label timeIndex, + const label fieldIndex, + const tensor& refValue +) const +{ + return readField(timeIndex, fieldIndex); +} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.H b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.H new file mode 100644 index 0000000000..e0b9afd453 --- /dev/null +++ b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReader.H @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::ensightensightSurfaceReader + +Description + Ensight format surface reader + +SourceFiles + ensightSurfaceReader.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ensightSurfaceReader_H +#define ensightSurfaceReader_H + +#include "surfaceReader.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ensightSurfaceReader Declaration +\*---------------------------------------------------------------------------*/ + +class ensightSurfaceReader +: + public surfaceReader +{ +protected: + + // Protected Data + + //- Base directory + fileName baseDir_; + + //- Name of mesh file + word meshFileName_; + + //- Field names + List fieldNames_; + + //- Field file names + List fieldFileNames_; + + //- Number of time steps + label nTimeSteps_; + + //- Start time index + label timeStartIndex_; + + //- Time increment + label timeIncrement_; + + //- Times + instantList timeValues_; + + //- Pointer to the surface + autoPtr surfPtr_; + + + // Protected Member Functions + + //- Read and check a section header + void debugSection(const word& expected, IFstream& is) const; + + //- Read the case file + void readCase(IFstream& is); + + //- Helper function to skip forward n steps in stream + void skip(const label n, IFstream& is) const; + + //- Helper function to return Type after skipping n tokens + template + void readSkip(IFstream& is, const label nSkip, Type& value) const; + + //- Helper function to return a field + template + tmp > readField + ( + const label timeIndex, + const label fieldIndex + ) const; + + +public: + + //- Runtime type information + TypeName("ensight"); + + // Constructors + + //- Construct from fileName + ensightSurfaceReader(const fileName& fName); + + + //- Destructor + virtual ~ensightSurfaceReader(); + + + // Member Functions + + //- Return a reference to the surface geometry + virtual const meshedSurface& geometry(); + + //- Return a list of the available times + virtual instantList times() const; + + //- Return a list of the available fields at a given time + virtual wordList fieldNames(const label timeIndex) const; + + //- Return a scalar field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const scalar& refValue = pTraits::zero + ) const; + + //- Return a scalar field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const vector& refValue = pTraits::zero + ) const; + + //- Return a sphericalTensor field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const sphericalTensor& reValue = pTraits::zero + ) const; + + //- Return a symmTensor field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const symmTensor& reValue = pTraits::zero + ) const; + + //- Return a tensor field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const tensor& reValue = pTraits::zero + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "ensightSurfaceReaderTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C new file mode 100644 index 0000000000..edb89955a5 --- /dev/null +++ b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include +#include + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +void Foam::ensightSurfaceReader::readSkip +( + IFstream& is, + const label nSkip, + Type& value +) const +{ + skip(nSkip, is); + + is >> value; +} + + +template +Foam::tmp > Foam::ensightSurfaceReader::readField +( + const label timeIndex, + const label fieldIndex +) const +{ + if (debug) + { + InfoInFunction<< endl; + } + + const word& fieldName(fieldNames_[fieldIndex]); + const label fileIndex = timeStartIndex_ + timeIndex*timeIncrement_; + + fileName fieldFileName(fieldFileNames_[fieldIndex]); + + std::ostringstream oss; + oss << std::setfill('0') << std::setw(4) << fileIndex; + const word indexStr = oss.str(); + fieldFileName.replace("****", indexStr); + + IFstream is(baseDir_/fieldFileName); + + if (!is.good()) + { + FatalErrorInFunction + << "Cannot read file " << is.name() + << " for field " << fieldName + << exit(FatalError); + } + + // Check that data type is as expected + word primitiveType(is); + + if (debug) + { + Info<< "primitiveType: " << primitiveType << endl; + } + + if (primitiveType != pTraits::typeName) + { + FatalIOErrorInFunction(is) + << "Expected " << pTraits::typeName << "values " + << "but found type " << primitiveType + << exit(FatalIOError); + } + + tmp > tField(new Field()); + + label n; + if (surfPtr_.valid()) + { + n = surfPtr_->size(); + } + else + { + n = 1000; + } + + Type value; + word wValue; + label iValue; + + // Read header info: part index, e.g. part 1 + is >> wValue >> iValue; + + // Read data file + // - Assume that file contains a mix of words and numbers, and that all + // numbers relate to face values, e.g. header comprises of words and + // element types are also words, e.g. tria3, quad4, nsided + DynamicList values(n); + while (is.good()) + { + token t(is); + + if (is.eof()) + { + break; + } + + if (t.isWord()) + { + wValue = t.wordToken(); + } + else + { + is.putBack(t); + is >> value; + values.append(value); + } + } + + tField().transfer(values); + + return tField; +} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/readers/surfaceReader.C b/src/sampling/sampledSurface/readers/surfaceReader.C new file mode 100644 index 0000000000..fb90c1d80f --- /dev/null +++ b/src/sampling/sampledSurface/readers/surfaceReader.C @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceReader.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(surfaceReader, 0); + defineRunTimeSelectionTable(surfaceReader, fileName); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::surfaceReader::surfaceReader(const fileName& fName) +: + fileName_(fName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::surfaceReader::~surfaceReader() +{} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/readers/surfaceReader.H b/src/sampling/sampledSurface/readers/surfaceReader.H new file mode 100644 index 0000000000..2ccdc470de --- /dev/null +++ b/src/sampling/sampledSurface/readers/surfaceReader.H @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::surfaceReader + +Description + Base class for surface readers + +SourceFiles + surfaceReader.C + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceReader_H +#define surfaceReader_H + +#include "typeInfo.H" +#include "autoPtr.H" +#include "MeshedSurfaces.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class surfaceReader Declaration +\*---------------------------------------------------------------------------*/ + +class surfaceReader +{ +protected: + + //- File name + fileName fileName_; + + +public: + + //- Runtime type information + TypeName("surfaceReader"); + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + surfaceReader, + fileName, + ( + const fileName& fName + ), + (fName) + ); + + + // Selectors + + //- Return a reference to the selected surfaceReader + static autoPtr New + ( + const word& readType, + const fileName& fName + ); + + + // Constructors + + //- Construct from fileName + surfaceReader(const fileName& fName); + + + //- Destructor + virtual ~surfaceReader(); + + + // Member Functions + + //- Return a reference to the surface geometry + virtual const meshedSurface& geometry() = 0; + + //- Return a list of the available times + virtual instantList times() const = 0; + + //- Return a list of the available fields at a given time + virtual wordList fieldNames(const label timeIndex) const = 0; + + //- Return a scalar field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const scalar& refValue = pTraits::zero + ) const = 0; + + //- Return a vector field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const vector& refValue = pTraits::zero + ) const = 0; + + //- Return a sphericalTensor field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const sphericalTensor& reValue = pTraits::zero + ) const = 0; + + //- Return a symmTensor field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const symmTensor& reValue = pTraits::zero + ) const = 0; + + //- Return a tensor field at a given time + virtual tmp > field + ( + const label timeIndex, + const label fieldIndex, + const tensor& reValue = pTraits::zero + ) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/readers/surfaceReaderNew.C b/src/sampling/sampledSurface/readers/surfaceReaderNew.C new file mode 100644 index 0000000000..415179e273 --- /dev/null +++ b/src/sampling/sampledSurface/readers/surfaceReaderNew.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceReader.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::autoPtr Foam::surfaceReader::New +( + const word& readerType, + const fileName& fName +) +{ + fileNameConstructorTable::iterator cstrIter = + fileNameConstructorTablePtr_->find(readerType); + + if (cstrIter == fileNameConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown reader type \"" << readerType << "\"\n\n" + << "Valid reader types: " + << fileNameConstructorTablePtr_->sortedToc() << nl + << exit(FatalError); + } + + return autoPtr(cstrIter()(fName)); +} + + +// ************************************************************************* // From 92c831250a190f0e3b0f3d3f4fae6c53f89b9472 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:31:20 +0000 Subject: [PATCH 03/12] ENH: Added new structure for run-time selectable data windowing functions --- .../windowModels/windowModel/windowModel.C | 100 ++++++++++++ .../windowModels/windowModel/windowModel.H | 143 ++++++++++++++++++ .../windowModels/windowModel/windowModelNew.C | 63 ++++++++ .../windowModel/windowModelTemplates.C | 84 ++++++++++ 4 files changed, 390 insertions(+) create mode 100644 src/randomProcesses/windowModels/windowModel/windowModel.C create mode 100644 src/randomProcesses/windowModels/windowModel/windowModel.H create mode 100644 src/randomProcesses/windowModels/windowModel/windowModelNew.C create mode 100644 src/randomProcesses/windowModels/windowModel/windowModelTemplates.C diff --git a/src/randomProcesses/windowModels/windowModel/windowModel.C b/src/randomProcesses/windowModels/windowModel/windowModel.C new file mode 100644 index 0000000000..9b0e0658ff --- /dev/null +++ b/src/randomProcesses/windowModels/windowModel/windowModel.C @@ -0,0 +1,100 @@ +#include "windowModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(windowModel, 0); + defineRunTimeSelectionTable(windowModel, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::windowModel::windowModel(const dictionary& dict, const label nSamples) +: + scalarField(nSamples), + nOverlapSamples_(0), + nWindow_(dict.lookupOrDefault("nWindow", -1)) +{ + scalar prc = readScalar(dict.lookup("overlapPercent")); + nOverlapSamples_ = floor(prc/scalar(100)*nSamples); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::windowModel::~windowModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::label Foam::windowModel::nSamples() const +{ + return size(); +} + + +Foam::label Foam::windowModel::nWindow() const +{ + return nWindow_; +} + + +Foam::label Foam::windowModel::nWindowsTotal(label nSamplesTotal) const +{ + const label nSamples = this->nSamples(); + + return floor((nSamplesTotal - nSamples)/(nSamples - nOverlapSamples_)) + 1; +} + + +Foam::label Foam::windowModel::validate(const label nSamplesTotal) +{ + label nSamples = this->nSamples(); + + if (nSamplesTotal < nSamples) + { + FatalErrorInFunction + << "Block size N = " << nSamples + << " is larger than total number of data points = " << nSamplesTotal + << exit(FatalError); + } + + label nWindowAvailable = nWindowsTotal(nSamplesTotal); + + if (nWindow_ == -1) + { + nWindow_ = nWindowAvailable; + } + + if (nWindow_ > nWindowAvailable) + { + FatalErrorInFunction + << "Number of data points calculated with " << nWindow_ + << " windows greater than the total number of data points" + << nl + << " Block size, N = " << nSamples << nl + << " Total number of data points = " << nSamplesTotal << nl + << " Maximum number of windows = " << nWindowAvailable << nl + << " Requested number of windows = " << nWindow_ + << exit(FatalError); + } + + label nRequiredSamples = + nWindow_*nSamples - (nWindow_ - 1)*nOverlapSamples_; + + Info<< "Windowing:" << nl + << " Total samples : " << nSamplesTotal << nl + << " Samples per window : " << nSamples << nl + << " Number of windows : " << nWindow_ << nl + << " Overlap size : " << nOverlapSamples_ << nl + << " Required number of samples : " << nRequiredSamples + << endl; + + return nRequiredSamples; +} + + +// ************************************************************************* // diff --git a/src/randomProcesses/windowModels/windowModel/windowModel.H b/src/randomProcesses/windowModels/windowModel/windowModel.H new file mode 100644 index 0000000000..b9e1845fe0 --- /dev/null +++ b/src/randomProcesses/windowModels/windowModel/windowModel.H @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::windowModel + +Description + Base class for windowing models + +SourceFiles + noiseFFT.C + +\*---------------------------------------------------------------------------*/ + +#ifndef windowModel_H +#define windowModel_H + +#include "autoPtr.H" +#include "runTimeSelectionTables.H" +#include "scalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class windowModel Declaration +\*---------------------------------------------------------------------------*/ + +class windowModel +: + public scalarField +{ + +protected: + + // Protected Data + + //- Number of overlap samples per window + label nOverlapSamples_; + + //- Number of windows + label nWindow_; + + +public: + + //- Runtime type information + TypeName("windowModel"); + + // Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + windowModel, + dictionary, + ( + const dictionary& dict, + const label nSamples + ), + (dict, nSamples) + ); + + + //- Construct from dictionary + windowModel(const dictionary& dict, const label nSamples); + + + // Selectors + + //- Return a reference to the selected window model + static autoPtr New + ( + const dictionary& dict, + const label nSamples + ); + + + //- Destuctor + virtual ~windowModel(); + + + // Public Member Functions + + //- Return the number of samples in the window + label nSamples() const; + + //- Return the number of windows + label nWindow() const; + + //- Return the total number of windows for a given number of samples + label nWindowsTotal(label nSamplesTotal) const; + + //- Validate that the window is applicable to the data set size, and + // return the number of required data points + label validate(label n); + + //- Return the windowed data + template + tmp > apply + ( + const Field& fld, + const label windowI + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "windowModelTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/randomProcesses/windowModels/windowModel/windowModelNew.C b/src/randomProcesses/windowModels/windowModel/windowModelNew.C new file mode 100644 index 0000000000..68aed5d766 --- /dev/null +++ b/src/randomProcesses/windowModels/windowModel/windowModelNew.C @@ -0,0 +1,63 @@ +#/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "windowModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::windowModel::New +( + const dictionary& dict, + const label nSamples +) +{ + const word modelType(dict.lookup("windowModel")); + + Info<< "Selecting windowModel " << modelType << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(modelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "windowModel::New(const dictionary&, const label)" + ) << "Unknown windowModel type " + << modelType << nl << nl + << "Valid windowModel types are:" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter()(dict.subDict(modelType + "Coeffs"), nSamples) + ); + +} + + +// ************************************************************************* // diff --git a/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C b/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C new file mode 100644 index 0000000000..1343b55bb9 --- /dev/null +++ b/src/randomProcesses/windowModels/windowModel/windowModelTemplates.C @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +template +Foam::tmp > Foam::windowModel::apply +( + const Field& fld, + const label windowI +) const +{ + label nSamples = this->nSamples(); + + if (nSamples > fld.size()) + { + FatalErrorIn + ( + "template " + "Foam::tmp > Foam::windowModel::apply" + "(" + "const Field&, " + "const label" + ") const" + ) + << "Number of samples in sampling window is greater than the " + << "size of the input field" << nl + << " input field size = " << fld.size() << nl + << " window size = " << nSamples << nl + << " requested window index = " << windowI + << exit(FatalError); + } + + + tmp > tresult(new Field(nSamples, pTraits::zero)); + Field& result = tresult(); + + label nWindow = nWindowsTotal(fld.size()); + if (windowI >= nWindow) + { + FatalErrorIn + ( + "template " + "Foam::tmp > Foam::windowModel::apply" + "(" + "const Field&, " + "const label" + ") const" + ) + << "Requested window " << windowI << " outside of range. " + << "Number of available windows is " << nWindow + << abort(FatalError); + } + + label windowOffset = windowI*(nSamples - nOverlapSamples_); + + const scalarField& wf = *this; + result = wf*SubField(fld, nSamples, windowOffset); + + return tresult; +} + + +// ************************************************************************* // From 9eef6f5c22817f19d91857f0b6be926d06c67f16 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:31:38 +0000 Subject: [PATCH 04/12] ENH: Added new Hanning window model --- .../windowModels/Hanning/Hanning.C | 122 +++++++++++++++++ .../windowModels/Hanning/Hanning.H | 125 ++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 src/randomProcesses/windowModels/Hanning/Hanning.C create mode 100644 src/randomProcesses/windowModels/Hanning/Hanning.H diff --git a/src/randomProcesses/windowModels/Hanning/Hanning.C b/src/randomProcesses/windowModels/Hanning/Hanning.C new file mode 100644 index 0000000000..19a48258ac --- /dev/null +++ b/src/randomProcesses/windowModels/Hanning/Hanning.C @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "Hanning.H" +#include "addToRunTimeSelectionTable.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace windowModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Hanning, 0); +addToRunTimeSelectionTable(windowModel, Hanning, dictionary); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Hanning::Hanning(const dictionary& dict, const label nSamples) +: + windowModel(dict, nSamples), + symmetric_(readBool(dict.lookup("symmetric"))), + extended_(readBool(dict.lookup("extended"))), + alpha_(dict.lookupOrDefault("alpha", 0.5)) +{ + // Extend range if required + label offset = extended_ ? 1 : 0; + scalar m = nSamples - 1 + 2*offset; + + scalarField t(nSamples); + forAll(t, i) + { + t[i] = i + offset; + } + + scalarField& wf = *this; + wf = (1 - alpha_)*cos(constant::mathematical::twoPi*t/m); + + // Reset second half of window if symmetric + if (symmetric_) + { + label midPointI = 0; + if (nSamples % 2 == 0) + { + midPointI = nSamples/2; + } + else + { + midPointI = (nSamples + 1)/2; + } + + for (label i = 0; i < midPointI; i++) + { + wf[nSamples - i - 1] = wf[i]; + } + } + + scalar sumSqr = sum(sqr(wf)); + + // Normalisation (if required) + wf *= sqrt(nSamples/sumSqr); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Hanning::~Hanning() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Hanning::symmetric() const +{ + return symmetric_; +} + + +bool Hanning::extended() const +{ + return extended_; +} + + +Foam::scalar Hanning::alpha() const +{ + return alpha_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace windowModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/randomProcesses/windowModels/Hanning/Hanning.H b/src/randomProcesses/windowModels/Hanning/Hanning.H new file mode 100644 index 0000000000..8a0ca618ed --- /dev/null +++ b/src/randomProcesses/windowModels/Hanning/Hanning.H @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::windowModels::Hanning + +Description + Hanning window + + The window is described by the function + \f[ + wf = (1 - \alpha) cos(2 \pi t/m); + \f] + + Where: + \vartable + \alpha | Coefficient with a default value of 0.5 + t | time + m | window width + \endvartable + + The window can be further manipulated by the controls: + - \c symmetric: force the window to be symmetric + - \c extended: extend the window by 1 element at start and end to produce + non-zero values at the start and end positions. Note: window is + normalised to preserve energy content + +SourceFiles + Hanning.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Hanning_H +#define Hanning_H + +#include "autoPtr.H" +#include "runTimeSelectionTables.H" +#include "windowModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace windowModels +{ + +/*---------------------------------------------------------------------------*\ + Class Hanning Declaration +\*---------------------------------------------------------------------------*/ + +class Hanning +: + public windowModel +{ + +protected: + + // Protected Member Data + + //- Symmetric switch + bool symmetric_; + + //- Extended switch + bool extended_; + + //- Window coefficient, default = 0.5 + scalar alpha_; + + +public: + + //- Runtime type information + TypeName("Hanning"); + + + //- Construct from dictionary + Hanning(const dictionary& dict, const label nSamples); + + //- Destuctor + virtual ~Hanning(); + + + // Public Member Functions + + //- Return the symmetric flag + bool symmetric() const; + + //- Return the extended flag + bool extended() const; + + //- Return the window coefficient + scalar alpha() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace windowModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 225cd918bb8e2263ab01c75e4c91aa4994157dc1 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:46:30 +0000 Subject: [PATCH 05/12] ENH: Added surfaceReaders to sampling library Make/files --- src/sampling/Make/files | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 03fab92a74..3416dd38d1 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -51,6 +51,12 @@ $(surfWriters)/starcd/starcdSurfaceWriter.C $(surfWriters)/vtk/vtkSurfaceWriter.C $(surfWriters)/boundaryData/boundaryDataSurfaceWriter.C +surfReaders = sampledSurface/readers + +$(surfReaders)/surfaceReader.C +$(surfReaders)/surfaceReaderNew.C +$(surfReaders)/ensight/ensightSurfaceReader.C + graphField/writePatchGraph.C graphField/writeCellGraph.C graphField/makeGraph.C From 4bf509df4279152a6b3cbe069979868afdc1d97b Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:53:23 +0000 Subject: [PATCH 06/12] ENH: Added new structure for run-time selectable noiseModels --- .../noise/noiseModels/noiseModel/noiseModel.C | 150 +++++++++++++++ .../noise/noiseModels/noiseModel/noiseModel.H | 175 ++++++++++++++++++ .../noiseModels/noiseModel/noiseModelNew.C | 53 ++++++ 3 files changed, 378 insertions(+) create mode 100644 src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C create mode 100644 src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H create mode 100644 src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C new file mode 100644 index 0000000000..c32c4ec21d --- /dev/null +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "noiseModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(noiseModel, 0); + defineRunTimeSelectionTable(noiseModel, dictionary); +} + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +Foam::scalar Foam::noiseModel::checkUniformTimeStep +( + const scalarList& times +) const +{ + scalar deltaT = -1.0; + + if (times.size() > 1) + { + for (label i = 1; i < times.size(); i++) + { + scalar dT = times[i] - times[i-1]; + + if (deltaT < 0) + { + deltaT = dT; + } + + if (mag(deltaT - dT) > SMALL) + { + FatalErrorInFunction + << "Unable to process data with a variable time step" + << exit(FatalError); + } + } + } + else + { + FatalErrorInFunction + << "Unable to create FFT with a single value" + << exit(FatalError); + } + + return deltaT; +} + + +Foam::label Foam::noiseModel::findStartTimeIndex +( + const instantList& allTimes, + const scalar startTime +) const +{ + forAll(allTimes, timeI) + { + const instant& i = allTimes[timeI]; + + if (i.value() >= startTime) + { + return timeI; + } + } + + return 0; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::noiseModel::noiseModel(const dictionary& dict) +: + dict_(dict), + pRef_(dict.lookupOrDefault("pRef", 0)), + nSamples_(dict.lookupOrDefault("N", 65536)), + fLower_(dict.lookupOrDefault("fl", 25)), + fUpper_(dict.lookupOrDefault("fu", 10000)), + startTime_(dict.lookupOrDefault("startTime", 0)), + windowModelPtr_(windowModel::New(dict, nSamples_)) +{ + // Check number of samples - must be a power of 2 for our FFT + bool powerOf2 = ((nSamples_ != 0) && !(nSamples_ & (nSamples_ - 1))); + if (!powerOf2) + { + FatalIOErrorInFunction(dict) + << "N: Number of samples in sampling windows must be a " + << "power of 2" + << exit(FatalIOError); + } + + if (fLower_ < 0) + { + FatalIOErrorInFunction(dict) + << "fl: lower frequency bound must be greater than zero" + << exit(FatalIOError); + + } + + if (fUpper_ < 0) + { + FatalIOErrorInFunction(dict) + << "fu: upper frequency bound must be greater than zero" + << exit(FatalIOError); + + } + + if (fUpper_ < fLower_) + { + FatalIOErrorInFunction(dict) + << "fu: upper frequency bound must be greater than lower " + << "frequency bound (fl)" + << exit(FatalIOError); + + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::noiseModel::~noiseModel() +{} + + +// ************************************************************************* // diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H new file mode 100644 index 0000000000..f7e739b7d0 --- /dev/null +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::noiseModel + +Description + Base class for noise models. + + Data is read from a dictionary, e.g. + + \verbatim + pRef 0; + N 4096; + fl 25; + fu 25; + startTime 0; + \endverbatim + + where + \table + Property | Description | Required | Default value + pRef | Reference pressure | no | 0 + N | Number of samples in sampling window | no | 65536 (2^16) + fl | Lower frequency bounds | no | 25 + fu | Upper frequency bounds | no | 10000 + \endtable + +Note + The number of samples in the sampling window must be a power of 2 + + +SourceFiles + noiseModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef noiseModel_H +#define noiseModel_H + +#include "dictionary.H" +#include "scalarList.H" +#include "instantList.H" +#include "windowModel.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class noiseModel Declaration +\*---------------------------------------------------------------------------*/ + +class noiseModel +{ + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + noiseModel(const noiseModel&); + + //- Disallow default bitwise assignment + void operator=(const noiseModel&); + + +protected: + + // Protected Data + + //- Copy of dictionary used for construction + const dictionary dict_; + + //- Reference pressure + scalar pRef_; + + //- Number of samples in sampling window, default = 2^16 + label nSamples_; + + //- Lower frequency limit, default = 25Hz + scalar fLower_; + + //- Upper frequency limit, default = 10kHz + scalar fUpper_; + + //- Start time, default = 0s + scalar startTime_; + + //- Window model + autoPtr windowModelPtr_; + + + + // Protected Member Functions + + //- Check and return uniform time step + scalar checkUniformTimeStep + ( + const scalarList& times + ) const; + + //- Find and return start time index + label findStartTimeIndex + ( + const instantList& allTimes, + const scalar startTime + ) const; + + +public: + + //- Runtime type information + TypeName("noiseModel"); + + //- Run time selection table + declareRunTimeSelectionTable + ( + autoPtr, + noiseModel, + dictionary, + ( + const dictionary& dict + ), + (dict) + ); + + //- Selector + static autoPtr New(const dictionary& dict); + + //- Constructor + noiseModel(const dictionary& dict); + + //- Destructor + virtual ~noiseModel(); + + + // Public Member Functions + + //- Abstract call to calculate + virtual void calculate() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C new file mode 100644 index 0000000000..3f5fa4f25f --- /dev/null +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "noiseModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::noiseModel::New(const dictionary& dict) +{ + const word modelType(dict.lookup("noiseModel")); + + Info<< "Selecting noiseModel " << modelType << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(modelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown noiseModel type " + << modelType << nl << nl + << "Valid noiseModel types are:" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(dict.subDict(modelType + "Coeffs"))); +} + + +// ************************************************************************* // From 39aa4f3a4e17000c4d8657dcce600a756d4e9fdd Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:54:17 +0000 Subject: [PATCH 07/12] ENH: Added new pointNoise model to process point data to replicate old behaviour --- .../noise/noiseModels/pointNoise/pointNoise.C | 151 ++++++++++++++++++ .../noise/noiseModels/pointNoise/pointNoise.H | 148 +++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C create mode 100644 src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H diff --git a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C new file mode 100644 index 0000000000..2014d721e3 --- /dev/null +++ b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "pointNoise.H" +#include "noiseFFT.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace noiseModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(pointNoise, 0); +addToRunTimeSelectionTable(noiseModel, pointNoise, dictionary); + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void pointNoise::filterTimeData +( + const CSV& pData, + scalarField& t, + scalarField& p +) +{ + const scalarField t0(pData.x()); + const scalarField p0(pData.y()); + + DynamicList tf(t0.size()); + DynamicList pf(t0.size()); + + forAll(t0, timeI) + { + if (t0[timeI] >= startTime_) + { + tf.append(t0[timeI]); + pf.append(p0[timeI]); + } + } + + t.transfer(tf); + p.transfer(pf); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void pointNoise::calculate() +{ + // Point data only handled by master + if (!Pstream::master()) + { + return; + } + + Info<< "Reading data file" << endl; + + CSV pData("pressure", dict_, "Data"); + fileName baseFileName(pData.fName().lessExt()); + + // Time and pressure history data + scalarField t, p; + filterTimeData(pData, t, p); + Info<< " read " << t.size() << " values" << nl << endl; + + Info<< "Creating noise FFT" << endl; + const scalar deltaT = checkUniformTimeStep(t); + + // Determine the windowing + windowModelPtr_->validate(t.size()); + + // Create the fft + noiseFFT nfft(deltaT, p); + + nfft -= pRef_; + + graph Pf(nfft.RMSmeanPf(windowModelPtr_())); + Info<< " Creating graph for " << Pf.title() << endl; + Pf.write(baseFileName + graph::wordify(Pf.title()), graphFormat_); + + graph Lf(nfft.Lf(Pf)); + Info<< " Creating graph for " << Lf.title() << endl; + Lf.write(baseFileName + graph::wordify(Lf.title()), graphFormat_); + + graph PSDf(nfft.PSDf(windowModelPtr_())); + Info<< " Creating graph for " << PSDf.title() << endl; + PSDf.write(baseFileName + graph::wordify(PSDf.title()), graphFormat_); + + graph PSD(nfft.PSD(PSDf)); + Info<< " Creating graph for " << PSD.title() << endl; + PSD.write(baseFileName + graph::wordify(PSD.title()), graphFormat_); + + labelList octave13BandIDs; + noiseFFT::octaveFrequenciesIDs(Pf.x(), fLower_, fUpper_, 3, octave13BandIDs); + + graph Ldelta(nfft.Ldelta(Lf, octave13BandIDs)); + Info<< " Creating graph for " << Ldelta.title() << endl; + Ldelta.write(baseFileName + graph::wordify(Ldelta.title()), graphFormat_); + + graph Pdelta(nfft.Pdelta(Pf, octave13BandIDs)); + Info<< " Creating graph for " << Pdelta.title() << endl; + Pdelta.write(baseFileName + graph::wordify(Pdelta.title()), graphFormat_); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +pointNoise::pointNoise(const dictionary& dict) +: + noiseModel(dict), + graphFormat_(dict.lookupOrDefault("graphFormat", "raw")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +pointNoise::~pointNoise() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace noiseModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H new file mode 100644 index 0000000000..020e462238 --- /dev/null +++ b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::noiseModels::pointNoise + +Description + Perform noise analysis on point-based pressure data. + + Input data is read from a dictionary, e.g. + + \verbatim + // Pressure reference + pRef 0; + + // Number of samples in sampling window + // Must be a power of 2, default = 2^16 (=65536) + N 4096; + + // Lower frequency bounds + fl 25; + + // Upper frequency bounds + fu 25; + + // Start time + startTime 0; + + windowModel + Coeffs + { + ... + } + + // Pressure data supplied in CSV file format + csvFileData + { + fileName "pressureData"; + nHeaderLine 1; + refColumn 0; + componentColumns (1); + separator " "; + mergeSeparators yes; + } + + graphFormat raw; + + \endverbatim + +SourceFiles + pointNoise.C + +SeeAlso + noiseModel.H + windowModel.H + +\*---------------------------------------------------------------------------*/ + +#ifndef pointNoise_H +#define pointNoise_H + +#include "noiseModel.H" +#include "CSV.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace noiseModels +{ + +/*---------------------------------------------------------------------------*\ + Class pointNoise Declaration +\*---------------------------------------------------------------------------*/ + +class pointNoise +: + public noiseModel +{ + +protected: + + // Protected data + + //- Graph format + word graphFormat_; + + + // Protected Member Functions + + void filterTimeData + ( + const CSV& pData, + scalarField& t, + scalarField& p + ); + + +public: + + //- Runtime type information + TypeName("pointNoise"); + + //- Constructor + pointNoise(const dictionary& dict); + + //- Destructor + virtual ~pointNoise(); + + + // Public Member Functions + + //- Calculate + virtual void calculate(); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace noiseModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 02ae5530993d68f5ae02f73a92f75b6256c250e9 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Feb 2016 12:54:43 +0000 Subject: [PATCH 08/12] ENH: Added new surfaceNoise model to process surface data --- .../noiseModels/surfaceNoise/surfaceNoise.C | 490 ++++++++++++++++++ .../noiseModels/surfaceNoise/surfaceNoise.H | 201 +++++++ 2 files changed, 691 insertions(+) create mode 100644 src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C create mode 100644 src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.H diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C new file mode 100644 index 0000000000..1dcc319766 --- /dev/null +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C @@ -0,0 +1,490 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceNoise.H" +#include "surfaceReader.H" +#include "surfaceWriter.H" +#include "noiseFFT.H" +#include "graph.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace noiseModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(surfaceNoise, 0); +addToRunTimeSelectionTable(noiseModel, surfaceNoise, dictionary); + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void surfaceNoise::initialise(const dictionary& dict) +{ + // All reading performed on the master processor only + if (Pstream::master()) + { + // Create the surface reader + const word readerType(dict.lookup("reader")); + readerPtr_.reset(surfaceReader::New(readerType, inputFileName_).ptr()); + + // Find the index of the pressure data + const word pName(dict.lookupOrDefault("pName", "p")); + const List fieldNames(readerPtr_->fieldNames(0)); + pIndex_ = findIndex(fieldNames, pName); + if (pIndex_ == -1) + { + FatalErrorInFunction + << "Unable to find pressure field name " << pName + << " in list of available fields: " << fieldNames + << exit(FatalError); + } + + // Create the surface writer + // - Could be done later, but since this utility can process a lot of + // data we can ensure that the user-input is correct prior to doing + // the heavy lifting + const word writerType(dict.lookup("writer")); + dictionary optDict + ( + dict.subOrEmptyDict("writeOptions").subOrEmptyDict(writerType) + ); + writerPtr_.reset(surfaceWriter::New(writerType, optDict).ptr()); + + // Set the time range + const instantList allTimes = readerPtr_->times(); + startTimeIndex_ = findStartTimeIndex(allTimes, startTime_); + + // Determine the windowing + label nAvailableTimes = allTimes.size() - startTimeIndex_; + label nRequiredTimes = windowModelPtr_->validate(nAvailableTimes); + + // Restrict times + times_.setSize(nRequiredTimes); + forAll(times_, timeI) + { + times_[timeI] = allTimes[timeI + startTimeIndex_].value(); + } + deltaT_ = checkUniformTimeStep(times_); + + const meshedSurface& surf = readerPtr_->geometry(); + nFace_ = surf.size(); + } + + Pstream::scatter(pIndex_); + Pstream::scatter(times_); + Pstream::scatter(startTimeIndex_); + Pstream::scatter(deltaT_); + Pstream::scatter(nFace_); +} + + +void surfaceNoise::readSurfaceData +( + const labelList& procFaceOffset, + List& pData +) +{ + // Data is stored as pressure on surface at a given time. Now we need to + // pivot the data so that we have the complete pressure time history per + // surface face. In serial mode, this results in all pressure data being + // loaded into memory (!) + + Info << "Reading pressure data" << endl; + + if (Pstream::parRun()) + { + PstreamBuffers pBufs(Pstream::nonBlocking); + + // Procedure: + // 1. Master processor reads pressure data for all faces for all times + // 2. Master sends each processor a subset of faces + // 3. Local processor reconstructs the full time history for the subset + // of faces + // Note: reading all data on master to avoid potential NFS problems... + + const label myProcI = Pstream::myProcNo(); + const label nLocalFace = + procFaceOffset[myProcI + 1] - procFaceOffset[myProcI]; + + // Complete pressure time history data for subset of faces + pData.setSize(nLocalFace); + const label nTimes = times_.size(); + forAll(pData, faceI) + { + pData[faceI].setSize(nTimes); + } + + // Read and send data + forAll(times_, i) + { + pBufs.clear(); + + if (Pstream::master()) + { + label timeI = i + startTimeIndex_; + + Info<< " time: " << times_[i] << endl; + + // Read pressure at all faces for time timeI + scalarField p(readerPtr_->field(timeI, pIndex_, scalar(0))); + + // Send subset of faces to each processor + for (label procI = 0; procI < Pstream::nProcs(); procI++) + { + label face0 = procFaceOffset[procI]; + label nLocalFace = + procFaceOffset[procI + 1] - procFaceOffset[procI]; + + UOPstream toProc(procI, pBufs); + toProc << SubList(p, nLocalFace, face0); + } + } + + pBufs.finishedSends(); + + // Receive data from the master + UIPstream fromProc(0, pBufs); + + scalarList pSlice(fromProc); + + forAll(pSlice, faceI) + { + pData[faceI][i] = pSlice[faceI]; + } + } + } + else + { + const label nLocalFace = procFaceOffset[0]; + + pData.setSize(nLocalFace); + forAll(times_, timeI) + { + forAll(pData, faceI) + { + pData[faceI].setSize(times_.size()); + } + } + + forAll(times_, i) + { + label timeI = i + startTimeIndex_; + + Info<< " time: " << times_[i] << endl; + const scalarField p(readerPtr_->field(timeI, pIndex_, scalar(0))); + + forAll(p, faceI) + { + pData[faceI][i] = p[faceI]; + } + } + } + + Info<< "Read " + << returnReduce(pData.size(), sumOp