Commit 3be20b49 authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge remote-tracking branch 'origin/develop' into develop

- conflicts resolved:
    src/conversion/ensight/file/ensightGeoFile.C
parents c133f98d 4b266671
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
if [ -f "$FFTW_ARCH_PATH/include/fftw3.h" ] || \
[ "${FFTW_ARCH_PATH##*-}" = system -a -f "/usr/include/fftw3.h" ]
then
wmake
else
echo
echo "Skipping dnsFoam solver (no FFTW)"
echo
fi
#------------------------------------------------------------------------------
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
if [ -f "$FFTW_ARCH_PATH/include/fftw3.h" ] || \
[ "${FFTW_ARCH_PATH##*-}" = system -a -f "/usr/include/fftw3.h" ]
then
wmake
else
echo
echo "Skipping noise utility (no FFTW)"
echo
fi
#------------------------------------------------------------------------------
EXE_INC = \
-I$(LIB_SRC)/randomProcesses/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = \
-lrandomProcesses \
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -28,157 +28,103 @@ Group
grpPostProcessingUtilities
Description
Utility to perform noise analysis of pressure data using the noiseFFT
library.
Utility to perform noise analysis of pressure data.
Control settings are read from the $FOAM_CASE/system/noiseDict dictionary,
or user-specified dictionary using the -dict option. Pressure data is
read using a CSV reader:
The utility provides a light wrapper around the run-time selectable
noise model. Current options include:
- point, and
- surface noise.
\heading Usage
\heading Example usage
\verbatim
pRef 101325;
N 65536;
nw 100;
f1 25;
fU 10000;
graphFormat raw;
pressureData
noiseModel surfaceNoise; // pointNoise
surfaceNoiseCoeffs
{
fileName "pressureData"
nHeaderLine 1; // number of header lines
refColumn 0; // reference column index
componentColumns (1); // component column indices
separator " "; // optional (defaults to ",")
mergeSeparators no; // merge multiple separators
outOfBounds clamp; // optional out-of-bounds handling
interpolationScheme linear; // optional interpolation scheme
windowModel Hanning;
HanningCoeffs
{
// Window overlap percentage
overlapPercent 50;
symmetric yes;
extended yes;
// Optional number of windows, default = all available
nWindow 5;
}
// Input file
inputFile "postProcessing/faceSource1/surface/patch/patch.case";
// Surface reader
reader ensight;
// Surface writer
writer ensight;
// Collate times for ensight output - ensures geometry is only written once
writeOptions
{
ensight
{
collateTimes 1;
}
}
// Number of samples in sampling window
// Must be a power of 2, default = 2^16 (=65536)
N 4096;
// Write interval for FFT data, default = 1
fftWriteInterval 100;
}
\endverbatim
where
\table
Property | Description | Required | Default value
pRef | Reference pressure | no | 0
N | Number of samples in sampling window | no | 65536
nw | Number of sampling windows | no | 100
fl | Lower frequency band | no | 25
fU | Upper frequency band | no | 10000
graphFormat | Output graph format | no | raw
\endtable
Current graph outputs include:
- FFT of the pressure data
- narrow-band PFL (pressure-fluctuation level) spectrum
- one-third-octave-band PFL spectrum
- one-third-octave-band pressure spectrum
SeeAlso
CSV.H
noiseFFT.H
noiseModel.H
windowModel.H
\*---------------------------------------------------------------------------*/
#include "noiseFFT.H"
#include "argList.H"
#include "Time.H"
#include "functionObjectFile.H"
#include "CSV.H"
#include "noiseModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::scalar checkUniformTimeStep(const scalarField& t)
{
// check that a uniform time step has been applied
scalar deltaT = -1.0;
if (t.size() > 1)
{
for (label i = 1; i < t.size(); i++)
{
scalar dT = t[i] - t[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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noParallel();
#include "addDictOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createFields.H"
Info<< "Reading data file" << endl;
Function1Types::CSV<scalar> pData("pressure", dict, "Data");
// time history data
const scalarField t(pData.x());
// pressure data
const scalarField p(pData.y());
if (t.size() < N)
fileName dictName(runTime.system()/"noiseDict");
if (args.optionFound("dict"))
{
FatalErrorInFunction
<< "Block size N = " << N
<< " is larger than number of data = " << t.size()
<< exit(FatalError);
dictName = args["dict"];
}
Info<< " read " << t.size() << " values" << nl << endl;
Info<< "Creating noise FFT" << endl;
noiseFFT nfft(checkUniformTimeStep(t), p);
nfft -= pRef;
fileName baseFileName(pData.fName().lessExt());
graph Pf(nfft.RMSmeanPf(N, min(nfft.size()/N, nw)));
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 Ldelta(nfft.Ldelta(Lf, f1, fU));
Info<< " Creating graph for " << Ldelta.title() << endl;
Ldelta.write(baseFileName + graph::wordify(Ldelta.title()), graphFormat);
graph Pdelta(nfft.Pdelta(Pf, f1, fU));
Info<< " Creating graph for " << Pdelta.title() << endl;
Pdelta.write(baseFileName + graph::wordify(Pdelta.title()), graphFormat);
IOdictionary dict
(
IOobject
(
dictName,
runTime,
IOobject::MUST_READ
)
);
autoPtr<noiseModel> model(noiseModel::New(dict));
model->calculate();
Info<< nl << "End\n" << endl;
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object noiseDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
noiseModel surfaceNoise;
surfaceNoiseCoeffs
{
windowModel Hanning;
HanningCoeffs
{
// Window overlap percentage
overlapPercent 50;
symmetric yes;
extended yes;
// Optional number of windows, default = all available
// nWindow 1;
}
/*
windowModel uniform;
uniformCoeffs
{
// Window overlap percentage
overlapPercent 50;
value 1;
// Optional number of windows, default = all available
// nWindow 1;
}
*/
// Input file
inputFile "postProcessing/faceSource1/surface/patch_motorBike_rider-helmet%65/patch_motorBike_rider-helmet%65.case";
// Surface reader
reader ensight;
// Surface writer
writer ensight;
// Collate times for ensight output - ensures geometry is only written once
writeOptions
{
ensight
{
collateTimes 1;
}
}
// Reference density (to convert from kinematic to static pressure)
rhoRef 1.205;
// Number of samples in sampling window
// Must be a power of 2, default = 2^16 (=65536)
N 4096; // 8192; // 4096;
// Lower frequency limit, default = 25Hz
//fl 25;
// Upper frequency limit, default = 10kHz
fu 15000;
// Start time, default = 0s
//startTime 0;
// Write interval for FFT data, default = 1
// fftWriteInterval 100;
}
pointNoiseCoeffs
{
csvFileData
{
fileName "pressureData";
nHeaderLine 1;
refColumn 0;
componentColumns (1);
separator " ";
mergeSeparators yes;
}
HanningCoeffs
{
// Window overlap percentage
overlapPercent 50;
symmetric yes;
extended yes;
// Optional number of windows, default = all available
//nWindow 5;
}
// Graph format, default = raw
graphFormat raw;
// Reference density (to convert from kinematic to static pressure)
rhoRef 1.2;
// Number of samples in sampling window
// Must be a power of 2, default = 2^16 (=65536)
N 4096;
// Lower frequency limit, default = 25Hz
//fl 25;
// Upper frequency limit, default = 10kHz
//fu 10000;
// Start time, default = 0s
//startTime 0;
// Write interval for FFT data, default = 1
fftWriteInterval 100;
}
// ************************************************************************* //
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
if [ -f "$FFTW_ARCH_PATH/include/fftw3.h" ] || \
[ "${FFTW_ARCH_PATH##*-}" = system -a -f "/usr/include/fftw3.h" ]
then
wmake
else
echo
echo "Skipping boxTurb utility (no FFTW)"
echo
fi
#------------------------------------------------------------------------------
......@@ -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
......
ensight/file/ensightFile.C
ensight/file/ensightGeoFile.C
ensight/readFile/ensightReadFile.C
ensight/part/ensightPart.C
ensight/part/ensightPartIO.C
ensight/part/ensightPartCells.C
......
......@@ -182,7 +182,6 @@ Foam::Ostream& Foam::ensightFile::write(const char* value)
}
return *this;
}
......
......@@ -144,7 +144,7 @@ public:
using Ostream::write;
//- Binary write
virtual Ostream& write(const char* buf, std::streamsize count);
virtual Ostream& write(const char*, std::streamsize count);
//- Write element keyword with trailing newline, optionally with undef
virtual Ostream& writeKeyword(const keyType&);
......@@ -156,19 +156,19 @@ public:
Ostream& writeUndef();
//- Write C-string as "%79s" or as binary (max 80 chars)
Ostream& write(const char* value);
Ostream& write(const char*);
//- Write string as "%79s" or as binary (max 80 chars)
Ostream& write(const string& value);
Ostream& write(const string&);
//- Write integer as "%10d" or as binary
Ostream& write(const label value);
Ostream& write(const label);
//- Write integer with specified width or as binary
Ostream& write(const label value, const label fieldWidth);
Ostream& write(const label, const label fieldWidth);
//- Write float as "%12.5e" or as binary
Ostream& write(const scalar value);
Ostream& write(const scalar);
//- Add carriage return to ascii stream
void newline();
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ensightReadFile.H"
#include <sstream>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightReadFile::ensightReadFile
(
const fileName& pathname,
IOstream::streamFormat format
)
:
IFstream(pathname, format)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightReadFile::~ensightReadFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Istream& Foam::ensightReadFile::read
(
char* buf,
std::streamsize count
)
{
stdStream().read(buf, count);
return *this;
}
Foam::Istream& Foam::ensightReadFile::read(string& value)
{
if (format() == IOstream::BINARY)
{
char buf[80];
read(reinterpret_cast<char*>(buf), sizeof(buf));
string strBuf(value);
const size_t iEnd = strBuf.find('\0', 0);
if (iEnd == string::npos)
{
value = buf;
}
else
{
value = strBuf.substr(0, iEnd - 1);
}
}
else
{
value = "";
while (value.empty() && !eof())
{
getLine(value);
}
}
return *this;
}
Foam::Istream& Foam::ensightReadFile::read(label& value)
{
int ivalue;
if (format() == IOstream::BINARY)
{
read
(
reinterpret_cast<char*>(&ivalue),
sizeof(ivalue)
);
}
else
{
stdStream() >> ivalue;
}
value = ivalue;
return *this;
}
Foam::Istream& Foam::ensightReadFile::read(scalar& value)
{
float fvalue;
if (format() == IOstream::BINARY)
{
read
(
reinterpret_cast<char*>(&fvalue),
sizeof(fvalue)
);
value = fvalue;
}
else