diff --git a/etc/caseDicts/postProcessing/fields/energySpectrum b/etc/caseDicts/postProcessing/fields/energySpectrum new file mode 100644 index 0000000000..4df60270fa --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/energySpectrum @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Web: www.OpenFOAM.com + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Calculates the energy spectrum for a box of turbulence + +\*---------------------------------------------------------------------------*/ + +type energySpectrum; +libs ("librandomProcessesFunctionObjects.so"); + +executeControl writeTime; +writeControl writeTime; + +// ************************************************************************* // diff --git a/src/functionObjects/randomProcesses/Allwmake b/src/functionObjects/randomProcesses/Allwmake new file mode 100755 index 0000000000..c81ffedf78 --- /dev/null +++ b/src/functionObjects/randomProcesses/Allwmake @@ -0,0 +1,16 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +targetType=libso # Preferred library type +. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments +. $WM_PROJECT_DIR/wmake/scripts/have_fftw + +#------------------------------------------------------------------------------ + +if have_fftw +then + wmake $targetType +else + echo "==> skip randomProcesses library (no FFTW)" +fi + +#------------------------------------------------------------------------------ diff --git a/src/functionObjects/randomProcesses/Make/files b/src/functionObjects/randomProcesses/Make/files new file mode 100644 index 0000000000..e13e8afc99 --- /dev/null +++ b/src/functionObjects/randomProcesses/Make/files @@ -0,0 +1,3 @@ +energySpectrum/energySpectrum.C + +LIB = $(FOAM_LIBBIN)/librandomProcessesFunctionObjects diff --git a/src/functionObjects/randomProcesses/Make/options b/src/functionObjects/randomProcesses/Make/options new file mode 100644 index 0000000000..4c713c968a --- /dev/null +++ b/src/functionObjects/randomProcesses/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/randomProcesses/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +LIB_LIBS = \ + -lrandomProcesses \ + -lfiniteVolume \ + -lmeshTools diff --git a/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C b/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C new file mode 100644 index 0000000000..7c19426a6e --- /dev/null +++ b/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C @@ -0,0 +1,263 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "energySpectrum.H" +#include "fft.H" +#include "fvMesh.H" +#include "boundBox.H" +#include "OFstream.H" +#include "mathematicalConstants.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(energySpectrum, 0); + addToRunTimeSelectionTable(functionObject, energySpectrum, dictionary); +} +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::functionObjects::energySpectrum::writeFileHeader(Ostream& os) +{ + writeHeader(os, "Turbulence energy spectra"); + + writeCommented(os, "kappa E(kappa)"); + + os << endl; +} + + +void Foam::functionObjects::energySpectrum::calcAndWriteSpectrum +( + const vectorField& U, + const vectorField& C, + const vector& c0, + const vector& deltaC, + const Vector