mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
applications/solvers/DNS/dnsFoam/Allwmake
Executable file
14
applications/solvers/DNS/dnsFoam/Allwmake
Executable file
@ -0,0 +1,14 @@
|
||||
#!/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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -8,7 +8,7 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
# Get version info and arch-path
|
||||
. $WM_PROJECT_DIR/etc/config.sh/functions
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/libccmio)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
|
||||
|
||||
set -x
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,6 +23,8 @@ License
|
||||
|
||||
Application
|
||||
foamInfoExec
|
||||
To simplify parsing of the output, The normal banner information
|
||||
is suppressed.
|
||||
|
||||
Group
|
||||
grpMiscUtilities
|
||||
|
||||
@ -47,11 +47,14 @@ QT4_WRAP_CPP(MOC_SRCS pqPVFoamReaderPanel.h)
|
||||
|
||||
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
|
||||
CLASS_NAME pqPVFoamReaderPanel
|
||||
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
|
||||
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
|
||||
XML_GROUP sources
|
||||
)
|
||||
|
||||
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
|
||||
# so check if version < 4.4
|
||||
|
||||
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
@ -61,7 +64,7 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
GUI_RESOURCE_FILES PVFoamReader.xml
|
||||
)
|
||||
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ELSE()
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
@ -70,7 +73,7 @@ ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
GUI_SOURCES pqPVFoamReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
)
|
||||
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ENDIF()
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
PVFoamReader_SM
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<ParaViewReaders>
|
||||
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
|
||||
<Reader name="PVFoamReader"
|
||||
extensions="OpenFOAM"
|
||||
file_description="OpenFOAM Reader">
|
||||
|
||||
@ -1,18 +1,12 @@
|
||||
/* Note: enable vtkPolyhedron when available */
|
||||
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../PVFoamReader \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||
$(shell \
|
||||
test -f $(ParaView_INCLUDE_DIR)/vtkPolyhedron.h && \
|
||||
echo "-DHAS_VTK_POLYHEDRON" || echo "-UHAS_VTK_POLYHEDRON" \
|
||||
)
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../PVFoamReader
|
||||
|
||||
LIB_LIBS = \
|
||||
-lmeshTools \
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -275,7 +275,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
// Polyhedral cell - use VTK_POLYHEDRON
|
||||
const labelList& cFaces = mesh.cells()[cellI];
|
||||
|
||||
#ifdef HAS_VTK_POLYHEDRON
|
||||
vtkIdType nFaces = cFaces.size();
|
||||
vtkIdType nLabels = nFaces;
|
||||
|
||||
@ -320,33 +319,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
}
|
||||
|
||||
vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data());
|
||||
#else
|
||||
// this is a horrible substitute
|
||||
// but avoids crashes when there is no vtkPolyhedron support
|
||||
|
||||
// establish unique node ids used
|
||||
HashSet<vtkIdType, Hash<label>> hashUniqId(2*256);
|
||||
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh.faces()[cFaces[cFaceI]];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
hashUniqId.insert(f[fp]);
|
||||
}
|
||||
}
|
||||
|
||||
// use face stream to store unique node ids:
|
||||
faceStream = hashUniqId.sortedToc();
|
||||
|
||||
vtkmesh->InsertNextCell
|
||||
(
|
||||
VTK_CONVEX_POINT_SET,
|
||||
vtkIdType(faceStream.size()),
|
||||
faceStream.data()
|
||||
);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -46,13 +46,16 @@ QT4_WRAP_CPP(MOC_SRCS pqPVblockMeshReaderPanel.h)
|
||||
|
||||
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
|
||||
CLASS_NAME pqPVblockMeshReaderPanel
|
||||
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
|
||||
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
|
||||
XML_GROUP sources
|
||||
)
|
||||
|
||||
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
|
||||
# so check if version < 4.4
|
||||
|
||||
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
@ -60,16 +63,16 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
GUI_RESOURCE_FILES PVblockMeshReader.xml
|
||||
)
|
||||
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
ELSE()
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
)
|
||||
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
|
||||
ENDIF()
|
||||
|
||||
# Build the client-side plugin
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<ParaViewReaders>
|
||||
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
|
||||
<Reader name="PVblockMeshReader"
|
||||
extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh reader">
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,8 @@ Group
|
||||
|
||||
Description
|
||||
List times using timeSelector.
|
||||
To simplify parsing of the output, the normal banner information
|
||||
is suppressed.
|
||||
|
||||
Usage
|
||||
|
||||
|
||||
14
applications/utilities/postProcessing/noise/Allwmake
Executable file
14
applications/utilities/postProcessing/noise/Allwmake
Executable file
@ -0,0 +1,14 @@
|
||||
#!/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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,6 +1,7 @@
|
||||
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;
|
||||
noiseModel surfaceNoise; // pointNoise
|
||||
|
||||
pressureData
|
||||
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 true;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
IOdictionary dict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dictName,
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
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);
|
||||
autoPtr<noiseModel> model(noiseModel::New(dict));
|
||||
model->calculate();
|
||||
|
||||
Info<< nl << "End\n" << endl;
|
||||
|
||||
|
||||
136
applications/utilities/postProcessing/noise/noiseDict
Normal file
136
applications/utilities/postProcessing/noise/noiseDict
Normal file
@ -0,0 +1,136 @@
|
||||
/*--------------------------------*- 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 true;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -71,7 +71,7 @@ formatOptions
|
||||
{
|
||||
// ascii/binary format
|
||||
format ascii;
|
||||
//collateTimes true; // write single file containing multiple timesteps
|
||||
collateTimes true; // write single file containing multiple timesteps
|
||||
// (only for static surfaces)
|
||||
}
|
||||
vtk
|
||||
|
||||
14
applications/utilities/preProcessing/boxTurb/Allwmake
Executable file
14
applications/utilities/preProcessing/boxTurb/Allwmake
Executable file
@ -0,0 +1,14 @@
|
||||
#!/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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,8 @@ Group
|
||||
|
||||
Description
|
||||
Miscellaneous information about surface meshes.
|
||||
To simplify parsing of the output, the normal banner information
|
||||
is suppressed.
|
||||
|
||||
Usage
|
||||
- surfaceMeshInfo surfaceFile [OPTION]
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
# \\/ 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/>.
|
||||
#
|
||||
# Script
|
||||
# engridFoam
|
||||
#
|
||||
# Description
|
||||
# start engrid using the paraview libraries from OpenFOAM
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
|
||||
Usage: ${0##*/} [OPTION]
|
||||
options:
|
||||
-help
|
||||
|
||||
* start engrid using the paraview-$ParaView_MAJOR libraries
|
||||
passes through engrid options unmodified
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
# report usage
|
||||
[ "$1" = "-h" -o "$1" = "-help" ] && usage
|
||||
|
||||
bindir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/engrid
|
||||
libdir="$ParaView_DIR/lib/paraview-${ParaView_MAJOR:-unknown}"
|
||||
|
||||
[ -x $bindir/engrid ] || usage "engrid executable not found in $bindir"
|
||||
[ -d $libdir ] || usage "paraview libraries not found"
|
||||
|
||||
export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
|
||||
echo "starting $bindir/engrid $@"
|
||||
eval "exec $bindir/engrid $@ &"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
75
bin/paraFoam
75
bin/paraFoam
@ -4,7 +4,7 @@
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# \\/ M anipulation |
|
||||
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
@ -40,17 +40,18 @@ usage() {
|
||||
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
|
||||
options:
|
||||
-block use blockMesh reader (uses .blockMesh extension)
|
||||
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
|
||||
-case <dir> specify alternative case directory, default is the cwd
|
||||
-region <name> specify alternative mesh region
|
||||
-touch only create the file (eg, .blockMesh, .OpenFOAM, etc)
|
||||
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
|
||||
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
|
||||
-help print the usage
|
||||
|
||||
Paraview options start with a double dashes.
|
||||
|
||||
paraview options start with a double dashes
|
||||
* start paraview with the OpenFOAM libraries
|
||||
|
||||
* start paraview $ParaView_VERSION with the OpenFOAM libraries
|
||||
paraview=$(command -v paraview)
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
@ -67,10 +68,9 @@ unset regionName optTouch
|
||||
# already 2010-07)
|
||||
export LC_ALL=C
|
||||
|
||||
# Reader extension
|
||||
# Reader extension and plugin
|
||||
extension=OpenFOAM
|
||||
|
||||
requirePV=1
|
||||
plugin=PVFoamReader
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
@ -81,11 +81,12 @@ do
|
||||
;;
|
||||
-block | -blockMesh)
|
||||
extension=blockMesh
|
||||
plugin=PVblockMeshReader
|
||||
shift
|
||||
;;
|
||||
-builtin)
|
||||
-builtin | -vtk)
|
||||
extension=foam
|
||||
requirePV=0
|
||||
unset plugin
|
||||
shift
|
||||
;;
|
||||
-case)
|
||||
@ -100,12 +101,12 @@ do
|
||||
;;
|
||||
-touch)
|
||||
optTouch=true
|
||||
requirePV=0
|
||||
unset plugin
|
||||
shift
|
||||
;;
|
||||
-touchAll)
|
||||
optTouch=all
|
||||
requirePV=0
|
||||
unset plugin
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
@ -116,26 +117,34 @@ do
|
||||
break # Stop here, treat this and balance as paraview options
|
||||
;;
|
||||
*)
|
||||
usage "unknown option/argument: '$*'"
|
||||
usage "unknown option/argument: '$1'"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check that reader module has been built
|
||||
if [ $requirePV -eq 1 -a ! -f $PV_PLUGIN_PATH/libPVFoamReader_SM.so ]
|
||||
then
|
||||
cat<< BUILDREADER
|
||||
|
||||
FATAL ERROR: ParaView reader module libraries do not exist
|
||||
# If a reader module is needed, check that it exists
|
||||
[ -z "$plugin" -o -f $PV_PLUGIN_PATH/lib${plugin}_SM.so ] || {
|
||||
cat<< BUILDREADER 1>&2
|
||||
|
||||
ERROR: ParaView reader module library ($plugin) does not exist
|
||||
Please build the reader module before continuing:
|
||||
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
|
||||
./Allwclean
|
||||
./Allwmake
|
||||
|
||||
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
|
||||
./Allwclean
|
||||
./Allwmake
|
||||
|
||||
BUILDREADER
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Fallback to native reader, if possible
|
||||
if [ "$extension" = OpenFOAM ]
|
||||
then
|
||||
extension=foam
|
||||
echo "Using the native VTK/OpenFOAM reader instead" 1>&2
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Check for --data=... argument
|
||||
hasDataArg()
|
||||
@ -165,7 +174,7 @@ if [ -n "$regionName" ]
|
||||
then
|
||||
if [ ! -d constant/$regionName ]
|
||||
then
|
||||
echo "FATAL ERROR: Region $regionName does not exist"
|
||||
echo "FATAL ERROR: Region $regionName does not exist" 1>&2
|
||||
exit 1
|
||||
else
|
||||
caseFile="$caseName{$regionName}.$extension"
|
||||
@ -179,10 +188,10 @@ all)
|
||||
if [ -f system/blockMeshDict -o -f constant/polyMesh/blockMeshDict ]
|
||||
then
|
||||
touch "$caseName.blockMesh"
|
||||
echo "Created '$caseName.blockMesh'"
|
||||
echo "Created '$caseName.blockMesh'" 1>&2
|
||||
fi
|
||||
touch "$caseName.$extension"
|
||||
echo "Created '$caseName.$extension'"
|
||||
echo "Created '$caseName.$extension'" 1>&2
|
||||
# Discover probable regions
|
||||
for region in constant/*
|
||||
do
|
||||
@ -190,14 +199,14 @@ all)
|
||||
then
|
||||
regionName=${region##*/}
|
||||
touch "$caseName{$regionName}.$extension"
|
||||
echo "Created '$caseName{$regionName}.$extension'"
|
||||
echo "Created '$caseName{$regionName}.$extension'" 1>&2
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
;;
|
||||
true)
|
||||
touch "$caseFile"
|
||||
echo "Created '$caseFile'"
|
||||
echo "Created '$caseFile'" 1>&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
@ -222,14 +231,14 @@ else
|
||||
warn="WARN file does not exist:"
|
||||
case $extension in
|
||||
blockMesh)
|
||||
blockMeshDictDir=system/blockMeshDict
|
||||
blockMeshDict=system/blockMeshDict
|
||||
if [ -f constant/polyMesh/blockMeshDict ]
|
||||
then
|
||||
blockMeshDictDir=constant/polyMesh/blockMeshDict
|
||||
blockMeshDict=constant/polyMesh/blockMeshDict
|
||||
fi
|
||||
for check in \
|
||||
system/controlDict \
|
||||
$blockMeshDictDir \
|
||||
$blockMeshDict \
|
||||
;
|
||||
do
|
||||
[ -s "$parentDir/$check" ] || {
|
||||
@ -240,7 +249,7 @@ else
|
||||
done
|
||||
;;
|
||||
|
||||
builtin | OpenFOAM)
|
||||
OpenFOAM)
|
||||
for check in \
|
||||
system/controlDict \
|
||||
$fvControls/fvSchemes \
|
||||
@ -268,7 +277,7 @@ else
|
||||
[ -e $caseFile ] || {
|
||||
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
||||
touch "$caseFile"
|
||||
echo "Created temporary '$caseFile'"
|
||||
echo "Created temporary '$caseFile'" 1>&2
|
||||
}
|
||||
|
||||
# For now filter out any ld.so errors. Caused by non-system compiler?
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
set boost_version=boost-system
|
||||
set boost_version=boost_1_61_0
|
||||
set cgal_version=CGAL-4.8
|
||||
|
||||
setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
set fftw_version=fftw-system
|
||||
set fftw_version=fftw-3.3.4
|
||||
|
||||
setenv FFTW_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
# - the LD_LIBRARY_PATH is not adjusted.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
boost_version=boost-system
|
||||
boost_version=boost_1_61_0
|
||||
cgal_version=CGAL-4.8
|
||||
|
||||
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
# - the LD_LIBRARY_PATH is not adjusted.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fftw_version=fftw-system
|
||||
fftw_version=fftw-3.3.4
|
||||
|
||||
export FFTW_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# File
|
||||
# etc/config.sh/libccmio
|
||||
# etc/config.sh/ccmio
|
||||
#
|
||||
# Description
|
||||
# Setup file for libccmio include/libraries.
|
||||
@ -116,7 +116,7 @@ else
|
||||
# Cleanup environment:
|
||||
# ~~~~~~~~~~~~~~~~~~~~
|
||||
unset WM_BASH_FUNCTIONS
|
||||
unset _foamAddPath _foamAddLib _foamAddMan
|
||||
unset _foamSource _foamEval
|
||||
unset -f _foamAddPath _foamAddLib _foamAddMan
|
||||
unset -f _foamSource _foamEval
|
||||
|
||||
fi
|
||||
|
||||
@ -58,10 +58,9 @@ wmake $targetType sampling
|
||||
|
||||
# Compile scotchDecomp, metisDecomp etc.
|
||||
parallel/Allwmake $targetType $*
|
||||
randomProcesses/Allwmake $targetType $*
|
||||
|
||||
wmake $targetType ODE
|
||||
wmake $targetType randomProcesses
|
||||
|
||||
wmake $targetType fvMotionSolver
|
||||
|
||||
transportModels/Allwmake $targetType $*
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
ensight/file/ensightFile.C
|
||||
ensight/file/ensightGeoFile.C
|
||||
ensight/readFile/ensightReadFile.C
|
||||
ensight/part/ensightPart.C
|
||||
ensight/part/ensightPartIO.C
|
||||
ensight/part/ensightPartCells.C
|
||||
|
||||
@ -281,14 +281,15 @@ Foam::Ostream& Foam::ensightFile::writeKeyword(const keyType& key)
|
||||
{
|
||||
if (allowUndef_)
|
||||
{
|
||||
write(string(key + " undef"));
|
||||
write(string(static_cast<const string&>(key) + " undef"));
|
||||
newline();
|
||||
write(undefValue_);
|
||||
newline();
|
||||
}
|
||||
else
|
||||
{
|
||||
write(key);
|
||||
// ensure we get ensightFile::write(const string&)
|
||||
write(static_cast<const string&>(key));
|
||||
newline();
|
||||
}
|
||||
return *this;
|
||||
|
||||
@ -25,8 +25,6 @@ License
|
||||
|
||||
#include "ensightGeoFile.H"
|
||||
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::ensightGeoFile::initialize()
|
||||
@ -76,10 +74,8 @@ Foam::ensightGeoFile::~ensightGeoFile()
|
||||
|
||||
Foam::Ostream& Foam::ensightGeoFile::writeKeyword(const keyType& key)
|
||||
{
|
||||
// Note: make sure to hit ensightFile::write(const string&)
|
||||
write(string(key));
|
||||
|
||||
newline();
|
||||
// ensure we get ensightFile::write(const string&)
|
||||
write(static_cast<const string&>(key)); newline();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
157
src/conversion/ensight/readFile/ensightReadFile.C
Normal file
157
src/conversion/ensight/readFile/ensightReadFile.C
Normal file
@ -0,0 +1,157 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
{
|
||||
stdStream() >> value;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ensightReadFile::readKeyword(string& key)
|
||||
{
|
||||
read(key);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ensightReadFile::readBinaryHeader()
|
||||
{
|
||||
if (format() == IOstream::BINARY)
|
||||
{
|
||||
string buffer;
|
||||
read(buffer);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
110
src/conversion/ensight/readFile/ensightReadFile.H
Normal file
110
src/conversion/ensight/readFile/ensightReadFile.H
Normal file
@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Class
|
||||
Foam::ensightReadFile
|
||||
|
||||
Description
|
||||
Ensight output with specialized read() for strings, integers and floats.
|
||||
Correctly handles binary read as well.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightReadFile_H
|
||||
#define ensightReadFile_H
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "IOstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightReadFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightReadFile
|
||||
:
|
||||
public IFstream
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightReadFile&);
|
||||
|
||||
//- Disallow default copy constructor
|
||||
ensightReadFile(const ensightReadFile&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
ensightReadFile
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstream::streamFormat format=IOstream::BINARY
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~ensightReadFile();
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
//- Inherit read from Istream
|
||||
using Istream::read;
|
||||
|
||||
//- Binary read
|
||||
virtual Istream& read(char* buf, std::streamsize count);
|
||||
|
||||
//- Read string as "%80s" or as binary
|
||||
Istream& read(string& value);
|
||||
|
||||
//- Read integer as "%10d" or as binary
|
||||
Istream& read(label& value);
|
||||
|
||||
//- Read float as "%12.5e" or as binary
|
||||
Istream& read(scalar& value);
|
||||
|
||||
//- Read element keyword
|
||||
virtual Istream& readKeyword(string& key);
|
||||
|
||||
//- Read "C Binary" for binary files (eg, geometry/measured)
|
||||
Istream& readBinaryHeader();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -80,10 +80,14 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeEddyOBJ() const
|
||||
// label i2 = ((i + 1) % nPoint) + nPoint;
|
||||
// os << "l " << i1 << " " << i2 << nl;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
OFstream os(db().time().path()/"eddies.obj");
|
||||
const Time& time = db().time();
|
||||
OFstream os
|
||||
(
|
||||
time.path()/"eddies_" + Foam::name(time.timeIndex()) + ".obj"
|
||||
);
|
||||
|
||||
label pointOffset = 0;
|
||||
forAll(eddies_, eddyI)
|
||||
@ -91,7 +95,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeEddyOBJ() const
|
||||
const eddy& e = eddies_[eddyI];
|
||||
pointOffset += e.writeSurfaceOBJ(pointOffset, patchNormal_, os);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -137,7 +141,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeLumleyCoeffs() const
|
||||
scalar eta = sqrt(-ii/3.0);
|
||||
os << xi << token::TAB << eta << token::TAB
|
||||
<< ii << token::TAB << iii << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After interpolation
|
||||
@ -1103,7 +1107,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::write(Ostream& os) const
|
||||
writeEntryIfDifferent(os, "d", 1.0, d_);
|
||||
writeEntryIfDifferent(os, "kappa", 0.41, kappa_);
|
||||
writeEntryIfDifferent(os, "perturb", 1e-5, perturb_);
|
||||
writeEntryIfDifferent(os, "nCellPerEddy", 5, nCellPerEddy_);
|
||||
writeEntryIfDifferent<label>(os, "nCellPerEddy", 5, nCellPerEddy_);
|
||||
writeEntryIfDifferent(os, "writeEddies", false, writeEddies_);
|
||||
|
||||
if (!interpolateR_)
|
||||
|
||||
@ -67,9 +67,9 @@ void Foam::fv::acousticDampingSource::setBlendingFactor()
|
||||
{
|
||||
blendFactor_[celli] = 0.0;
|
||||
}
|
||||
else if ((d >= r1_) && (d <= (r1_ + r2_)))
|
||||
else if ((d >= r1_) && (d <= r2_))
|
||||
{
|
||||
blendFactor_[celli] = (1.0 - cos(pi*mag(d - r1_)/r2_))/2.0;
|
||||
blendFactor_[celli] = (1.0 - cos(pi*mag(d - r1_)/(r2_ - r1_)))/2.0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,6 +206,8 @@ bool Foam::fv::acousticDampingSource::read(const dictionary& dict)
|
||||
Info<< name_ << ": Setting stencil width to " << w_ << endl;
|
||||
}
|
||||
|
||||
setBlendingFactor();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
@ -25,12 +25,17 @@ Class
|
||||
Foam::EulerCoordinateRotation
|
||||
|
||||
Description
|
||||
A coordinateRotation defined in the z-x-y Euler convention.
|
||||
A coordinateRotation defined in the z-x-z (intrinsic) Euler convention.
|
||||
|
||||
The 3 rotations are defined in the Euler intrinsic convention
|
||||
(around Z, around X' and around Z'').
|
||||
The order of the parameter arguments matches this rotation order.
|
||||
|
||||
The 3 rotations are defined in the Euler convention
|
||||
(around Z, around X' and around Z').
|
||||
For reference and illustration, see
|
||||
http://mathworld.wolfram.com/EulerAngles.html
|
||||
and
|
||||
https://en.wikipedia.org/wiki/Euler_angles#Conventions
|
||||
|
||||
Note, however, that it is the reverse transformation
|
||||
(local->global) that is defined here.
|
||||
|
||||
|
||||
@ -18,10 +18,8 @@ fluxSummary/fluxSummaryFunctionObject.C
|
||||
Lambda2/Lambda2.C
|
||||
Lambda2/Lambda2FunctionObject.C
|
||||
|
||||
/*
|
||||
mapFields/mapFields.C
|
||||
mapFields/mapFieldsFunctionObject.C
|
||||
*/
|
||||
|
||||
Peclet/Peclet.C
|
||||
Peclet/PecletFunctionObject.C
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOmapFields
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for mapFields.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOmapFields_H
|
||||
#define IOmapFields_H
|
||||
|
||||
#include "mapFields.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<mapFields> IOmapFields;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,221 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "mapFields.H"
|
||||
#include "meshToMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(mapFieldsFO, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::mapFieldsFO::createInterpolation(const dictionary& dict)
|
||||
{
|
||||
const fvMesh& meshTarget = static_cast<const fvMesh&>(obr_);
|
||||
const word mapRegionName(dict.lookup("mapRegion"));
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< name_ << ':' << nl
|
||||
<< " Reading mesh " << mapRegionName << endl;
|
||||
}
|
||||
|
||||
mapRegionPtr_.reset
|
||||
(
|
||||
new fvMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
mapRegionName,
|
||||
meshTarget.time().constant(),
|
||||
meshTarget.time()
|
||||
)
|
||||
)
|
||||
);
|
||||
const fvMesh& mapRegion = mapRegionPtr_();
|
||||
word mapMethodName(dict.lookup("mapMethod"));
|
||||
if (!meshToMesh::interpolationMethodNames_.found(mapMethodName))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name_ << ": unknown map method "
|
||||
<< mapMethodName << nl
|
||||
<< "Available methods include: "
|
||||
<< meshToMesh::interpolationMethodNames_.sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
meshToMesh::interpolationMethod mapMethod
|
||||
(
|
||||
meshToMesh::interpolationMethodNames_[mapMethodName]
|
||||
);
|
||||
|
||||
// Lookup corresponding AMI method
|
||||
word patchMapMethodName =
|
||||
AMIPatchToPatchInterpolation::interpolationMethodToWord
|
||||
(
|
||||
meshToMesh::interpolationMethodAMI(mapMethod)
|
||||
);
|
||||
|
||||
// Optionally override
|
||||
if (dict.readIfPresent("patchMapMethod", patchMapMethodName))
|
||||
{
|
||||
if (log_)
|
||||
Info<< " Patch mapping method: " << patchMapMethodName << endl;
|
||||
}
|
||||
|
||||
bool consistent = readBool(dict.lookup("consistent"));
|
||||
|
||||
if (log_) Info<< " Creating mesh to mesh interpolation" << endl;
|
||||
|
||||
if (consistent)
|
||||
{
|
||||
interpPtr_.reset
|
||||
(
|
||||
new meshToMesh
|
||||
(
|
||||
mapRegion,
|
||||
meshTarget,
|
||||
mapMethodName,
|
||||
patchMapMethodName
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
HashTable<word> patchMap(dict.lookup("patchMap"));
|
||||
wordList cuttingPatches(dict.lookup("cuttingPatches"));
|
||||
|
||||
interpPtr_.reset
|
||||
(
|
||||
new meshToMesh
|
||||
(
|
||||
mapRegion,
|
||||
meshTarget,
|
||||
mapMethodName,
|
||||
patchMapMethodName,
|
||||
patchMap,
|
||||
cuttingPatches
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::mapFieldsFO::mapFieldsFO
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
mapRegionPtr_(),
|
||||
interpPtr_(),
|
||||
fieldNames_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningInFunction
|
||||
<< "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::mapFieldsFO::~mapFieldsFO()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::mapFieldsFO::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_.readIfPresent("log", dict);
|
||||
dict.lookup("fields") >> fieldNames_;
|
||||
|
||||
createInterpolation(dict);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::mapFieldsFO::execute()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::mapFieldsFO::end()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::mapFieldsFO::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::mapFieldsFO::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
if (log_) Info
|
||||
<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
ok = writeFieldType<scalar>() || ok;
|
||||
ok = writeFieldType<vector>() || ok;
|
||||
ok = writeFieldType<sphericalTensor>() || ok;
|
||||
ok = writeFieldType<symmTensor>() || ok;
|
||||
ok = writeFieldType<tensor>() || ok;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
if (!ok)
|
||||
{
|
||||
Info<< " none" << nl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,200 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Class
|
||||
Foam::mapFields
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Map fields from local mesh to secondary mesh at run-time.
|
||||
|
||||
Example of function object specification to map fields:
|
||||
\verbatim
|
||||
mapFields1
|
||||
{
|
||||
type mapFields;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
|
||||
mapRegion coarseMesh;
|
||||
mapMethod cellVolumeWeight;
|
||||
consistent yes;
|
||||
|
||||
fields ("U.*" p);
|
||||
}
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: mapFields | yes |
|
||||
mapRgion | Name of region to map to | yes |
|
||||
mapMethod | Mapping method | yes |
|
||||
patchMapMethod | Patch mapping method | no | <auto>
|
||||
consistent | Mapping meshes have consistent boundaries | yes |
|
||||
fields | List of field names to map | yes |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
|
||||
SourceFiles
|
||||
mapFields.C
|
||||
IOmapFields.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mapFieldsFO_H
|
||||
#define mapFieldsFO_H
|
||||
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
class meshToMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class mapFields Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class mapFieldsFO
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of mapFields objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Locally cached map region mesh (map to this mesh)
|
||||
autoPtr<fvMesh> mapRegionPtr_;
|
||||
|
||||
//- Mesh-to-mesh interpolation
|
||||
autoPtr<meshToMesh> interpPtr_;
|
||||
|
||||
//- List of field names to interpolate
|
||||
wordReList fieldNames_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
mapFieldsFO(const mapFieldsFO&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const mapFieldsFO&) = delete;
|
||||
|
||||
//- Helper function to create the mesh-to-mesh interpolation
|
||||
void createInterpolation(const dictionary& dict);
|
||||
|
||||
//- Helper function to interpolate and write the fied
|
||||
template<class Type>
|
||||
bool writeFieldType() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("mapFieldsFO");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
mapFieldsFO
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~mapFieldsFO();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of mapFields
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the mapFields data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the mapFields and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "mapFieldsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "mapFieldsFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(mapFieldsFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
mapFieldsFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::mapFieldsFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around mapFields to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
mapFieldsFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mapFieldsFunctionObject_H
|
||||
#define mapFieldsFunctionObject_H
|
||||
|
||||
#include "mapFields.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<mapFieldsFO> mapFieldsFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "meshToMesh.H"
|
||||
|
||||
template<class Type>
|
||||
bool Foam::mapFieldsFO::writeFieldType() const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
|
||||
const fvMesh& mapRegion = mapRegionPtr_();
|
||||
|
||||
wordList fieldNames(obr_.names(FieldType::typeName));
|
||||
labelList selected = findStrings(fieldNames_, fieldNames);
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[selected[i]];
|
||||
const FieldType& field = obr_.lookupObject<FieldType>(fieldName);
|
||||
|
||||
if (log_) Info << " " << fieldName;
|
||||
|
||||
IOobject mapRegionIO
|
||||
(
|
||||
fieldName,
|
||||
field.time().timeName(),
|
||||
mapRegion
|
||||
);
|
||||
|
||||
tmp<FieldType> tfieldMapRegion(interpPtr_->mapTgtToSrc(field));
|
||||
|
||||
if (log_) Info<< ": interpolated";
|
||||
|
||||
FieldType fieldMapRegion(mapRegionIO, tfieldMapRegion);
|
||||
fieldMapRegion.write();
|
||||
|
||||
if (log_) Info<< " and written" << nl;
|
||||
}
|
||||
|
||||
return selected.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
18
src/randomProcesses/Allwmake
Executable file
18
src/randomProcesses/Allwmake
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
targetType=libso
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
if [ -f "$FFTW_ARCH_PATH/include/fftw3.h" ] || \
|
||||
[ "${FFTW_ARCH_PATH##*-}" = system -a -f "/usr/include/fftw3.h" ]
|
||||
then
|
||||
wmake $targetType
|
||||
else
|
||||
echo
|
||||
echo "Skipping randomProcesses library (no FFTW)"
|
||||
echo
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -35,7 +35,7 @@ inline Foam::label Foam::Kmesh::index
|
||||
const label i,
|
||||
const label j,
|
||||
const label k,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
)
|
||||
{
|
||||
return (k + j*nn[2] + i*nn[1]*nn[2]);
|
||||
|
||||
@ -57,7 +57,7 @@ class Kmesh
|
||||
vector l_;
|
||||
|
||||
//- Multi-dimensional addressing array
|
||||
labelList nn_;
|
||||
List<int> nn_;
|
||||
|
||||
//- Maximum wavenumber
|
||||
scalar kmax_;
|
||||
@ -71,7 +71,7 @@ class Kmesh
|
||||
const label i,
|
||||
const label j,
|
||||
const label k,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
);
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ public:
|
||||
return l_;
|
||||
}
|
||||
|
||||
const labelList& nn() const
|
||||
const List<int>& nn() const
|
||||
{
|
||||
return nn_;
|
||||
}
|
||||
|
||||
@ -1,25 +1,31 @@
|
||||
Kmesh = Kmesh
|
||||
|
||||
fft = fft
|
||||
|
||||
processes = processes
|
||||
UOprocess = $(processes)/UOprocess
|
||||
|
||||
turbulence = turbulence
|
||||
|
||||
noise = noise
|
||||
|
||||
Kmesh = Kmesh
|
||||
$(Kmesh)/Kmesh.C
|
||||
|
||||
fft = fft
|
||||
$(fft)/fft.C
|
||||
$(fft)/fftRenumber.C
|
||||
$(fft)/calcEk.C
|
||||
$(fft)/kShellIntegration.C
|
||||
|
||||
processes = processes
|
||||
UOprocess = $(processes)/UOprocess
|
||||
$(UOprocess)/UOprocess.C
|
||||
|
||||
turbulence = turbulence
|
||||
$(turbulence)/turbGen.C
|
||||
|
||||
$(noise)/noiseFFT.C
|
||||
noise = noise
|
||||
$(noise)/noiseFFT/noiseFFT.C
|
||||
$(noise)/noiseModels/noiseModel/noiseModel.C
|
||||
$(noise)/noiseModels/noiseModel/noiseModelNew.C
|
||||
$(noise)/noiseModels/pointNoise/pointNoise.C
|
||||
$(noise)/noiseModels/surfaceNoise/surfaceNoise.C
|
||||
|
||||
|
||||
windowModels = windowModels
|
||||
$(windowModels)/windowModel/windowModel.C
|
||||
$(windowModels)/windowModel/windowModelNew.C
|
||||
$(windowModels)/Hanning/Hanning.C
|
||||
$(windowModels)/uniform/uniform.C
|
||||
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/librandomProcesses
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
-I$(FFTW_ARCH_PATH)/include \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume
|
||||
-L$(FFTW_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) -lfftw3 \
|
||||
-lfiniteVolume \
|
||||
-lsampling \
|
||||
-lsurfMesh
|
||||
|
||||
@ -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.
|
||||
@ -24,7 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fft.H"
|
||||
#include "fftRenumber.H"
|
||||
|
||||
#include <fftw3.h>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -33,16 +34,11 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define SWAP(a,b) tempr=(a); (a)=(b); (b)=tempr
|
||||
#define TWOPI 6.28318530717959
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void fft::transform
|
||||
(
|
||||
complexField& field,
|
||||
const labelList& nn,
|
||||
transformDirection isign
|
||||
const UList<int>& nn,
|
||||
transformDirection dir
|
||||
)
|
||||
{
|
||||
forAll(nn, idim)
|
||||
@ -59,134 +55,64 @@ void fft::transform
|
||||
}
|
||||
}
|
||||
|
||||
const label ndim = nn.size();
|
||||
|
||||
label i1, i2, i3, i2rev, i3rev, ip1, ip2, ip3, ifp1, ifp2;
|
||||
label ibit, k1, k2, n, nprev, nrem, idim;
|
||||
scalar tempi, tempr;
|
||||
scalar theta, wi, wpi, wpr, wr, wtemp;
|
||||
scalar* data = reinterpret_cast<scalar*>(field.begin()) - 1;
|
||||
|
||||
|
||||
// if inverse transform : renumber before transform
|
||||
|
||||
if (isign == REVERSE_TRANSFORM)
|
||||
{
|
||||
fftRenumber(field, nn);
|
||||
}
|
||||
|
||||
|
||||
label ntot = 1;
|
||||
forAll(nn, idim)
|
||||
{
|
||||
ntot *= nn[idim];
|
||||
}
|
||||
|
||||
|
||||
nprev = 1;
|
||||
|
||||
for (idim=ndim; idim>=1; idim--)
|
||||
{
|
||||
n = nn[idim-1];
|
||||
nrem = ntot/(n*nprev);
|
||||
ip1 = nprev << 1;
|
||||
ip2 = ip1*n;
|
||||
ip3 = ip2*nrem;
|
||||
i2rev = 1;
|
||||
|
||||
for (i2=1; i2<=ip2; i2+=ip1)
|
||||
{
|
||||
if (i2 < i2rev)
|
||||
{
|
||||
for (i1=i2; i1<=i2 + ip1 - 2; i1+=2)
|
||||
{
|
||||
for (i3=i1; i3<=ip3; i3+=ip2)
|
||||
{
|
||||
i3rev = i2rev + i3 - i2;
|
||||
SWAP(data[i3], data[i3rev]);
|
||||
SWAP(data[i3 + 1], data[i3rev + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ibit = ip2 >> 1;
|
||||
while (ibit >= ip1 && i2rev > ibit)
|
||||
{
|
||||
i2rev -= ibit;
|
||||
ibit >>= 1;
|
||||
}
|
||||
|
||||
i2rev += ibit;
|
||||
}
|
||||
|
||||
ifp1 = ip1;
|
||||
|
||||
while (ifp1 < ip2)
|
||||
{
|
||||
ifp2 = ifp1 << 1;
|
||||
theta = isign*TWOPI/(ifp2/ip1);
|
||||
wtemp = sin(0.5*theta);
|
||||
wpr = -2.0*wtemp*wtemp;
|
||||
wpi = sin(theta);
|
||||
wr = 1.0;
|
||||
wi = 0.0;
|
||||
|
||||
for (i3 = 1; i3 <= ifp1; i3 += ip1)
|
||||
{
|
||||
for (i1 = i3; i1 <= i3 + ip1 - 2; i1 += 2)
|
||||
{
|
||||
for (i2 = i1; i2 <= ip3; i2 += ifp2)
|
||||
{
|
||||
k1 = i2;
|
||||
k2 = k1 + ifp1;
|
||||
tempr = scalar(wr*data[k2]) - scalar(wi*data[k2 + 1]);
|
||||
tempi = scalar(wr*data[k2 + 1]) + scalar(wi*data[k2]);
|
||||
data[k2] = data[k1] - tempr;
|
||||
data[k2 + 1] = data[k1 + 1] - tempi;
|
||||
data[k1] += tempr;
|
||||
data[k1 + 1] += tempi;
|
||||
}
|
||||
}
|
||||
|
||||
wr = (wtemp = wr)*wpr - wi*wpi + wr;
|
||||
wi = wi*wpr + wtemp*wpi + wi;
|
||||
}
|
||||
ifp1 = ifp2;
|
||||
}
|
||||
nprev *= n;
|
||||
}
|
||||
|
||||
|
||||
// if forward transform : renumber after transform
|
||||
|
||||
if (isign == FORWARD_TRANSFORM)
|
||||
{
|
||||
fftRenumber(field, nn);
|
||||
}
|
||||
|
||||
|
||||
// scale result (symmetric scale both forward and inverse transform)
|
||||
|
||||
scalar recRootN = 1.0/sqrt(scalar(ntot));
|
||||
// Copy field into fftw containers
|
||||
label N = field.size();
|
||||
fftw_complex in[N], out[N];
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
field[i] *= recRootN;
|
||||
in[i][0] = field[i].Re();
|
||||
in[i][1] = field[i].Im();
|
||||
}
|
||||
|
||||
// Create the plan
|
||||
// FFTW_FORWARD = -1
|
||||
// FFTW_BACKWARD = 1
|
||||
|
||||
// 1-D plan
|
||||
// fftw_plan plan =
|
||||
// fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
|
||||
|
||||
// Generic 1..3-D plan
|
||||
label rank = nn.size();
|
||||
fftw_plan plan =
|
||||
fftw_plan_dft(rank, nn.begin(), in, out, dir, FFTW_ESTIMATE);
|
||||
|
||||
// Compute the FFT
|
||||
fftw_execute(plan);
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
field[i].Re() = out[i][0];
|
||||
field[i].Im() = out[i][1];
|
||||
}
|
||||
|
||||
fftw_destroy_plan(plan);
|
||||
|
||||
/*
|
||||
fftw_real in[N], out[N];
|
||||
// Create a plan for real data input
|
||||
// - generates 1-sided FFT
|
||||
// - direction given by FFTW_R2HC or FFTW_HC2R.
|
||||
// - in[N] is the array of real input val ues
|
||||
// - out[N] is the array of N/2 real valuea followed by N/2 complex values
|
||||
// - 0 component = DC component
|
||||
fftw_plan plan = fftw_plan_r2r_2d(N, in, out, FFTW_R2HC, FFTW_ESTIMATE)
|
||||
|
||||
// Compute the FFT
|
||||
fftw_execute(plan);
|
||||
|
||||
fftw_destroy_plan(plan);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#undef SWAP
|
||||
#undef TWOPI
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
tmp<complexField> fft::forwardTransform
|
||||
(
|
||||
const tmp<complexField>& tfield,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
)
|
||||
{
|
||||
tmp<complexField> tfftField(new complexField(tfield));
|
||||
@ -202,7 +128,7 @@ tmp<complexField> fft::forwardTransform
|
||||
tmp<complexField> fft::reverseTransform
|
||||
(
|
||||
const tmp<complexField>& tfield,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
)
|
||||
{
|
||||
tmp<complexField> tifftField(new complexField(tfield));
|
||||
@ -218,7 +144,7 @@ tmp<complexField> fft::reverseTransform
|
||||
tmp<complexVectorField> fft::forwardTransform
|
||||
(
|
||||
const tmp<complexVectorField>& tfield,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
)
|
||||
{
|
||||
tmp<complexVectorField> tfftVectorField
|
||||
@ -247,7 +173,7 @@ tmp<complexVectorField> fft::forwardTransform
|
||||
tmp<complexVectorField> fft::reverseTransform
|
||||
(
|
||||
const tmp<complexVectorField>& tfield,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
)
|
||||
{
|
||||
tmp<complexVectorField> tifftVectorField
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,14 +25,16 @@ Class
|
||||
Foam::fft
|
||||
|
||||
Description
|
||||
Fast fourier transform derived from the Numerical
|
||||
Recipes in C routine.
|
||||
Fast fourier transform using the fftw library.
|
||||
|
||||
The complex transform field is returned in the field supplied. The
|
||||
direction of transform is supplied as an argument (1 = forward, -1 =
|
||||
direction of transform is supplied as an argument (-1 = forward, 1 =
|
||||
reverse). The dimensionality and organisation of the array of values
|
||||
in space is supplied in the nn indexing array.
|
||||
|
||||
Note
|
||||
The fftw library uses int only (no longs) for its dimensionality.
|
||||
|
||||
SourceFiles
|
||||
fft.C
|
||||
|
||||
@ -42,7 +44,7 @@ SourceFiles
|
||||
#define fft_H
|
||||
|
||||
#include "complexFields.H"
|
||||
#include "labelList.H"
|
||||
#include "UList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -56,15 +58,15 @@ public:
|
||||
|
||||
enum transformDirection
|
||||
{
|
||||
FORWARD_TRANSFORM = 1,
|
||||
REVERSE_TRANSFORM = -1
|
||||
FORWARD_TRANSFORM = -1,
|
||||
REVERSE_TRANSFORM = 1
|
||||
};
|
||||
|
||||
|
||||
static void transform
|
||||
(
|
||||
complexField& field,
|
||||
const labelList& nn,
|
||||
const UList<int>& nn,
|
||||
transformDirection fftDirection
|
||||
);
|
||||
|
||||
@ -72,28 +74,28 @@ public:
|
||||
static tmp<complexField> forwardTransform
|
||||
(
|
||||
const tmp<complexField>& field,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
);
|
||||
|
||||
|
||||
static tmp<complexField> reverseTransform
|
||||
(
|
||||
const tmp<complexField>& field,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
);
|
||||
|
||||
|
||||
static tmp<complexVectorField> forwardTransform
|
||||
(
|
||||
const tmp<complexVectorField>& field,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
);
|
||||
|
||||
|
||||
static tmp<complexVectorField> reverseTransform
|
||||
(
|
||||
const tmp<complexVectorField>& field,
|
||||
const labelList& nn
|
||||
const UList<int>& nn
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -1,124 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Multi-dimensional renumbering used in the Numerical Recipes
|
||||
fft routine. This version is recursive, so works in n-d :
|
||||
determined by the length of array nn
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fftRenumber.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fftRenumberRecurse
|
||||
(
|
||||
List<complex>& data,
|
||||
List<complex>& renumData,
|
||||
const labelList& nn,
|
||||
label nnprod,
|
||||
label ii,
|
||||
label l1,
|
||||
label l2
|
||||
)
|
||||
{
|
||||
if (ii == nn.size())
|
||||
{
|
||||
// we've worked out the renumbering scheme. Now copy
|
||||
// the components across
|
||||
|
||||
data[l1] = complex(renumData[l2].Re(),renumData[l2].Im());
|
||||
}
|
||||
else
|
||||
{
|
||||
// do another level of folding. First work out the
|
||||
// multiplicative value of the index
|
||||
|
||||
nnprod /= nn[ii];
|
||||
label i_1(0);
|
||||
|
||||
for (label i=0; i<nn[ii]; i++)
|
||||
{
|
||||
// now evaluate the indices (both from array 1 and to
|
||||
// array 2). These get multiplied by nnprod to (cumulatively)
|
||||
// find the real position in the list corresponding to
|
||||
// this set of indices.
|
||||
|
||||
if (i<nn[ii]/2)
|
||||
{
|
||||
i_1 = i + nn[ii]/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
i_1 = i - nn[ii]/2;
|
||||
}
|
||||
|
||||
|
||||
// go to the next level of recursion.
|
||||
|
||||
fftRenumberRecurse
|
||||
(
|
||||
data,
|
||||
renumData,
|
||||
nn,
|
||||
nnprod,
|
||||
ii+1,
|
||||
l1+i*nnprod,
|
||||
l2+i_1*nnprod
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fftRenumber
|
||||
(
|
||||
List<complex>& data,
|
||||
const labelList& nn
|
||||
)
|
||||
{
|
||||
List<complex> renumData(data);
|
||||
|
||||
label nnprod(1);
|
||||
forAll(nn, i)
|
||||
{
|
||||
nnprod *= nn[i];
|
||||
}
|
||||
|
||||
label ii(0), l1(0), l2(0);
|
||||
|
||||
fftRenumberRecurse
|
||||
(
|
||||
data,
|
||||
renumData,
|
||||
nn,
|
||||
nnprod,
|
||||
ii,
|
||||
l1,
|
||||
l2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,454 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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 "noiseFFT.H"
|
||||
#include "IFstream.H"
|
||||
#include "DynamicList.H"
|
||||
#include "fft.H"
|
||||
#include "SubField.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::noiseFFT::p0 = 2e-5;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::noiseFFT::noiseFFT
|
||||
(
|
||||
const scalar deltat,
|
||||
const scalarField& pressure
|
||||
)
|
||||
:
|
||||
scalarField(pressure),
|
||||
deltat_(deltat)
|
||||
{}
|
||||
|
||||
|
||||
Foam::noiseFFT::noiseFFT(const fileName& pFileName, const label skip)
|
||||
:
|
||||
scalarField(),
|
||||
deltat_(0.0)
|
||||
{
|
||||
// Construct pressure data file
|
||||
IFstream pFile(pFileName);
|
||||
|
||||
// Check pFile stream is OK
|
||||
if (!pFile.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << pFileName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (skip)
|
||||
{
|
||||
scalar dummyt, dummyp;
|
||||
|
||||
for (label i=0; i<skip; i++)
|
||||
{
|
||||
pFile >> dummyt;
|
||||
|
||||
if (!pFile.good() || pFile.eof())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of points in file " << pFileName
|
||||
<< " is less than the number to be skipped = " << skip
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
pFile >> dummyp;
|
||||
}
|
||||
}
|
||||
|
||||
scalar t = 0, T = 0;
|
||||
DynamicList<scalar> pData(100000);
|
||||
label i = 0;
|
||||
|
||||
while (!(pFile >> t).eof())
|
||||
{
|
||||
T = t;
|
||||
pFile >> pData(i++);
|
||||
}
|
||||
|
||||
deltat_ = T/pData.size();
|
||||
|
||||
this->transfer(pData);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::graph Foam::noiseFFT::pt() const
|
||||
{
|
||||
scalarField t(size());
|
||||
forAll(t, i)
|
||||
{
|
||||
t[i] = i*deltat_;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"p(t)",
|
||||
"t [s]",
|
||||
"p(t) [Pa]",
|
||||
t,
|
||||
*this
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::window
|
||||
(
|
||||
const label N,
|
||||
const label ni
|
||||
) const
|
||||
{
|
||||
label windowOffset = N;
|
||||
|
||||
if ((N + ni*windowOffset) > size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Requested window is outside set of data" << endl
|
||||
<< "number of data = " << size() << endl
|
||||
<< "size of window = " << N << endl
|
||||
<< "window = " << ni
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
tmp<scalarField> tpw(new scalarField(N));
|
||||
scalarField& pw = tpw.ref();
|
||||
|
||||
label offset = ni*windowOffset;
|
||||
|
||||
forAll(pw, i)
|
||||
{
|
||||
pw[i] = operator[](i + offset);
|
||||
}
|
||||
|
||||
return tpw;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::Hanning(const label N) const
|
||||
{
|
||||
scalarField t(N);
|
||||
forAll(t, i)
|
||||
{
|
||||
t[i] = i*deltat_;
|
||||
}
|
||||
|
||||
scalar T = N*deltat_;
|
||||
|
||||
return 2*(0.5 - 0.5*cos(constant::mathematical::twoPi*t/T));
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::Pf
|
||||
(
|
||||
const tmp<scalarField>& tpn
|
||||
) const
|
||||
{
|
||||
tmp<scalarField> tPn2
|
||||
(
|
||||
mag
|
||||
(
|
||||
fft::reverseTransform
|
||||
(
|
||||
ReComplexField(tpn),
|
||||
labelList(1, tpn().size())
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
tpn.clear();
|
||||
|
||||
tmp<scalarField> tPn
|
||||
(
|
||||
new scalarField
|
||||
(
|
||||
scalarField::subField(tPn2(), tPn2().size()/2)
|
||||
)
|
||||
);
|
||||
scalarField& Pn = tPn.ref();
|
||||
|
||||
Pn *= 2.0/sqrt(scalar(tPn2().size()));
|
||||
Pn[0] /= 2.0;
|
||||
|
||||
return tPn;
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::meanPf
|
||||
(
|
||||
const label N,
|
||||
const label nw
|
||||
) const
|
||||
{
|
||||
if (N > size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Requested window is outside set of data" << nl
|
||||
<< "number of data = " << size() << nl
|
||||
<< "size of window = " << N << nl
|
||||
<< "window = " << nw
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
scalarField MeanPf(N/2, 0.0);
|
||||
|
||||
scalarField Hwf(Hanning(N));
|
||||
|
||||
for (label wi=0; wi<nw; ++wi)
|
||||
{
|
||||
MeanPf += Pf(Hwf*window(N, wi));
|
||||
}
|
||||
|
||||
MeanPf /= nw;
|
||||
|
||||
scalarField f(MeanPf.size());
|
||||
scalar deltaf = 1.0/(N*deltat_);
|
||||
|
||||
forAll(f, i)
|
||||
{
|
||||
f[i] = i*deltaf;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"P(f)",
|
||||
"f [Hz]",
|
||||
"P(f) [Pa]",
|
||||
f,
|
||||
MeanPf
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::RMSmeanPf
|
||||
(
|
||||
const label N,
|
||||
const label nw
|
||||
) const
|
||||
{
|
||||
if (N > size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Requested window is outside set of data" << endl
|
||||
<< "number of data = " << size() << endl
|
||||
<< "size of window = " << N << endl
|
||||
<< "window = " << nw
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
scalarField RMSMeanPf(N/2, 0.0);
|
||||
|
||||
scalarField Hwf(Hanning(N));
|
||||
|
||||
for (label wi=0; wi<nw; ++wi)
|
||||
{
|
||||
RMSMeanPf += sqr(Pf(Hwf*window(N, wi)));
|
||||
}
|
||||
|
||||
RMSMeanPf = sqrt(RMSMeanPf/nw);
|
||||
|
||||
scalarField f(RMSMeanPf.size());
|
||||
scalar deltaf = 1.0/(N*deltat_);
|
||||
|
||||
forAll(f, i)
|
||||
{
|
||||
f[i] = i*deltaf;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"P(f)",
|
||||
"f [Hz]",
|
||||
"P(f) [Pa]",
|
||||
f,
|
||||
RMSMeanPf
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::Lf(const graph& gPf) const
|
||||
{
|
||||
return graph
|
||||
(
|
||||
"L(f)",
|
||||
"f [Hz]",
|
||||
"L(f) [dB]",
|
||||
gPf.x(),
|
||||
20*log10(gPf.y()/p0)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::Ldelta
|
||||
(
|
||||
const graph& gLf,
|
||||
const scalar f1,
|
||||
const scalar fU
|
||||
) const
|
||||
{
|
||||
const scalarField& f = gLf.x();
|
||||
const scalarField& Lf = gLf.y();
|
||||
|
||||
scalarField ldelta(Lf.size(), 0.0);
|
||||
scalarField fm(ldelta.size());
|
||||
|
||||
scalar fratio = cbrt(2.0);
|
||||
scalar deltaf = 1.0/(2*Lf.size()*deltat_);
|
||||
|
||||
scalar fl = f1/sqrt(fratio);
|
||||
scalar fu = fratio*fl;
|
||||
|
||||
label istart = label(fl/deltaf);
|
||||
label j = 0;
|
||||
|
||||
for (label i = istart; i<Lf.size(); i++)
|
||||
{
|
||||
scalar fmi = sqrt(fu*fl);
|
||||
|
||||
if (fmi > fU + 1) break;
|
||||
|
||||
if (f[i] >= fu)
|
||||
{
|
||||
fm[j] = fmi;
|
||||
ldelta[j] = 10*log10(ldelta[j]);
|
||||
|
||||
j++;
|
||||
|
||||
fl = fu;
|
||||
fu *= fratio;
|
||||
}
|
||||
|
||||
ldelta[j] += pow(10, Lf[i]/10.0);
|
||||
}
|
||||
|
||||
fm.setSize(j);
|
||||
ldelta.setSize(j);
|
||||
|
||||
return graph
|
||||
(
|
||||
"Ldelta",
|
||||
"fm [Hz]",
|
||||
"Ldelta [dB]",
|
||||
fm,
|
||||
ldelta
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::Pdelta
|
||||
(
|
||||
const graph& gPf,
|
||||
const scalar f1,
|
||||
const scalar fU
|
||||
) const
|
||||
{
|
||||
const scalarField& f = gPf.x();
|
||||
const scalarField& Pf = gPf.y();
|
||||
|
||||
scalarField pdelta(Pf.size(), 0.0);
|
||||
scalarField fm(pdelta.size());
|
||||
|
||||
scalar fratio = cbrt(2.0);
|
||||
scalar deltaf = 1.0/(2*Pf.size()*deltat_);
|
||||
|
||||
scalar fl = f1/sqrt(fratio);
|
||||
scalar fu = fratio*fl;
|
||||
|
||||
label istart = label(fl/deltaf + 1.0 - SMALL);
|
||||
label j = 0;
|
||||
|
||||
for (label i = istart; i<Pf.size(); i++)
|
||||
{
|
||||
scalar fmi = sqrt(fu*fl);
|
||||
|
||||
if (fmi > fU + 1) break;
|
||||
|
||||
if (f[i] >= fu)
|
||||
{
|
||||
fm[j] = fmi;
|
||||
pdelta[j] = sqrt((2.0/3.0)*pdelta[j]);
|
||||
|
||||
j++;
|
||||
|
||||
fl = fu;
|
||||
fu *= fratio;
|
||||
}
|
||||
|
||||
pdelta[j] += sqr(Pf[i]);
|
||||
}
|
||||
|
||||
fm.setSize(j);
|
||||
pdelta.setSize(j);
|
||||
|
||||
return graph
|
||||
(
|
||||
"Pdelta",
|
||||
"fm [Hz]",
|
||||
"Pdelta [dB]",
|
||||
fm,
|
||||
pdelta
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::noiseFFT::Lsum(const graph& gLf) const
|
||||
{
|
||||
const scalarField& Lf = gLf.y();
|
||||
|
||||
scalar lsum = 0.0;
|
||||
|
||||
forAll(Lf, i)
|
||||
{
|
||||
lsum += pow(10, Lf[i]/10.0);
|
||||
}
|
||||
|
||||
lsum = 10*log10(lsum);
|
||||
|
||||
return lsum;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::noiseFFT::dbToPa(const scalar db) const
|
||||
{
|
||||
return p0*pow(10.0, db/20.0);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::dbToPa
|
||||
(
|
||||
const tmp<scalarField>& db
|
||||
) const
|
||||
{
|
||||
return p0*pow(10.0, db/20.0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
474
src/randomProcesses/noise/noiseFFT/noiseFFT.C
Normal file
474
src/randomProcesses/noise/noiseFFT/noiseFFT.C
Normal file
@ -0,0 +1,474 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "noiseFFT.H"
|
||||
#include "IFstream.H"
|
||||
#include "DynamicList.H"
|
||||
#include "SubField.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "HashSet.H"
|
||||
#include "fft.H"
|
||||
|
||||
using namespace Foam::constant;
|
||||
|
||||
// * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::noiseFFT::p0 = 2e-5;
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::frequencies
|
||||
(
|
||||
const label N,
|
||||
const scalar deltaT
|
||||
)
|
||||
{
|
||||
tmp<scalarField> tf(new scalarField(N/2, 0));
|
||||
scalarField& f = tf.ref();
|
||||
|
||||
scalar deltaf = 1.0/(N*deltaT);
|
||||
forAll(f, i)
|
||||
{
|
||||
f[i] = i*deltaf;
|
||||
}
|
||||
|
||||
return tf;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::PSD(const scalarField& PSDf)
|
||||
{
|
||||
return 10*log10(PSDf/sqr(p0));
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::SPL(const scalarField& Prms2)
|
||||
{
|
||||
return 10*log10(Prms2/sqr(p0));
|
||||
}
|
||||
|
||||
|
||||
void Foam::noiseFFT::octaveBandInfo
|
||||
(
|
||||
const scalarField& f,
|
||||
const scalar fLower,
|
||||
const scalar fUpper,
|
||||
const scalar octave,
|
||||
labelList& fBandIDs,
|
||||
scalarField& fCentre
|
||||
)
|
||||
{
|
||||
// Set the indices of to the lower frequency bands for the input frequency
|
||||
// range. Ensure that the centre frequency passes though 1000 Hz
|
||||
|
||||
// Low frequency bound given by:
|
||||
// fLow = f0*(2^(0.5*bandI/octave))
|
||||
|
||||
// Initial (lowest centre frequency)
|
||||
scalar fTest = 15.625;
|
||||
|
||||
const scalar fRatio = pow(2, 1.0/octave);
|
||||
const scalar fRatioL2C = pow(2, 0.5/octave);
|
||||
|
||||
// IDs of band IDs
|
||||
labelHashSet bandIDs(f.size());
|
||||
|
||||
// Centre frequencies
|
||||
DynamicList<scalar> fc;
|
||||
|
||||
// Convert to lower band limit
|
||||
fTest /= fRatioL2C;
|
||||
|
||||
forAll(f, i)
|
||||
{
|
||||
if (f[i] >= fTest)
|
||||
{
|
||||
// Advance band if appropriate
|
||||
while (f[i] > fTest)
|
||||
{
|
||||
fTest *= fRatio;
|
||||
}
|
||||
fTest /= fRatio;
|
||||
|
||||
if (bandIDs.insert(i))
|
||||
{
|
||||
// Also store (next) centre frequency
|
||||
fc.append(fTest*fRatioL2C);
|
||||
}
|
||||
fTest *= fRatio;
|
||||
|
||||
if (fTest > fUpper)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fBandIDs = bandIDs.toc();
|
||||
|
||||
// Remove the last centre frequency (beyond upper frequency limit)
|
||||
fc.remove();
|
||||
|
||||
fCentre.transfer(fc);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::noiseFFT::noiseFFT
|
||||
(
|
||||
const scalar deltaT,
|
||||
const scalarField& pressure
|
||||
)
|
||||
:
|
||||
scalarField(pressure),
|
||||
deltaT_(deltaT)
|
||||
{
|
||||
scalarField& p = *this;
|
||||
p -= average(p);
|
||||
}
|
||||
|
||||
|
||||
Foam::noiseFFT::noiseFFT(const fileName& pFileName, const label skip)
|
||||
:
|
||||
scalarField(),
|
||||
deltaT_(0.0)
|
||||
{
|
||||
// Construct pressure data file
|
||||
IFstream pFile(pFileName);
|
||||
|
||||
// Check pFile stream is OK
|
||||
if (!pFile.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << pFileName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (skip)
|
||||
{
|
||||
scalar dummyt, dummyp;
|
||||
|
||||
for (label i = 0; i < skip; i++)
|
||||
{
|
||||
pFile >> dummyt;
|
||||
|
||||
if (!pFile.good() || pFile.eof())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of points in file " << pFileName
|
||||
<< " is less than the number to be skipped = " << skip
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
pFile >> dummyp;
|
||||
}
|
||||
}
|
||||
|
||||
scalar t = 0, T0 = 0, T1 = 0;
|
||||
DynamicList<scalar> pData(100000);
|
||||
label i = 0;
|
||||
|
||||
while (!(pFile >> t).eof())
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
T0 = t;
|
||||
}
|
||||
|
||||
T1 = t;
|
||||
pFile >> pData(i++);
|
||||
}
|
||||
|
||||
// Note: assumes fixed time step
|
||||
deltaT_ = (T1 - T0)/pData.size();
|
||||
|
||||
this->transfer(pData);
|
||||
|
||||
scalarField& p = *this;
|
||||
p -= average(p);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::graph Foam::noiseFFT::pt() const
|
||||
{
|
||||
scalarField t(size());
|
||||
forAll(t, i)
|
||||
{
|
||||
t[i] = i*deltaT_;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"p(t)",
|
||||
"t [s]",
|
||||
"p(t) [Pa]",
|
||||
t,
|
||||
*this
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::Pf
|
||||
(
|
||||
const tmp<scalarField>& tpn
|
||||
) const
|
||||
{
|
||||
// Calculate the 2-sided fft
|
||||
// Note: result not scaled
|
||||
tmp<scalarField> tPn2
|
||||
(
|
||||
mag
|
||||
(
|
||||
fft::reverseTransform
|
||||
(
|
||||
ReComplexField(tpn),
|
||||
List<int>(1, tpn().size())
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
tpn.clear();
|
||||
|
||||
// Only storing the positive half
|
||||
// Note: storing (N/2) values, DC component at position (0)
|
||||
tmp<scalarField> tPn
|
||||
(
|
||||
new scalarField
|
||||
(
|
||||
scalarField::subField(tPn2(), tPn2().size()/2 + 1)
|
||||
)
|
||||
);
|
||||
|
||||
return tPn;
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::meanPf(const windowModel& window) const
|
||||
{
|
||||
const label N = window.nSamples();
|
||||
const label nWindow = window.nWindow();
|
||||
|
||||
scalarField meanPf(N/2 + 1, 0.0);
|
||||
|
||||
for (label windowI = 0; windowI < nWindow; ++windowI)
|
||||
{
|
||||
meanPf += Pf(window.apply<scalar>(*this, windowI));
|
||||
}
|
||||
|
||||
meanPf /= scalar(nWindow);
|
||||
|
||||
scalar deltaf = 1.0/(N*deltaT_);
|
||||
scalarField f(meanPf.size());
|
||||
forAll(f, i)
|
||||
{
|
||||
f[i] = i*deltaf;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"P(f)",
|
||||
"f [Hz]",
|
||||
"P(f) [Pa]",
|
||||
f,
|
||||
meanPf
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::RMSmeanPf(const windowModel& window) const
|
||||
{
|
||||
const label N = window.nSamples();
|
||||
const label nWindow = window.nWindow();
|
||||
|
||||
scalarField RMSMeanPf(N/2 + 1, 0.0);
|
||||
for (label windowI = 0; windowI < nWindow; ++windowI)
|
||||
{
|
||||
RMSMeanPf += sqr(Pf(window.apply<scalar>(*this, windowI)));
|
||||
}
|
||||
|
||||
RMSMeanPf = sqrt(RMSMeanPf/scalar(nWindow))/scalar(N);
|
||||
|
||||
scalar deltaf = 1.0/(N*deltaT_);
|
||||
scalarField f(RMSMeanPf.size());
|
||||
forAll(f, i)
|
||||
{
|
||||
f[i] = i*deltaf;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"Prms(f)",
|
||||
"f [Hz]",
|
||||
"Prms(f) [Pa]",
|
||||
f,
|
||||
RMSMeanPf
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::PSDf(const windowModel& window) const
|
||||
{
|
||||
const label N = window.nSamples();
|
||||
const label nWindow = window.nWindow();
|
||||
|
||||
scalarField psd(N/2 + 1, 0.0);
|
||||
|
||||
for (label windowI = 0; windowI < nWindow; ++windowI)
|
||||
{
|
||||
psd += sqr(Pf(window.apply<scalar>(*this, windowI)));
|
||||
}
|
||||
|
||||
scalar deltaf = 1.0/(N*deltaT_);
|
||||
scalar fs = 1.0/deltaT_;
|
||||
psd /= scalar(nWindow)*fs*N;
|
||||
|
||||
// Scaling due to use of 1-sided FFT
|
||||
// Note: do not scale DC component
|
||||
psd *= 2;
|
||||
psd.first() /= 2;
|
||||
psd.last() /= 2;
|
||||
|
||||
scalarField f(psd.size());
|
||||
|
||||
if (0) // if (debug)
|
||||
{
|
||||
Pout<< "Average PSD: " << average(psd) << endl;
|
||||
}
|
||||
|
||||
forAll(f, i)
|
||||
{
|
||||
f[i] = i*deltaf;
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"PSD(f)",
|
||||
"f [Hz]",
|
||||
"PSD(f) [PaPa_Hz]",
|
||||
f,
|
||||
psd
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::PSD(const graph& gPSDf) const
|
||||
{
|
||||
return graph
|
||||
(
|
||||
"PSD(f)",
|
||||
"f [Hz]",
|
||||
"PSD_dB(f) [dB_Hz]",
|
||||
gPSDf.x(),
|
||||
10*log10(gPSDf.y()/sqr(p0))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::graph Foam::noiseFFT::octaves
|
||||
(
|
||||
const graph& g,
|
||||
const labelList& freqBandIDs,
|
||||
bool integrate
|
||||
) const
|
||||
{
|
||||
if (freqBandIDs.size() < 2)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Octave frequency bands are not defined "
|
||||
<< "- skipping octaves calculation"
|
||||
<< endl;
|
||||
|
||||
return graph
|
||||
(
|
||||
"octave",
|
||||
"x",
|
||||
"y",
|
||||
scalarField(),
|
||||
scalarField()
|
||||
);
|
||||
}
|
||||
|
||||
const scalarField& f = g.x();
|
||||
const scalarField& data = g.y();
|
||||
|
||||
scalarField octData(freqBandIDs.size() - 1, 0.0);
|
||||
scalarField fm(freqBandIDs.size() -1, 0.0);
|
||||
|
||||
for (label bandI = 0; bandI < freqBandIDs.size() - 1; bandI++)
|
||||
{
|
||||
label fb0 = freqBandIDs[bandI];
|
||||
label fb1 = freqBandIDs[bandI+1];
|
||||
fm[bandI] = f[fb0];
|
||||
|
||||
if (fb0 == fb1) continue;
|
||||
|
||||
if (integrate)
|
||||
{
|
||||
for (label freqI = fb0; freqI < fb1; freqI++)
|
||||
{
|
||||
label f0 = f[freqI];
|
||||
label f1 = f[freqI + 1];
|
||||
scalar dataAve = 0.5*(data[freqI] + data[freqI + 1]);
|
||||
octData[bandI] += dataAve*(f1 - f0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (label freqI = fb0; freqI < fb1; freqI++)
|
||||
{
|
||||
octData[bandI] += data[freqI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return graph
|
||||
(
|
||||
"octaves(f)",
|
||||
"fm [Hz]",
|
||||
"octave data",
|
||||
fm,
|
||||
octData
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::noiseFFT::dbToPa(const scalar db) const
|
||||
{
|
||||
return p0*pow(10.0, db/20.0);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::noiseFFT::dbToPa
|
||||
(
|
||||
const tmp<scalarField>& db
|
||||
) const
|
||||
{
|
||||
return p0*pow(10.0, db/20.0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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.
|
||||
@ -25,11 +25,26 @@ Class
|
||||
Foam::noiseFFT
|
||||
|
||||
Description
|
||||
FFT of the pressure field
|
||||
Performs FFT of pressure field to generate noise data.
|
||||
|
||||
General functionality:
|
||||
- Pf: fft of the pressure data
|
||||
- meanPf: multi-window mean fft
|
||||
- RMSmeanPf: multi-window RMS mean fft
|
||||
- PSDf: multi-window power spectral density (PSD) in frequency domain
|
||||
- PSD: power spectral density in dB/Hz
|
||||
- SPL: sound pressure level in dB
|
||||
|
||||
Octave-based data:
|
||||
- PSD spectrum
|
||||
- SPL spectrum
|
||||
|
||||
SourceFiles
|
||||
noiseFFT.C
|
||||
|
||||
SeeAlso
|
||||
windowModel.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef noiseFFT_H
|
||||
@ -37,6 +52,7 @@ SourceFiles
|
||||
|
||||
#include "scalarField.H"
|
||||
#include "graph.H"
|
||||
#include "windowModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -44,7 +60,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class noiseFFT Declaration
|
||||
Class noiseFFT Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class noiseFFT
|
||||
@ -54,7 +70,18 @@ class noiseFFT
|
||||
// Private data
|
||||
|
||||
//- Time spacing of the raw data
|
||||
scalar deltat_;
|
||||
scalar deltaT_;
|
||||
|
||||
struct octaveBandInfo
|
||||
{
|
||||
label octave;
|
||||
|
||||
// IDs of bin boundaries in pressure data
|
||||
labelList binIDs;
|
||||
|
||||
// Centre frequencies for each bin
|
||||
scalarField centreFreq;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
@ -81,37 +108,61 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the graph of p(t)
|
||||
//- Return the FFT frequencies
|
||||
static tmp<scalarField> frequencies
|
||||
(
|
||||
const label N,
|
||||
const scalar deltaT
|
||||
);
|
||||
|
||||
//- Return the PSD [dB/Hz]
|
||||
// Input PSD in [Pa^2/Hz]
|
||||
static tmp<scalarField> PSD(const scalarField& PSDf);
|
||||
|
||||
//- Return the SPL [dB]
|
||||
// Input P(rms)^2 in [Pa^2]
|
||||
static tmp<scalarField> SPL(const scalarField& Prms2);
|
||||
|
||||
//- Return a list of the frequency indices wrt f field that
|
||||
// correspond to the bands limits for a given octave
|
||||
static void octaveBandInfo
|
||||
(
|
||||
const scalarField& f,
|
||||
const scalar fLower,
|
||||
const scalar fUpper,
|
||||
const scalar octave,
|
||||
labelList& fBandIDs,
|
||||
scalarField& fCentre
|
||||
);
|
||||
|
||||
//- Return the graph of pressure as a function of time
|
||||
graph pt() const;
|
||||
|
||||
//- Return the nth window
|
||||
tmp<scalarField> window(const label N, const label n) const;
|
||||
|
||||
//- Return the Hanning window function
|
||||
tmp<scalarField> Hanning(const label N) const;
|
||||
|
||||
//- Return the fft of the given pressure data
|
||||
tmp<scalarField> Pf(const tmp<scalarField>& pn) const;
|
||||
|
||||
//- Return the multi-window mean fft of the complete pressure data
|
||||
graph meanPf(const label N, const label nw) const;
|
||||
//- Return the multi-window mean fft of the complete pressure data [Pa]
|
||||
graph meanPf(const windowModel& window) const;
|
||||
|
||||
//- Return the multi-window RMS mean fft of the complete pressure data
|
||||
graph RMSmeanPf(const label N, const label nw) const;
|
||||
//- Return the multi-window RMS mean fft of the complete pressure
|
||||
// data [Pa]
|
||||
graph RMSmeanPf(const windowModel& window) const;
|
||||
|
||||
//- Return the narrow-band PFL (pressure-fluctuation level) spectrum
|
||||
graph Lf(const graph& gPf) const;
|
||||
//- Return the multi-window PSD (power spectral density) of the complete
|
||||
// pressure data [Pa^2/Hz]
|
||||
graph PSDf(const windowModel& window) const;
|
||||
|
||||
//- Return the one-third-octave-band PFL spectrum
|
||||
// starting at octave with mean frequency f1
|
||||
graph Ldelta(const graph& gLf, const scalar f1, const scalar fU) const;
|
||||
//- Return the PSD [dB/Hz]
|
||||
// Takes PSD in [Pa^2/Hz]
|
||||
graph PSD(const graph& gPSDf) const;
|
||||
|
||||
//- Return the one-third-octave-band pressure spectrum
|
||||
// starting at octave with mean frequency f1
|
||||
graph Pdelta(const graph& gLf, const scalar f1, const scalar fU) const;
|
||||
|
||||
//- Return the total PFL as the sum of Lf over all frequencies
|
||||
scalar Lsum(const graph& gLf) const;
|
||||
//- Generate octave data
|
||||
graph octaves
|
||||
(
|
||||
const graph& g,
|
||||
const labelList& freqBandIDs,
|
||||
bool integrate
|
||||
) const;
|
||||
|
||||
//- Convert the db into Pa
|
||||
scalar dbToPa(const scalar db) const;
|
||||
151
src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C
Normal file
151
src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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),
|
||||
rhoRef_(dict.lookupOrDefault<scalar>("rhoRef", 1)),
|
||||
nSamples_(dict.lookupOrDefault<label>("N", 65536)),
|
||||
fLower_(dict.lookupOrDefault<scalar>("fl", 25)),
|
||||
fUpper_(dict.lookupOrDefault<scalar>("fu", 10000)),
|
||||
startTime_(dict.lookupOrDefault<scalar>("startTime", 0)),
|
||||
windowModelPtr_(windowModel::New(dict, nSamples_)),
|
||||
graphFormat_(dict.lookupOrDefault<word>("graphFormat", "raw"))
|
||||
{
|
||||
// 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()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
179
src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H
Normal file
179
src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H
Normal file
@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::noiseModel
|
||||
|
||||
Description
|
||||
Base class for noise models.
|
||||
|
||||
Data is read from a dictionary, e.g.
|
||||
|
||||
\verbatim
|
||||
rhoRef 0;
|
||||
N 4096;
|
||||
fl 25;
|
||||
fu 25;
|
||||
startTime 0;
|
||||
\endverbatim
|
||||
|
||||
where
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
rhoRef | Reference density | no | 1
|
||||
N | Number of samples in sampling window | no | 65536 (2^16)
|
||||
fl | Lower frequency bounds | no | 25
|
||||
fu | Upper frequency bounds | no | 10000
|
||||
startTime | Start time | no | 0
|
||||
graphFormat | Graph format | no | raw
|
||||
\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 density (to convert from kinematic to static pressure)
|
||||
scalar rhoRef_;
|
||||
|
||||
//- 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<windowModel> windowModelPtr_;
|
||||
|
||||
//- Graph format
|
||||
word graphFormat_;
|
||||
|
||||
|
||||
// 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<noiseModel> 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "noiseModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::noiseModel> 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<noiseModel>(cstrIter()(dict.subDict(modelType + "Coeffs")));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
207
src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C
Normal file
207
src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C
Normal file
@ -0,0 +1,207 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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 Function1Types::CSV<scalar>& pData,
|
||||
scalarField& t,
|
||||
scalarField& p
|
||||
)
|
||||
{
|
||||
const scalarField t0(pData.x());
|
||||
const scalarField p0(pData.y());
|
||||
|
||||
DynamicList<scalar> tf(t0.size());
|
||||
DynamicList<scalar> 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;
|
||||
|
||||
Function1Types::CSV<scalar> pData("pressure", dict_, "Data");
|
||||
|
||||
// Time and pressure history data
|
||||
scalarField t, p;
|
||||
filterTimeData(pData, t, p);
|
||||
p *= rhoRef_;
|
||||
|
||||
Info<< " read " << t.size() << " values" << nl << endl;
|
||||
|
||||
Info<< "Creating noise FFT" << endl;
|
||||
const scalar deltaT = checkUniformTimeStep(t);
|
||||
|
||||
// Determine the windowing
|
||||
windowModelPtr_->validate(t.size());
|
||||
const windowModel& win = windowModelPtr_();
|
||||
const scalar deltaf = 1.0/(deltaT*win.nSamples());
|
||||
fileName outDir(fileName("postProcessing")/"noise"/typeName);
|
||||
|
||||
// Create the fft
|
||||
noiseFFT nfft(deltaT, p);
|
||||
|
||||
|
||||
// Narrow band data
|
||||
// ----------------
|
||||
|
||||
// RMS pressure [Pa]
|
||||
graph Prmsf(nfft.RMSmeanPf(win));
|
||||
Info<< " Creating graph for " << Prmsf.title() << endl;
|
||||
Prmsf.write(outDir, graph::wordify(Prmsf.title()), graphFormat_);
|
||||
|
||||
// PSD [Pa^2/Hz]
|
||||
graph PSDf(nfft.PSDf(win));
|
||||
Info<< " Creating graph for " << PSDf.title() << endl;
|
||||
PSDf.write(outDir, graph::wordify(PSDf.title()), graphFormat_);
|
||||
|
||||
// PSD [dB/Hz]
|
||||
graph PSDg
|
||||
(
|
||||
"PSD_dB_Hz(f)",
|
||||
"f [Hz]",
|
||||
"PSD(f) [dB_Hz]",
|
||||
Prmsf.x(),
|
||||
noiseFFT::PSD(PSDf.y())
|
||||
);
|
||||
Info<< " Creating graph for " << PSDg.title() << endl;
|
||||
PSDg.write(outDir, graph::wordify(PSDg.title()), graphFormat_);
|
||||
|
||||
// SPL [dB]
|
||||
graph SPLg
|
||||
(
|
||||
"SPL_dB(f)",
|
||||
"f [Hz]",
|
||||
"SPL(f) [dB]",
|
||||
Prmsf.x(),
|
||||
noiseFFT::SPL(PSDf.y()*deltaf)
|
||||
);
|
||||
Info<< " Creating graph for " << SPLg.title() << endl;
|
||||
SPLg.write(outDir, graph::wordify(SPLg.title()), graphFormat_);
|
||||
|
||||
labelList octave13BandIDs;
|
||||
scalarField octave13FreqCentre;
|
||||
noiseFFT::octaveBandInfo
|
||||
(
|
||||
Prmsf.x(),
|
||||
fLower_,
|
||||
fUpper_,
|
||||
3,
|
||||
octave13BandIDs,
|
||||
octave13FreqCentre
|
||||
);
|
||||
|
||||
|
||||
// 1/3 octave data
|
||||
// ---------------
|
||||
|
||||
// PSD [Pa^2/Hz]
|
||||
graph PSD13f(nfft.octaves(PSDf, octave13BandIDs, false));
|
||||
|
||||
// Integrated PSD = P(rms)^2 [Pa^2]
|
||||
graph Prms13f2(nfft.octaves(PSDf, octave13BandIDs, true));
|
||||
|
||||
graph PSD13g
|
||||
(
|
||||
"PSD13_dB_Hz(fm)",
|
||||
"fm [Hz]",
|
||||
"PSD(fm) [dB_Hz]",
|
||||
octave13FreqCentre,
|
||||
noiseFFT::PSD(PSD13f.y())
|
||||
);
|
||||
Info<< " Creating graph for " << PSD13g.title() << endl;
|
||||
PSD13g.write(outDir, graph::wordify(PSD13g.title()), graphFormat_);
|
||||
|
||||
graph SPL13g
|
||||
(
|
||||
"SPL13_dB(fm)",
|
||||
"fm [Hz]",
|
||||
"SPL(fm) [dB]",
|
||||
octave13FreqCentre,
|
||||
noiseFFT::SPL(Prms13f2.y())
|
||||
);
|
||||
Info<< " Creating graph for " << SPL13g.title() << endl;
|
||||
SPL13g.write(outDir, graph::wordify(SPL13g.title()), graphFormat_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pointNoise::pointNoise(const dictionary& dict)
|
||||
:
|
||||
noiseModel(dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
pointNoise::~pointNoise()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace noiseModels
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
142
src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H
Normal file
142
src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H
Normal file
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 <modelType>
|
||||
<modelType>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 Member Functions
|
||||
|
||||
void filterTimeData
|
||||
(
|
||||
const Function1Types::CSV<scalar>& 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,705 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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)
|
||||
{
|
||||
label nAvailableTimes = 0;
|
||||
|
||||
// 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<word>("pName", "p"));
|
||||
const List<word> 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
|
||||
nAvailableTimes = allTimes.size() - startTimeIndex_;
|
||||
}
|
||||
|
||||
Pstream::scatter(pIndex_);
|
||||
Pstream::scatter(startTimeIndex_);
|
||||
Pstream::scatter(nAvailableTimes);
|
||||
|
||||
|
||||
// Note: all processors should call the windowing validate function
|
||||
label nRequiredTimes = windowModelPtr_->validate(nAvailableTimes);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Restrict times
|
||||
const instantList allTimes = readerPtr_->times();
|
||||
|
||||
times_.setSize(nRequiredTimes);
|
||||
forAll(times_, timeI)
|
||||
{
|
||||
times_[timeI] = allTimes[timeI + startTimeIndex_].value();
|
||||
}
|
||||
deltaT_ = checkUniformTimeStep(times_);
|
||||
|
||||
// Read the surface geometry
|
||||
const meshedSurface& surf = readerPtr_->geometry();
|
||||
nFace_ = surf.size();
|
||||
}
|
||||
|
||||
Pstream::scatter(times_);
|
||||
Pstream::scatter(deltaT_);
|
||||
Pstream::scatter(nFace_);
|
||||
}
|
||||
|
||||
|
||||
void surfaceNoise::readSurfaceData
|
||||
(
|
||||
const labelList& procFaceOffset,
|
||||
List<scalarField>& 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)));
|
||||
|
||||
// Apply conversions
|
||||
p *= rhoRef_;
|
||||
|
||||
// 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<scalar>(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]*rhoRef_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "Read "
|
||||
<< returnReduce(pData.size(), sumOp<label>())
|
||||
<< " pressure traces with "
|
||||
<< times_.size()
|
||||
<< " time values" << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar surfaceNoise::writeSurfaceData
|
||||
(
|
||||
const word& fName,
|
||||
const word& groupName,
|
||||
const word& title,
|
||||
const scalar freq,
|
||||
const scalarField& data,
|
||||
const labelList& procFaceOffset
|
||||
) const
|
||||
{
|
||||
Info<< " processing " << title << " for frequency " << freq << endl;
|
||||
|
||||
fileName outDir
|
||||
(
|
||||
fileName("postProcessing")/"noise"/groupName/Foam::name(freq)
|
||||
);
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Collect the surface data so that we can output the surfaces
|
||||
|
||||
PstreamBuffers pBufs(Pstream::nonBlocking);
|
||||
|
||||
if (!Pstream::master())
|
||||
{
|
||||
UOPstream toProc(0, pBufs);
|
||||
toProc << data;
|
||||
}
|
||||
|
||||
pBufs.finishedSends();
|
||||
|
||||
scalar areaAverage = 0;
|
||||
if (Pstream::master())
|
||||
{
|
||||
const meshedSurface& surf = readerPtr_->geometry();
|
||||
|
||||
scalarField allData(surf.size());
|
||||
|
||||
forAll(data, faceI)
|
||||
{
|
||||
// Master procFaceOffset is zero...
|
||||
allData[faceI] = data[faceI];
|
||||
}
|
||||
|
||||
for (label procI = 1; procI < Pstream::nProcs(); procI++)
|
||||
{
|
||||
UIPstream fromProc(procI, pBufs);
|
||||
scalarList dataSlice(fromProc);
|
||||
forAll(dataSlice, i)
|
||||
{
|
||||
label faceI = procFaceOffset[procI] + i;
|
||||
allData[faceI] = dataSlice[i];
|
||||
}
|
||||
}
|
||||
|
||||
fileName outFileName = writerPtr_->write
|
||||
(
|
||||
outDir,
|
||||
fName,
|
||||
surf.points(),
|
||||
surf.faces(),
|
||||
title,
|
||||
allData,
|
||||
false
|
||||
);
|
||||
|
||||
// TODO: Move faceAreas to demand-driven function in MeshedSurface
|
||||
// scalarField faceAreas(surf.faces().size());
|
||||
// forAll(faceAreas, i)
|
||||
// {
|
||||
// faceAreas[i] = surf.faces()[i].mag(surf.points());
|
||||
// }
|
||||
//
|
||||
// areaAverage = sum(allData*faceAreas)/sum(faceAreas);
|
||||
areaAverage = sum(allData)/allData.size();
|
||||
}
|
||||
Pstream::scatter(areaAverage);
|
||||
|
||||
return areaAverage;
|
||||
}
|
||||
else
|
||||
{
|
||||
const meshedSurface& surf = readerPtr_->geometry();
|
||||
|
||||
writerPtr_->write
|
||||
(
|
||||
outDir,
|
||||
fName,
|
||||
surf.points(),
|
||||
surf.faces(),
|
||||
title,
|
||||
data,
|
||||
false
|
||||
);
|
||||
|
||||
// TODO: Move faceAreas to demand-driven function in MeshedSurface
|
||||
// scalarField faceAreas(surf.faces().size());
|
||||
// forAll(faceAreas, i)
|
||||
// {
|
||||
// faceAreas[i] = surf.faces()[i].mag(surf.points());
|
||||
// }
|
||||
//
|
||||
// return sum(data*faceAreas)/sum(faceAreas);
|
||||
return sum(data)/data.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar surfaceNoise::surfaceAverage
|
||||
(
|
||||
const scalarField& data,
|
||||
const labelList& procFaceOffset
|
||||
) const
|
||||
{
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Collect the surface data so that we can output the surfaces
|
||||
|
||||
PstreamBuffers pBufs(Pstream::nonBlocking);
|
||||
|
||||
if (!Pstream::master())
|
||||
{
|
||||
UOPstream toProc(0, pBufs);
|
||||
toProc << data;
|
||||
}
|
||||
|
||||
pBufs.finishedSends();
|
||||
|
||||
scalar areaAverage = 0;
|
||||
if (Pstream::master())
|
||||
{
|
||||
const meshedSurface& surf = readerPtr_->geometry();
|
||||
|
||||
scalarField allData(surf.size());
|
||||
|
||||
forAll(data, faceI)
|
||||
{
|
||||
// Master procFaceOffset is zero...
|
||||
allData[faceI] = data[faceI];
|
||||
}
|
||||
|
||||
for (label procI = 1; procI < Pstream::nProcs(); procI++)
|
||||
{
|
||||
UIPstream fromProc(procI, pBufs);
|
||||
scalarList dataSlice(fromProc);
|
||||
forAll(dataSlice, i)
|
||||
{
|
||||
label faceI = procFaceOffset[procI] + i;
|
||||
allData[faceI] = dataSlice[i];
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move faceAreas to demand-driven function in MeshedSurface
|
||||
scalarField faceAreas(surf.faces().size());
|
||||
forAll(faceAreas, i)
|
||||
{
|
||||
faceAreas[i] = surf.faces()[i].mag(surf.points());
|
||||
}
|
||||
|
||||
// areaAverage = sum(allData*faceAreas)/sum(faceAreas);
|
||||
areaAverage = sum(allData)/allData.size();
|
||||
}
|
||||
Pstream::scatter(areaAverage);
|
||||
|
||||
return areaAverage;
|
||||
}
|
||||
else
|
||||
{
|
||||
const meshedSurface& surf = readerPtr_->geometry();
|
||||
|
||||
// TODO: Move faceAreas to demand-driven function in MeshedSurface
|
||||
scalarField faceAreas(surf.faces().size());
|
||||
forAll(faceAreas, i)
|
||||
{
|
||||
faceAreas[i] = surf.faces()[i].mag(surf.points());
|
||||
}
|
||||
|
||||
// return sum(data*faceAreas)/sum(faceAreas);
|
||||
return sum(data)/data.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
surfaceNoise::surfaceNoise(const dictionary& dict)
|
||||
:
|
||||
noiseModel(dict),
|
||||
inputFileName_(dict.lookup("inputFile")),
|
||||
pIndex_(0),
|
||||
times_(),
|
||||
deltaT_(0),
|
||||
startTimeIndex_(0),
|
||||
nFace_(0),
|
||||
fftWriteInterval_(dict.lookupOrDefault("fftWriteInterval", 1))
|
||||
{
|
||||
initialise(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
surfaceNoise::~surfaceNoise()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void surfaceNoise::calculate()
|
||||
{
|
||||
// Container for pressure time history data per face
|
||||
List<scalarField> pData;
|
||||
|
||||
// Processor procFaceOffsets
|
||||
labelList procFaceOffset;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
const label nProcs = Pstream::nProcs();
|
||||
const label nFacePerProc = floor(nFace_/nProcs) + 1;
|
||||
|
||||
procFaceOffset.setSize(nProcs + 1, 0);
|
||||
for (label i = 1; i < procFaceOffset.size(); i++)
|
||||
{
|
||||
procFaceOffset[i] = min(i*nFacePerProc, nFace_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
procFaceOffset.setSize(1, nFace_);
|
||||
}
|
||||
|
||||
// Read pressure data from file
|
||||
readSurfaceData(procFaceOffset, pData);
|
||||
|
||||
// Process the pressure data, and store results as surface values per
|
||||
// frequency so that it can be output using the surface writer
|
||||
|
||||
Info<< "Creating noise FFTs" << endl;
|
||||
|
||||
// Storage for FFT data
|
||||
const label nLocalFace = pData.size();
|
||||
const scalarField freq1(noiseFFT::frequencies(nSamples_, deltaT_));
|
||||
const label nFFT = freq1.size()/fftWriteInterval_;
|
||||
List<scalarField> surfPrmsf(nFFT);
|
||||
List<scalarField> surfPSDf(nFFT);
|
||||
forAll(surfPrmsf, freqI)
|
||||
{
|
||||
surfPrmsf[freqI].setSize(nLocalFace);
|
||||
surfPSDf[freqI].setSize(nLocalFace);
|
||||
}
|
||||
|
||||
// Storage for 1/3 octave data
|
||||
labelList octave13BandIDs;
|
||||
scalarField octave13FreqCentre;
|
||||
noiseFFT::octaveBandInfo
|
||||
(
|
||||
freq1,
|
||||
fLower_,
|
||||
fUpper_,
|
||||
3,
|
||||
octave13BandIDs,
|
||||
octave13FreqCentre
|
||||
);
|
||||
|
||||
List<scalarField> surfPSD13f(octave13BandIDs.size() - 1);
|
||||
List<scalarField> surfPrms13f2(octave13BandIDs.size() - 1);
|
||||
forAll(surfPSD13f, freqI)
|
||||
{
|
||||
surfPSD13f[freqI].setSize(nLocalFace);
|
||||
surfPrms13f2[freqI].setSize(nLocalFace);
|
||||
}
|
||||
|
||||
const windowModel& win = windowModelPtr_();
|
||||
|
||||
forAll(pData, faceI)
|
||||
{
|
||||
const scalarField& p = pData[faceI];
|
||||
|
||||
noiseFFT nfft(deltaT_, p);
|
||||
graph Prmsf(nfft.RMSmeanPf(win));
|
||||
graph PSDf(nfft.PSDf(win));
|
||||
|
||||
// Store the frequency results in slot for face of surface
|
||||
forAll(surfPrmsf, i)
|
||||
{
|
||||
label freqI = (i + 1)*fftWriteInterval_ - 1;
|
||||
surfPrmsf[i][faceI] = Prmsf.y()[freqI];
|
||||
surfPSDf[i][faceI] = PSDf.y()[freqI];
|
||||
}
|
||||
|
||||
// PSD [Pa^2/Hz]
|
||||
graph PSD13f(nfft.octaves(PSDf, octave13BandIDs, false));
|
||||
|
||||
// Integrated PSD = P(rms)^2 [Pa^2]
|
||||
graph Prms13f2(nfft.octaves(PSDf, octave13BandIDs, true));
|
||||
|
||||
// Store the 1/3 octave results in slot for face of surface
|
||||
forAll(surfPSD13f, freqI)
|
||||
{
|
||||
surfPSD13f[freqI][faceI] = PSD13f.y()[freqI];
|
||||
surfPrms13f2[freqI][faceI] = Prms13f2.y()[freqI];
|
||||
}
|
||||
|
||||
// Free the storage for p
|
||||
// p.clear();
|
||||
}
|
||||
|
||||
// Output directory for graphs
|
||||
fileName outDir(fileName("postProcessing")/"noise"/typeName);
|
||||
|
||||
const scalar deltaf = 1.0/(deltaT_*win.nSamples());
|
||||
Info<< "Writing fft surface data" << endl;
|
||||
{
|
||||
scalarField PrmsfAve(surfPrmsf.size(), 0);
|
||||
scalarField PSDfAve(surfPrmsf.size(), 0);
|
||||
scalarField fOut(surfPrmsf.size(), 0);
|
||||
|
||||
forAll(surfPrmsf, i)
|
||||
{
|
||||
label freqI = i*fftWriteInterval_;
|
||||
fOut[i] = freq1[freqI];
|
||||
const word& fName = inputFileName_.name(true);
|
||||
const word gName = "fft";
|
||||
PrmsfAve[i] = writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"Prmsf",
|
||||
freq1[freqI],
|
||||
surfPrmsf[i],
|
||||
procFaceOffset
|
||||
);
|
||||
|
||||
PSDfAve[i] = writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"PSDf",
|
||||
freq1[freqI],
|
||||
surfPSDf[i],
|
||||
procFaceOffset
|
||||
);
|
||||
writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"PSD",
|
||||
freq1[freqI],
|
||||
noiseFFT::PSD(surfPSDf[i]),
|
||||
procFaceOffset
|
||||
);
|
||||
writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"SPL",
|
||||
freq1[freqI],
|
||||
noiseFFT::SPL(surfPSDf[i]*deltaf),
|
||||
procFaceOffset
|
||||
);
|
||||
}
|
||||
|
||||
graph Prmsfg
|
||||
(
|
||||
"Average Prms(f)",
|
||||
"f [Hz]",
|
||||
"P(f) [Pa]",
|
||||
fOut,
|
||||
PrmsfAve
|
||||
);
|
||||
Prmsfg.write(outDir, graph::wordify(Prmsfg.title()), graphFormat_);
|
||||
|
||||
graph PSDfg
|
||||
(
|
||||
"Average PSD_f(f)",
|
||||
"f [Hz]",
|
||||
"PSD(f) [PaPa_Hz]",
|
||||
fOut,
|
||||
PSDfAve
|
||||
);
|
||||
PSDfg.write(outDir, graph::wordify(PSDfg.title()), graphFormat_);
|
||||
|
||||
graph PSDg
|
||||
(
|
||||
"Average PSD_dB_Hz(f)",
|
||||
"f [Hz]",
|
||||
"PSD(f) [dB_Hz]",
|
||||
fOut,
|
||||
noiseFFT::PSD(PSDfAve)
|
||||
);
|
||||
PSDg.write(outDir, graph::wordify(PSDg.title()), graphFormat_);
|
||||
|
||||
graph SPLg
|
||||
(
|
||||
"Average SPL_dB(f)",
|
||||
"f [Hz]",
|
||||
"SPL(f) [dB]",
|
||||
fOut,
|
||||
noiseFFT::SPL(PSDfAve*deltaf)
|
||||
);
|
||||
SPLg.write(outDir, graph::wordify(SPLg.title()), graphFormat_);
|
||||
}
|
||||
|
||||
|
||||
Info<< "Writing one-third octave surface data" << endl;
|
||||
{
|
||||
scalarField PSDfAve(surfPSD13f.size(), 0);
|
||||
scalarField Prms13f2Ave(surfPSD13f.size(), 0);
|
||||
|
||||
forAll(surfPSD13f, i)
|
||||
{
|
||||
const word& fName = inputFileName_.name(true);
|
||||
const word gName = "oneThirdOctave";
|
||||
PSDfAve[i] = writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"PSD13f",
|
||||
octave13FreqCentre[i],
|
||||
surfPSD13f[i],
|
||||
procFaceOffset
|
||||
);
|
||||
writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"PSD13",
|
||||
octave13FreqCentre[i],
|
||||
noiseFFT::PSD(surfPSD13f[i]),
|
||||
procFaceOffset
|
||||
);
|
||||
writeSurfaceData
|
||||
(
|
||||
fName,
|
||||
gName,
|
||||
"SPL13",
|
||||
octave13FreqCentre[i],
|
||||
noiseFFT::SPL(surfPrms13f2[i]),
|
||||
procFaceOffset
|
||||
);
|
||||
|
||||
Prms13f2Ave[i] = surfaceAverage(surfPrms13f2[i], procFaceOffset);
|
||||
}
|
||||
|
||||
graph PSD13g
|
||||
(
|
||||
"Average PSD13_dB_Hz(fm)",
|
||||
"fm [Hz]",
|
||||
"PSD(fm) [dB_Hz]",
|
||||
octave13FreqCentre,
|
||||
noiseFFT::PSD(PSDfAve)
|
||||
);
|
||||
PSD13g.write(outDir, graph::wordify(PSD13g.title()), graphFormat_);
|
||||
|
||||
graph SPL13g
|
||||
(
|
||||
"Average SPL13_dB(fm)",
|
||||
"fm [Hz]",
|
||||
"SPL(fm) [dB]",
|
||||
octave13FreqCentre,
|
||||
noiseFFT::SPL(Prms13f2Ave)
|
||||
);
|
||||
SPL13g.write(outDir, graph::wordify(SPL13g.title()), graphFormat_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace noiseModels
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,208 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::noiseModels::surfaceNoise
|
||||
|
||||
Description
|
||||
Perform noise analysis on surface-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 <modelType>
|
||||
<modelType>Coeffs
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
// Input file
|
||||
inputFile "postProcessing/faceSource1/surface/patch/patch.case";
|
||||
|
||||
// Write interval for FFT data, default = 1
|
||||
fftWriteInterval 100;
|
||||
|
||||
// Surface reader
|
||||
reader ensight;
|
||||
|
||||
// Surface writer
|
||||
writer ensight;
|
||||
|
||||
// Collate times for ensight output - ensures geometry is only written once
|
||||
writeOptions
|
||||
{
|
||||
ensight
|
||||
{
|
||||
collateTimes true;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
surfaceNoise.C
|
||||
|
||||
SeeAlso
|
||||
noiseModel.H
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceNoise_H
|
||||
#define surfaceNoise_H
|
||||
|
||||
#include "noiseModel.H"
|
||||
#include "labelList.H"
|
||||
#include "scalarField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class surfaceReader;
|
||||
class surfaceWriter;
|
||||
|
||||
namespace noiseModels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceNoise Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceNoise
|
||||
:
|
||||
public noiseModel
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Input file name
|
||||
const fileName inputFileName_;
|
||||
|
||||
//- Index of pressure field in reader field list
|
||||
label pIndex_;
|
||||
|
||||
//- Sample times
|
||||
scalarList times_;
|
||||
|
||||
//- Time step (constant)
|
||||
scalar deltaT_;
|
||||
|
||||
//- Start time index
|
||||
label startTimeIndex_;
|
||||
|
||||
//- Number of surface faces
|
||||
label nFace_;
|
||||
|
||||
//- Frequency data output interval, default = 1
|
||||
// nSamples/2 data points are returned from the FFT, which can
|
||||
// result in a very large number of output files (1 per frequency)
|
||||
label fftWriteInterval_;
|
||||
|
||||
//- Pointer to the surface reader
|
||||
mutable autoPtr<surfaceReader> readerPtr_;
|
||||
|
||||
//- Pointer to the surface writer
|
||||
autoPtr<surfaceWriter> writerPtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Initialise
|
||||
void initialise(const dictionary& dict);
|
||||
|
||||
//- Read surface data
|
||||
void readSurfaceData
|
||||
(
|
||||
const labelList& procFaceOffset,
|
||||
List<scalarField>& pData
|
||||
);
|
||||
|
||||
//- Write surface data to file
|
||||
// Returns the area average value
|
||||
scalar writeSurfaceData
|
||||
(
|
||||
const word& fName,
|
||||
const word& groupName,
|
||||
const word& title,
|
||||
const scalar freq,
|
||||
const scalarField& data,
|
||||
const labelList& procFaceOffset
|
||||
) const;
|
||||
|
||||
//- Calculate the area average value
|
||||
scalar surfaceAverage
|
||||
(
|
||||
const scalarField& data,
|
||||
const labelList& procFaceOffset
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaceNoise");
|
||||
|
||||
//- Constructor
|
||||
surfaceNoise(const dictionary& dict);
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfaceNoise();
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Calculate
|
||||
virtual void calculate();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace noiseModels
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
122
src/randomProcesses/windowModels/Hanning/Hanning.C
Normal file
122
src/randomProcesses/windowModels/Hanning/Hanning.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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)) // Hamming = 0.54
|
||||
{
|
||||
// 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 = alpha_ - (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
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
125
src/randomProcesses/windowModels/Hanning/Hanning.H
Normal file
125
src/randomProcesses/windowModels/Hanning/Hanning.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::windowModels::Hanning
|
||||
|
||||
Description
|
||||
Hanning window
|
||||
|
||||
The window is described by the function
|
||||
\f[
|
||||
wf = (1 - \alpha) - \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
|
||||
|
||||
// ************************************************************************* //
|
||||
66
src/randomProcesses/windowModels/uniform/uniform.C
Normal file
66
src/randomProcesses/windowModels/uniform/uniform.C
Normal file
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "uniform.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace windowModels
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(uniform, 0);
|
||||
addToRunTimeSelectionTable(windowModel, uniform, dictionary);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
uniform::uniform(const dictionary& dict, const label nSamples)
|
||||
:
|
||||
windowModel(dict, nSamples),
|
||||
value_(readScalar(dict.lookup("value")))
|
||||
{
|
||||
scalarField& wf = *this;
|
||||
wf = value_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
uniform::~uniform()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace windowModels
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,57 +21,65 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Global
|
||||
fftRenumber
|
||||
Class
|
||||
Foam::windowModels::uniform
|
||||
|
||||
Description
|
||||
Multi-dimensional renumbering used in the Numerical Recipes
|
||||
fft routine.
|
||||
A window that applies uniform scaling.
|
||||
|
||||
SourceFiles
|
||||
fftRenumber.C
|
||||
uniform.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fftRenumber_H
|
||||
#define fftRenumber_H
|
||||
#ifndef uniform_H
|
||||
#define uniform_H
|
||||
|
||||
#include "complex.H"
|
||||
#include "List.H"
|
||||
#include "labelList.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "windowModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace windowModels
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniform Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Recursively evaluate the indexing necessary to do the folding of the fft
|
||||
// data. We recurse until we have the indexing ncessary for the folding in all
|
||||
// directions.
|
||||
void fftRenumberRecurse
|
||||
(
|
||||
List<complex>& data,
|
||||
List<complex>& renumData,
|
||||
const labelList& nn,
|
||||
label nnprod,
|
||||
label ii,
|
||||
label l1,
|
||||
label l2
|
||||
);
|
||||
class uniform
|
||||
:
|
||||
public windowModel
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Uniform value
|
||||
scalar value_;
|
||||
|
||||
|
||||
// Fold the n-d data array to get the fft components in the right places.
|
||||
void fftRenumber
|
||||
(
|
||||
List<complex>& data,
|
||||
const labelList& nn
|
||||
);
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uniform");
|
||||
|
||||
|
||||
//- Construct from dictionary
|
||||
uniform(const dictionary& dict, const label nSamples);
|
||||
|
||||
//- Destuctor
|
||||
virtual ~uniform();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace windowModels
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
125
src/randomProcesses/windowModels/windowModel/windowModel.C
Normal file
125
src/randomProcesses/windowModels/windowModel/windowModel.C
Normal file
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
143
src/randomProcesses/windowModels/windowModel/windowModel.H
Normal file
143
src/randomProcesses/windowModels/windowModel/windowModel.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<windowModel> 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<class Type>
|
||||
tmp<Field<Type> > apply
|
||||
(
|
||||
const Field<Type>& fld,
|
||||
const label windowI
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "windowModelTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "windowModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::windowModel> 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<windowModel>
|
||||
(
|
||||
cstrIter()(dict.subDict(modelType + "Coeffs"), nSamples)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::windowModel::apply
|
||||
(
|
||||
const Field<Type>& fld,
|
||||
const label windowI
|
||||
) const
|
||||
{
|
||||
label nSamples = this->nSamples();
|
||||
|
||||
if (nSamples > fld.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "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<Field<Type> > tresult(new Field<Type>(nSamples, pTraits<Type>::zero));
|
||||
Field<Type>& result = tresult.ref();
|
||||
|
||||
label nWindow = nWindowsTotal(fld.size());
|
||||
if (windowI >= nWindow)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "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<Type>(fld, nSamples, windowOffset);
|
||||
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
@ -0,0 +1,515 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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::readGeometryHeader(ensightReadFile& is) const
|
||||
{
|
||||
// Binary flag string if applicable
|
||||
is.readBinaryHeader();
|
||||
|
||||
string buffer;
|
||||
|
||||
// Ensight Geometry File
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << endl;
|
||||
|
||||
// Description - 1
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << endl;
|
||||
|
||||
// Node info
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << endl;
|
||||
|
||||
// Element info
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << endl;
|
||||
|
||||
// Part
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << endl;
|
||||
|
||||
// Part number
|
||||
label ibuffer;
|
||||
is.read(ibuffer);
|
||||
if (debug) Info<< "ibuffer: " << ibuffer << endl;
|
||||
|
||||
// Description - 2
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << endl;
|
||||
|
||||
// Co-ordinates
|
||||
is.read(buffer);
|
||||
if (debug) Info<< "buffer: " << buffer << 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);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Read section header: " << expected << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightSurfaceReader::readCase(IFstream& is)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction<< endl;
|
||||
}
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << is.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
string buffer;
|
||||
|
||||
// Read the file
|
||||
debugSection("FORMAT", is);
|
||||
skip(3, is); // type: ensight gold
|
||||
|
||||
debugSection("GEOMETRY", is);
|
||||
readSkip(is, 2, meshFileName_);
|
||||
|
||||
debugSection("VARIABLE", is);
|
||||
|
||||
DynamicList<word> fieldNames(10);
|
||||
DynamicList<word> 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);
|
||||
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),
|
||||
streamFormat_(IOstream::ASCII),
|
||||
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 isBinary(baseDir_/meshFileName_, IOstream::BINARY);
|
||||
|
||||
if (!isBinary.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << isBinary.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
streamFormat_ = IOstream::BINARY;
|
||||
{
|
||||
istream& is = isBinary.stdStream();
|
||||
|
||||
char buffer[80];
|
||||
is.read(buffer, 80);
|
||||
|
||||
char test[80];
|
||||
label nChar = 0;
|
||||
for (label i = 0; i < 80; ++i)
|
||||
{
|
||||
if (buffer[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
test[i] = buffer[i];
|
||||
nChar++;
|
||||
}
|
||||
|
||||
string testStr(test, nChar);
|
||||
|
||||
if
|
||||
(
|
||||
(testStr.find("binary", 0) == string::npos)
|
||||
&& (testStr.find("Binary", 0) == string::npos)
|
||||
)
|
||||
{
|
||||
streamFormat_ = IOstream::ASCII;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "stream format: ";
|
||||
if (streamFormat_ == IOstream::ASCII)
|
||||
{
|
||||
Info<< "ascii" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "binary" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ensightReadFile is(baseDir_/meshFileName_, streamFormat_);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "File: " << is.name() << endl;
|
||||
}
|
||||
|
||||
readGeometryHeader(is);
|
||||
|
||||
label nPoints;
|
||||
is.read(nPoints);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nPoints: " << nPoints << endl;
|
||||
}
|
||||
|
||||
pointField points(nPoints);
|
||||
{
|
||||
scalarField x(nPoints);
|
||||
for (label dir = 0; dir < 3; dir++)
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
is.read(x[pointI]);
|
||||
}
|
||||
|
||||
points.replace(dir, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read faces - may be a mix of tris, quads and polys
|
||||
DynamicList<face> faces(ceil(nPoints/3));
|
||||
DynamicList<Tuple2<string, label> > schema(faces.size());
|
||||
string faceType = "";
|
||||
label nFace = 0;
|
||||
while (is.good()) // (is.peek() != EOF)
|
||||
{
|
||||
is.read(faceType);
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "faceType: " << faceType << endl;
|
||||
}
|
||||
|
||||
if (faceType == "tria3")
|
||||
{
|
||||
is.read(nFace);
|
||||
|
||||
label np = 3;
|
||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||
{
|
||||
face f(np);
|
||||
for (label fpI = 0; fpI < np; fpI++)
|
||||
{
|
||||
is.read(f[fpI]);
|
||||
}
|
||||
|
||||
faces.append(f);
|
||||
}
|
||||
}
|
||||
else if (faceType == "quad4")
|
||||
{
|
||||
is.read(nFace);
|
||||
|
||||
label np = 4;
|
||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||
{
|
||||
face f(np);
|
||||
for (label fpI = 0; fpI < np; fpI++)
|
||||
{
|
||||
is.read(f[fpI]);
|
||||
}
|
||||
|
||||
faces.append(f);
|
||||
}
|
||||
}
|
||||
else if (faceType == "nsided")
|
||||
{
|
||||
is.read(nFace);
|
||||
|
||||
labelList np(nFace);
|
||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||
{
|
||||
is.read(np[faceI]);
|
||||
}
|
||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||
{
|
||||
face f(np[faceI]);
|
||||
for (label fpI = 0; fpI < f.size(); ++fpI)
|
||||
{
|
||||
is.read(f[fpI]);
|
||||
}
|
||||
|
||||
faces.append(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unknown face type: " << faceType
|
||||
<< ". Aborting read and continuing with current "
|
||||
<< "elements only" << endl;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
schema.append(Tuple2<string, label>(faceType, nFace));
|
||||
}
|
||||
|
||||
schema_.transfer(schema);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "read nFaces: " << faces.size() << nl
|
||||
<< "file schema: " << schema_ << endl;
|
||||
}
|
||||
|
||||
// Convert from 1-based Ensight addressing to 0-based OF addressing
|
||||
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::Field<Foam::scalar> > Foam::ensightSurfaceReader::field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const scalar& refValue
|
||||
) const
|
||||
{
|
||||
return readField<scalar>(timeIndex, fieldIndex);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector> > Foam::ensightSurfaceReader::field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const vector& refValue
|
||||
) const
|
||||
{
|
||||
return readField<vector>(timeIndex, fieldIndex);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::sphericalTensor> >
|
||||
Foam::ensightSurfaceReader::field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const sphericalTensor& refValue
|
||||
) const
|
||||
{
|
||||
return readField<sphericalTensor>(timeIndex, fieldIndex);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::symmTensor> > Foam::ensightSurfaceReader::field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const symmTensor& refValue
|
||||
) const
|
||||
{
|
||||
return readField<symmTensor>(timeIndex, fieldIndex);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::tensor> > Foam::ensightSurfaceReader::field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const tensor& refValue
|
||||
) const
|
||||
{
|
||||
return readField<tensor>(timeIndex, fieldIndex);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,201 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ensightensightSurfaceReader
|
||||
|
||||
Description
|
||||
Ensight format surface reader
|
||||
|
||||
SourceFiles
|
||||
ensightSurfaceReader.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightSurfaceReader_H
|
||||
#define ensightSurfaceReader_H
|
||||
|
||||
#include "surfaceReader.H"
|
||||
#include "ensightReadFile.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightSurfaceReader Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightSurfaceReader
|
||||
:
|
||||
public surfaceReader
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Format flag
|
||||
IOstream::streamFormat streamFormat_;
|
||||
|
||||
//- Base directory
|
||||
fileName baseDir_;
|
||||
|
||||
//- Name of mesh file
|
||||
word meshFileName_;
|
||||
|
||||
//- Field names
|
||||
List<word> fieldNames_;
|
||||
|
||||
//- Field file names
|
||||
List<word> fieldFileNames_;
|
||||
|
||||
//- Number of time steps
|
||||
label nTimeSteps_;
|
||||
|
||||
//- Start time index
|
||||
label timeStartIndex_;
|
||||
|
||||
//- Time increment
|
||||
label timeIncrement_;
|
||||
|
||||
//- Times
|
||||
instantList timeValues_;
|
||||
|
||||
//- Pointer to the surface
|
||||
autoPtr<meshedSurface> surfPtr_;
|
||||
|
||||
List<Tuple2<string, label> > schema_;
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
//- Read (and throw away) geometry file header
|
||||
void readGeometryHeader(ensightReadFile& is) const;
|
||||
|
||||
//- Helper function to return Type after skipping n tokens
|
||||
template<class Type>
|
||||
void readSkip(IFstream& is, const label nSkip, Type& value) const;
|
||||
|
||||
//- Helper function to return a field
|
||||
template<class Type>
|
||||
tmp<Field<Type> > 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<scalar> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const scalar& refValue = pTraits<scalar>::zero
|
||||
) const;
|
||||
|
||||
//- Return a scalar field at a given time
|
||||
virtual tmp<Field<vector> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const vector& refValue = pTraits<vector>::zero
|
||||
) const;
|
||||
|
||||
//- Return a sphericalTensor field at a given time
|
||||
virtual tmp<Field<sphericalTensor> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const sphericalTensor& reValue = pTraits<sphericalTensor>::zero
|
||||
) const;
|
||||
|
||||
//- Return a symmTensor field at a given time
|
||||
virtual tmp<Field<symmTensor> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const symmTensor& reValue = pTraits<symmTensor>::zero
|
||||
) const;
|
||||
|
||||
//- Return a tensor field at a given time
|
||||
virtual tmp<Field<tensor> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const tensor& reValue = pTraits<tensor>::zero
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ensightSurfaceReaderTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,161 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightSurfaceReader::readSkip
|
||||
(
|
||||
IFstream& is,
|
||||
const label nSkip,
|
||||
Type& value
|
||||
) const
|
||||
{
|
||||
skip(nSkip, is);
|
||||
|
||||
is >> value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > 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);
|
||||
|
||||
|
||||
ensightReadFile is(baseDir_/fieldFileName, streamFormat_);
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << is.name()
|
||||
<< " for field " << fieldName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Check that data type is as expected
|
||||
string primitiveType;
|
||||
is.read(primitiveType);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "primitiveType: " << primitiveType << endl;
|
||||
}
|
||||
|
||||
if (primitiveType != pTraits<Type>::typeName)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "Expected " << pTraits<Type>::typeName << "values "
|
||||
<< "but found type " << primitiveType
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
scalar value;
|
||||
string strValue;
|
||||
label iValue;
|
||||
|
||||
// Read header info: part index, e.g. part 1
|
||||
is.read(strValue);
|
||||
is.read(iValue);
|
||||
|
||||
// Allocate storage for data as a list per component
|
||||
List<DynamicList<scalar> > values(pTraits<Type>::nComponents);
|
||||
label n = surfPtr_->size();
|
||||
forAll(values, cmptI)
|
||||
{
|
||||
values.setSize(n);
|
||||
}
|
||||
|
||||
// Read data file using schema generated while reading the surface
|
||||
forAll(schema_, i)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
const string& faceType = schema_[i].first();
|
||||
Info<< "Reading face type " << faceType << " data" << endl;
|
||||
}
|
||||
|
||||
const label nFace = schema_[i].second();
|
||||
|
||||
if (nFace != 0)
|
||||
{
|
||||
is.read(strValue);
|
||||
|
||||
for
|
||||
(
|
||||
direction cmptI=0;
|
||||
cmptI < pTraits<Type>::nComponents;
|
||||
++cmptI
|
||||
)
|
||||
{
|
||||
for (label faceI = 0; faceI < nFace; ++faceI)
|
||||
{
|
||||
is.read(value);
|
||||
values[cmptI].append(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tmp<Field<Type> > tField(new Field<Type>(n, pTraits<Type>::zero));
|
||||
Field<Type>& field = tField.ref();
|
||||
|
||||
for
|
||||
(
|
||||
direction cmptI=0;
|
||||
cmptI < pTraits<Type>::nComponents;
|
||||
++cmptI
|
||||
)
|
||||
{
|
||||
field.replace(cmptI, values[cmptI]);
|
||||
values[cmptI].clear();
|
||||
}
|
||||
|
||||
return tField;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
51
src/sampling/sampledSurface/readers/surfaceReader.C
Normal file
51
src/sampling/sampledSurface/readers/surfaceReader.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
161
src/sampling/sampledSurface/readers/surfaceReader.H
Normal file
161
src/sampling/sampledSurface/readers/surfaceReader.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<surfaceReader> 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<scalar> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const scalar& refValue = pTraits<scalar>::zero
|
||||
) const = 0;
|
||||
|
||||
//- Return a vector field at a given time
|
||||
virtual tmp<Field<vector> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const vector& refValue = pTraits<vector>::zero
|
||||
) const = 0;
|
||||
|
||||
//- Return a sphericalTensor field at a given time
|
||||
virtual tmp<Field<sphericalTensor> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const sphericalTensor& reValue = pTraits<sphericalTensor>::zero
|
||||
) const = 0;
|
||||
|
||||
//- Return a symmTensor field at a given time
|
||||
virtual tmp<Field<symmTensor> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const symmTensor& reValue = pTraits<symmTensor>::zero
|
||||
) const = 0;
|
||||
|
||||
//- Return a tensor field at a given time
|
||||
virtual tmp<Field<tensor> > field
|
||||
(
|
||||
const label timeIndex,
|
||||
const label fieldIndex,
|
||||
const tensor& reValue = pTraits<tensor>::zero
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
52
src/sampling/sampledSurface/readers/surfaceReaderNew.C
Normal file
52
src/sampling/sampledSurface/readers/surfaceReaderNew.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceReader.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::surfaceReader> 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<surfaceReader>(cstrIter()(fName));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,14 +42,15 @@ Foam::ensightSurfaceWriter::ensightSurfaceWriter()
|
||||
:
|
||||
surfaceWriter(),
|
||||
writeFormat_(IOstream::ASCII),
|
||||
collateTimes_(false)
|
||||
collateTimes_(true)
|
||||
{}
|
||||
|
||||
|
||||
Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options)
|
||||
:
|
||||
surfaceWriter(),
|
||||
writeFormat_(IOstream::ASCII)
|
||||
writeFormat_(IOstream::ASCII),
|
||||
collateTimes_(true)
|
||||
{
|
||||
// choose ascii or binary format
|
||||
if (options.found("format"))
|
||||
@ -68,6 +69,17 @@ Foam::ensightSurfaceWriter::~ensightSurfaceWriter()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Note that ensight does supports geometry in a separate file,
|
||||
// but setting this true leaves mesh files in the wrong places
|
||||
// (when there are fields).
|
||||
//
|
||||
// Make this false to let the field writers take back control
|
||||
bool Foam::ensightSurfaceWriter::separateGeometry() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
@ -84,14 +96,13 @@ Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
mkDir(outputDir);
|
||||
}
|
||||
|
||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||
const scalar timeValue = 0.0;
|
||||
|
||||
OFstream osCase(outputDir/surfName + ".case");
|
||||
ensightGeoFile osGeom
|
||||
(
|
||||
outputDir,
|
||||
surfName + ".0000.mesh",
|
||||
surfName + ".00000000.mesh",
|
||||
writeFormat_
|
||||
);
|
||||
|
||||
@ -113,7 +124,7 @@ Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl
|
||||
<< timeValue << nl
|
||||
<< " " << timeValue << nl
|
||||
<< nl;
|
||||
|
||||
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,9 +52,10 @@ class ensightSurfaceWriter
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Write option (default is IOstream::ASCII
|
||||
//- Write option (default: IOstream::ASCII)
|
||||
IOstream::streamFormat writeFormat_;
|
||||
|
||||
//- Collate times (default: ASCII)
|
||||
bool collateTimes_;
|
||||
|
||||
|
||||
@ -126,10 +127,7 @@ public:
|
||||
|
||||
//- True if the surface format supports geometry in a separate file.
|
||||
// False if geometry and field must be in a single file
|
||||
virtual bool separateGeometry() const
|
||||
{
|
||||
return !collateTimes_;
|
||||
}
|
||||
virtual bool separateGeometry() const;
|
||||
|
||||
|
||||
//- Write single surface geometry to file.
|
||||
|
||||
@ -64,6 +64,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
|
||||
// - VAR2/SURF1.0001.VAR2
|
||||
|
||||
const fileName baseDir = outputDir/varName;
|
||||
const fileName timeDir = outputDir.name();
|
||||
|
||||
if (!isDir(baseDir))
|
||||
{
|
||||
@ -71,19 +72,19 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
|
||||
}
|
||||
|
||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||
const scalar timeValue = 0.0;
|
||||
const scalar timeValue = readScalar(IStringStream(timeDir)());
|
||||
|
||||
OFstream osCase(baseDir/surfName + ".case");
|
||||
ensightGeoFile osGeom
|
||||
(
|
||||
baseDir,
|
||||
surfName + ".0000.mesh",
|
||||
surfName + ".00000000.mesh",
|
||||
writeFormat_
|
||||
);
|
||||
ensightFile osField
|
||||
(
|
||||
baseDir,
|
||||
surfName + ".0000." + varName,
|
||||
surfName + ".00000000." + varName,
|
||||
writeFormat_
|
||||
);
|
||||
|
||||
@ -97,22 +98,23 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << osGeom.name().name() << nl
|
||||
<< "model: 1 " << osGeom.name().name() << nl
|
||||
<< nl
|
||||
<< "VARIABLE" << nl
|
||||
<< ensightPTraits<Type>::typeName << " per "
|
||||
<< word(isNodeValues ? "node:" : "element:") << setw(10) << 1
|
||||
<< " " << varName
|
||||
<< " " << surfName.c_str() << ".****." << varName << nl
|
||||
<< word(isNodeValues ? "node:" : "element:")
|
||||
<< setw(3) << 1
|
||||
<< setw(15) << varName
|
||||
<< " " << surfName.c_str() << ".********." << varName << nl
|
||||
<< nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: 1" << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: 1" << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl
|
||||
<< timeValue << nl
|
||||
<< nl;
|
||||
<< " " << timeValue
|
||||
<< nl << nl << "# end" << nl;
|
||||
|
||||
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
||||
osGeom << ensPart;
|
||||
@ -145,13 +147,13 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
// eg, something like this:
|
||||
// - SURF1/SURF1.case
|
||||
// - SURF1/SURF1.0000.mesh
|
||||
// - SURF1/SURF1.0001.VAR1
|
||||
// - SURF1/SURF1.0001.VAR2
|
||||
// - SURF1/SURF1/data/0000/VAR1
|
||||
// - SURF1/SURF1/data/0000/VAR2
|
||||
// and
|
||||
// - SURF2/SURF2.case
|
||||
// - SURF2/SURF2.0000.mesh
|
||||
// - SURF2/SURF2.0001.VAR1
|
||||
// - SURF2/SURF2.0001.VAR2
|
||||
// - SURF2/SURF2/data/0000/VAR1
|
||||
// - SURF2/SURF2/data/0000/VAR2
|
||||
|
||||
const fileName baseDir = outputDir.path()/surfName;
|
||||
const fileName timeDir = outputDir.name();
|
||||
@ -162,11 +164,10 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
}
|
||||
|
||||
// surfName already validated
|
||||
const fileName meshFile(baseDir/surfName + ".0000.mesh");
|
||||
const fileName meshFile(baseDir/surfName + ".000000.mesh");
|
||||
const scalar timeValue = readScalar(IStringStream(timeDir)());
|
||||
label timeIndex = 0;
|
||||
|
||||
|
||||
// Do case file
|
||||
{
|
||||
dictionary dict;
|
||||
@ -235,9 +236,11 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
{
|
||||
Info<< "Writing state file to fieldsDict" << endl;
|
||||
}
|
||||
OFstream os(baseDir/"fieldsDict");
|
||||
os << dict;
|
||||
|
||||
{
|
||||
OFstream os(baseDir/"fieldsDict");
|
||||
os << "// summary of ensight times/fields" << nl << nl;
|
||||
dict.write(os, false);
|
||||
}
|
||||
|
||||
OFstream osCase(baseDir/surfName + ".case");
|
||||
|
||||
@ -251,7 +254,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << meshFile.name() << nl
|
||||
<< "model: 1 " << meshFile.name() << nl
|
||||
<< nl
|
||||
<< "VARIABLE" << nl;
|
||||
|
||||
@ -269,30 +272,32 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
osCase
|
||||
<< fieldType << " per "
|
||||
<< word(isNodeValues ? "node:" : "element:")
|
||||
<< setw(10) << 1
|
||||
<< setw(3) << 1
|
||||
<< setw(15) << varName
|
||||
<< " " << surfName.c_str() << ".****." << varName
|
||||
<< " data/******/" << varName
|
||||
<< nl;
|
||||
}
|
||||
osCase << nl;
|
||||
|
||||
osCase
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: " << timeIndex+1 << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: " << timeIndex+1 << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl;
|
||||
|
||||
label count = 0;
|
||||
forAll(times, timeI)
|
||||
{
|
||||
osCase << setw(12) << times[timeI] << " ";
|
||||
osCase << ' ' << setw(12) << times[timeI];
|
||||
|
||||
if (timeI != 0 && (timeI % 6) == 0)
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
osCase << nl;
|
||||
}
|
||||
}
|
||||
osCase << nl;
|
||||
osCase << nl << nl << "# end" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,15 +321,20 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
{
|
||||
OStringStream os;
|
||||
os.stdStream().fill('0');
|
||||
os << setw(4) << timeIndex;
|
||||
os << setw(6) << timeIndex;
|
||||
timeString = os.str();
|
||||
}
|
||||
|
||||
fileName dataDir = baseDir/"data"/timeString;
|
||||
|
||||
// as per mkdir -p "data/000000"
|
||||
mkDir(dataDir);
|
||||
|
||||
// Write field
|
||||
ensightFile osField
|
||||
(
|
||||
baseDir,
|
||||
surfName + "." + timeString + "." + varName,
|
||||
dataDir,
|
||||
varName,
|
||||
writeFormat_
|
||||
);
|
||||
if (verbose)
|
||||
@ -334,6 +344,14 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
osField.writeKeyword(ensightPTraits<Type>::typeName);
|
||||
ensPart.writeField(osField, values, isNodeValues);
|
||||
|
||||
// place a timestamp in the directory for future reference
|
||||
{
|
||||
OFstream timeStamp(dataDir/"time");
|
||||
timeStamp
|
||||
<< "# timestep time" << nl
|
||||
<< dataDir.name() << " " << timeValue << nl;
|
||||
}
|
||||
|
||||
return baseDir/surfName + ".case";
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
/*--------------------------------*- 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 volScalarField;
|
||||
location "0";
|
||||
object T;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 0 0 1 0 0 0];
|
||||
|
||||
internalField uniform 300;
|
||||
|
||||
boundaryField
|
||||
{
|
||||
inlet
|
||||
{
|
||||
type fixedValue;
|
||||
value $internalField;
|
||||
}
|
||||
|
||||
outlet
|
||||
{
|
||||
type inletOutlet;
|
||||
inletValue $internalField;
|
||||
value $internalField;
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,43 @@
|
||||
/*--------------------------------*- 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 volVectorField;
|
||||
location "0";
|
||||
object U;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 1 -1 0 0 0 0];
|
||||
|
||||
internalField uniform (0 0 0);
|
||||
|
||||
boundaryField
|
||||
{
|
||||
inlet
|
||||
{
|
||||
type zeroGradient; // pressureInletVelocity;
|
||||
value $internalField;
|
||||
}
|
||||
|
||||
outlet
|
||||
{
|
||||
type pressureInletOutletVelocity;
|
||||
value $internalField;
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
1045
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/V
Normal file
1045
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/V
Normal file
File diff suppressed because it is too large
Load Diff
54
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/p
Executable file
54
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/p
Executable file
@ -0,0 +1,54 @@
|
||||
/*--------------------------------*- 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 volScalarField;
|
||||
location "0";
|
||||
object p;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [1 -1 -2 0 0 0 0];
|
||||
|
||||
internalField uniform 101325;
|
||||
|
||||
boundaryField
|
||||
{
|
||||
inlet
|
||||
{
|
||||
type uniformFixedValue; // oscillatingFixedValue;
|
||||
uniformValue sine;
|
||||
uniformValueCoeffs
|
||||
{
|
||||
amplitude constant 1;
|
||||
frequency constant 3000;
|
||||
scale constant 50;
|
||||
level constant 101325;
|
||||
}
|
||||
value $internalField;
|
||||
}
|
||||
|
||||
outlet
|
||||
{
|
||||
type waveTransmissive;
|
||||
gamma 1.4;
|
||||
fieldInf 101325;
|
||||
lInf 2.25;
|
||||
value $internalField;
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
10
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean
Executable file
10
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source tutorial clean functions
|
||||
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
|
||||
|
||||
cleanCase
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
8
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun
Executable file
8
tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source tutorial run functions
|
||||
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
||||
|
||||
runApplication blockMesh
|
||||
runApplication $(getApplication)
|
||||
@ -0,0 +1,49 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 2.3.1 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "constant";
|
||||
object thermophysicalProperties;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
thermoType
|
||||
{
|
||||
type hePsiThermo;
|
||||
mixture pureMixture;
|
||||
transport sutherland;
|
||||
thermo hConst;
|
||||
equationOfState perfectGas;
|
||||
specie specie;
|
||||
energy sensibleEnthalpy;
|
||||
}
|
||||
|
||||
mixture
|
||||
{
|
||||
specie
|
||||
{
|
||||
nMoles 1;
|
||||
molWeight 28.9;
|
||||
}
|
||||
thermodynamics
|
||||
{
|
||||
Cp 1007;
|
||||
Hf 0;
|
||||
}
|
||||
transport
|
||||
{
|
||||
As 1.4792e-06;
|
||||
Ts 116;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,21 @@
|
||||
/*--------------------------------*- 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 "constant";
|
||||
object turbulenceProperties;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
simulationType laminar;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,78 @@
|
||||
/*--------------------------------*- 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;
|
||||
object blockMeshDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
convertToMeters 1;
|
||||
|
||||
vertices
|
||||
(
|
||||
(-1.25 -0.01 -0.01)
|
||||
(1.25 -0.01 -0.01)
|
||||
(1.25 0.01 -0.01)
|
||||
(-1.25 0.01 -0.01)
|
||||
(-1.25 -0.01 0.01)
|
||||
(1.25 -0.01 0.01)
|
||||
(1.25 0.01 0.01)
|
||||
(-1.25 0.01 0.01)
|
||||
);
|
||||
|
||||
blocks
|
||||
(
|
||||
hex (0 1 2 3 4 5 6 7) (1000 1 1) simpleGrading (1 1 1)
|
||||
);
|
||||
|
||||
edges
|
||||
(
|
||||
);
|
||||
|
||||
boundary
|
||||
(
|
||||
inlet
|
||||
{
|
||||
type patch;
|
||||
faces
|
||||
(
|
||||
(0 4 7 3)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
outlet
|
||||
{
|
||||
type patch;
|
||||
faces
|
||||
(
|
||||
(1 2 6 5)
|
||||
);
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
faces
|
||||
(
|
||||
(0 1 5 4)
|
||||
(3 7 6 2)
|
||||
(0 3 2 1)
|
||||
(5 6 7 4)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
mergePatchPairs
|
||||
(
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,82 @@
|
||||
/*--------------------------------*- 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 controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application rhoPimpleFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.02;
|
||||
|
||||
deltaT 2e-6;
|
||||
|
||||
writeControl runTime;
|
||||
|
||||
writeInterval 0.0002;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii; // binary;
|
||||
|
||||
writePrecision 16;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
adjustTimeStep no;
|
||||
|
||||
maxCo 0.3;
|
||||
|
||||
maxDeltaT 1;
|
||||
|
||||
|
||||
functions
|
||||
{
|
||||
fieldAverage
|
||||
{
|
||||
type fieldAverage;
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
outputControl outputTime;
|
||||
fields
|
||||
(
|
||||
U
|
||||
{
|
||||
mean on;
|
||||
prime2Mean off;
|
||||
base time;
|
||||
}
|
||||
|
||||
p
|
||||
{
|
||||
mean on;
|
||||
prime2Mean off;
|
||||
base time;
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,37 @@
|
||||
/*--------------------------------*- 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 fvOptions;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
acousticDampingSource
|
||||
{
|
||||
type acousticDampingSource;
|
||||
active yes;
|
||||
|
||||
acousticDampingSourceCoeffs
|
||||
{
|
||||
timeStart 0.004;
|
||||
duration 1000.0;
|
||||
selectionMode all;
|
||||
centre (-1.25 0 0);
|
||||
radius1 1.2;
|
||||
radius2 1.65;
|
||||
frequency 3000;
|
||||
URef UMean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//************************************************************************* //
|
||||
@ -0,0 +1,58 @@
|
||||
/*--------------------------------*- 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 fvSchemes;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
ddtSchemes
|
||||
{
|
||||
default backward;
|
||||
}
|
||||
|
||||
gradSchemes
|
||||
{
|
||||
default Gauss linear;
|
||||
}
|
||||
|
||||
divSchemes
|
||||
{
|
||||
default none;
|
||||
div(phi,U) Gauss linearUpwind grad(U);
|
||||
div(phi,K) Gauss linear;
|
||||
div(phi,h) Gauss limitedLinear 1;
|
||||
div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
|
||||
}
|
||||
|
||||
laplacianSchemes
|
||||
{
|
||||
default Gauss linear orthogonal;
|
||||
}
|
||||
|
||||
interpolationSchemes
|
||||
{
|
||||
default linear;
|
||||
}
|
||||
|
||||
snGradSchemes
|
||||
{
|
||||
default no;
|
||||
}
|
||||
|
||||
wallDist
|
||||
{
|
||||
method meshWave;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,71 @@
|
||||
/*--------------------------------*- 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 fvSolution;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
solvers
|
||||
{
|
||||
p
|
||||
{
|
||||
solver PCG;
|
||||
preconditioner DIC;
|
||||
tolerance 1e-08;
|
||||
relTol 0.01;
|
||||
}
|
||||
|
||||
pFinal
|
||||
{
|
||||
$p;
|
||||
relTol 0;
|
||||
}
|
||||
|
||||
"rho.*"
|
||||
{
|
||||
$p;
|
||||
tolerance 1e-05;
|
||||
relTol 0;
|
||||
}
|
||||
|
||||
"(U|h)"
|
||||
{
|
||||
solver smoothSolver;
|
||||
smoother symGaussSeidel;
|
||||
tolerance 1e-08;
|
||||
relTol 0.01;
|
||||
}
|
||||
|
||||
"(U|h)Final"
|
||||
{
|
||||
$U;
|
||||
relTol 0;
|
||||
}
|
||||
}
|
||||
|
||||
PIMPLE
|
||||
{
|
||||
momentumPredictor yes;
|
||||
nOuterCorrectors 7;
|
||||
nCorrectors 1;
|
||||
rhoMax 1.5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
41
tutorials/incompressible/icoFoam/cavityMappingTest/0/U
Normal file
41
tutorials/incompressible/icoFoam/cavityMappingTest/0/U
Normal file
@ -0,0 +1,41 @@
|
||||
/*--------------------------------*- 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 volVectorField;
|
||||
object U;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 1 -1 0 0 0 0];
|
||||
|
||||
internalField uniform (0 0 0);
|
||||
|
||||
boundaryField
|
||||
{
|
||||
movingWall
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform (1 0 0);
|
||||
}
|
||||
|
||||
fixedWalls
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
39
tutorials/incompressible/icoFoam/cavityMappingTest/0/p
Normal file
39
tutorials/incompressible/icoFoam/cavityMappingTest/0/p
Normal file
@ -0,0 +1,39 @@
|
||||
/*--------------------------------*- 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 volScalarField;
|
||||
object p;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 2 -2 0 0 0 0];
|
||||
|
||||
internalField uniform 0;
|
||||
|
||||
boundaryField
|
||||
{
|
||||
movingWall
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
fixedWalls
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
11
tutorials/incompressible/icoFoam/cavityMappingTest/Allclean
Executable file
11
tutorials/incompressible/icoFoam/cavityMappingTest/Allclean
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
|
||||
# Source tutorial run functions
|
||||
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
|
||||
|
||||
cleanCase
|
||||
|
||||
rm -rf constant/coarseMesh
|
||||
|
||||
|
||||
22
tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel
Executable file
22
tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
|
||||
# Source tutorial run functions
|
||||
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
||||
|
||||
runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse
|
||||
|
||||
mkdir constant/coarseMesh
|
||||
mv constant/polyMesh constant/coarseMesh
|
||||
|
||||
runApplication -s fine blockMesh -dict system/blockMeshDict.fine
|
||||
|
||||
runApplication -s fine decomposePar
|
||||
|
||||
runApplication -s coarseMesh decomposePar -region coarseMesh
|
||||
|
||||
runParallel $(getApplication)
|
||||
|
||||
#runApplication -s fine reconstructPar
|
||||
#
|
||||
#runApplication -s coarseMesh reconstructPar -region coarseMesh
|
||||
15
tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-serial
Executable file
15
tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-serial
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
|
||||
# Source tutorial run functions
|
||||
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
||||
|
||||
runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse
|
||||
|
||||
mkdir constant/coarseMesh
|
||||
mv constant/polyMesh constant/coarseMesh
|
||||
|
||||
runApplication -s fine blockMesh -dict system/blockMeshDict.fine
|
||||
|
||||
runApplication $(getApplication)
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
/*--------------------------------*- 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 "constant";
|
||||
object transportProperties;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
nu [0 2 -1 0 0 0 0] 0.01;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user