Commit 945d80f1 authored by Andrew Heather's avatar Andrew Heather Committed by Andrew Heather
Browse files

Merge branch 'feature-digitalFilterFvPatchInlet' into 'develop'

Digital-Filter Based Synthetic Turbulence Generation Method for LES/DES Inflow

See merge request OpenFOAM-plus!235
parents 74ec9428 14a2a8bf
......@@ -950,6 +950,12 @@ bool Foam::Time::stopAt(const stopAtControls stopCtrl) const
}
bool Foam::Time::isAdjustTimeStep() const
{
return controlDict_.lookupOrDefault("adjustTimeStep", false) ? true : false;
}
void Foam::Time::setTime(const Time& t)
{
value() = t.value();
......
......@@ -422,6 +422,9 @@ public:
//- Return the stop control information
virtual stopAtControls stopAt() const;
//- Return true if adjustTimeStep is true
virtual bool isAdjustTimeStep() const;
//- Return the list of function objects
const functionObjectList& functionObjects() const
{
......
......@@ -200,6 +200,7 @@ $(derivedFvPatchFields)/translatingWallVelocity/translatingWallVelocityFvPatchVe
$(derivedFvPatchFields)/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
$(derivedFvPatchFields)/turbulentDFSEMInlet/eddy/eddy.C
$(derivedFvPatchFields)/turbulentDFSEMInlet/eddy/eddyIO.C
$(derivedFvPatchFields)/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C
$(derivedFvPatchFields)/turbulentInlet/turbulentInletFvPatchFields.C
$(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C
$(derivedFvPatchFields)/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 - 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "pointToPointPlanarInterpolation.H"
#include "Time.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::turbulentDigitalFilterInletFvPatchVectorField::interpolateOrRead
(
const word& fieldName,
const dictionary& dict,
bool& interpolateField
) const
{
if (dict.found(fieldName))
{
tmp<Field<Type>> tFld
(
new Field<Type>
(
fieldName,
dict,
this->patch().size()
)
);
interpolateField = false;
return tFld;
}
else
{
interpolateField = true;
return interpolateBoundaryData<Type>(fieldName);
}
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::turbulentDigitalFilterInletFvPatchVectorField::interpolateBoundaryData
(
const word& fieldName
) const
{
const word& patchName = this->patch().name();
fileName valsFile
(
fileHandler().filePath
(
fileName
(
this->db().time().path()
/this->db().time().caseConstant()
/"boundaryData"
/patchName
/"0"
/fieldName
)
)
);
autoPtr<ISstream> isPtr
(
fileHandler().NewIFstream
(
valsFile
)
);
Field<Type> vals(isPtr());
Info<< "Turbulent DFM/FSM patch " << patchName
<< ": Interpolating field " << fieldName
<< " from " << valsFile << endl;
return patchMapper().interpolate(vals);
}
template<class Form, class Type>
Form Foam::turbulentDigitalFilterInletFvPatchVectorField::generateRandomSet
(
const label len
)
{
Form randomSet(len);
std::generate
(
randomSet.begin(),
randomSet.end(),
[&]{return rndGen_.GaussNormal<Type>();}
);
return randomSet;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1906 |
| \\ / 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
{
bottomWall
{
type fixedValue;
value uniform (0 0 0);
}
topWall
{
type fixedValue;
value uniform (0 0 0);
}
sides_half0
{
type cyclic;
}
sides_half1
{
type cyclic;
}
inlet
{
type turbulentDFSEMInlet;
delta 2;
nCellPerEddy 1;
mapMethod nearestCell;
value uniform (0 0 0);
}
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1906 |
| \\ / 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
{
bottomWall
{
type fixedValue;
value uniform (0 0 0);
}
topWall
{
type fixedValue;
value uniform (0 0 0);
}
sides_half0
{
type cyclic;
}
sides_half1
{
type cyclic;
}
inlet
{
type turbulentDigitalFilterInlet;
variant digitalFilter;
planeDivisions ( 64 70 );
L ( 0.78035508 0.31085352 0.342261 0.1728125 0.171875
0.22459375 0.172787596 0.171889998 0.224578995 );
patchNormalSpeed 20.133;
value uniform (0 0 0);
}
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1906 |
| \\ / 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
{
bottomWall
{
type fixedValue;
value uniform (0 0 0);
}
topWall
{
type fixedValue;
value uniform (0 0 0);
}
sides_half0
{
type cyclic;
}
sides_half1
{
type cyclic;
}
inlet
{
type turbulentDigitalFilterInlet;
variant reducedDigitalFilter;
planeDivisions ( 64 70 );
L ( 0.78035508 0.31085352 0.342261 0.1728125 0.171875
0.22459375 0.172787596 0.171889998 0.224578995 );
patchNormalSpeed 20.133;
value uniform (0 0 0);
}
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1906 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
bottomWall
{
type zeroGradient;
}
topWall
{
type zeroGradient;
}
sides_half0
{
type cyclic;
}
sides_half1
{
type cyclic;
}
inlet
{
type calculated;
value uniform 1e-08;
}
outlet
{
type calculated;
value uniform 1e-08;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1906 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
bottomWall
{
type zeroGradient;
}
topWall
{
type zeroGradient;
}
sides_half0
{
type cyclic;
}
sides_half1
{
type cyclic;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
cleanCase0
\rm -r results
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
# Compute test case with different synthetic inflow models
declare -a Models=(
"reducedDigitalFilter"
"digitalFilter"
"DFSEM"
)
# Collect data in 'results' directory
[ -d "results" ] || mkdir results
restore0Dir
runApplication blockMesh
# Compute and collect data
for val in ${Models[@]}; do
echo "Running the case with the model: $val"
\cp 0/U.$val 0/U
\rm -r constant/boundaryData/inlet
\cp -r constant/boundaryData/inlet.$val constant/boundaryData/inlet
runApplication pimpleFoam
gnuplot plot.patch
gnuplot plot.cell
mv postProcessing results/postProcessing.$val
mv stress* results/postProcessing.$val/.
mv log* results/postProcessing.$val/.
cleanTimeDirectories
done
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
# Compute test case with different synthetic inflow models
declare -a Models=(
"reducedDigitalFilter"
"digitalFilter"
"DFSEM"
)
# Collect data in 'results' directory
[ -d "results" ] || mkdir results
restore0Dir
runApplication blockMesh
# Compute parallel and collect data
for val in ${Models[@]}; do
echo "Running the case with the model: $val"
\rm 0/U*
\cp 0.orig/U.$val 0/U
\rm -r constant/boundaryData/inlet
\cp -r constant/boundaryData/inlet.$val constant/boundaryData/inlet
runApplication decomposePar
runParallel pimpleFoam
gnuplot plot.patch
gnuplot plot.cell
mv postProcessing results/postProcessing.$val
mv stress* results/postProcessing.$val/.
mv log* results/postProcessing.$val/.
cleanTimeDirectories
\rm -rf processor* > /dev/null 2>&1
done
Synthetic turbulence inflow tests
======================
The following three synthetic turbulence inflow boundary conditions are
examined through a single-cell-domain smooth-wall plane channel flow setup:
- turbulentDFSEMInlet
- turbulentDigitalFilterInlet variant=digitalFilter
- turbulentDigitalFilterInlet variant=reducedDigitalFilter
The input statistics are obtained from:
Moser, Kim & Mansour
"DNS of Turbulent Channel Flow up to Re_tau=590",
Physics of Fluids (1999) vol 11, 943-945.
doi.org/10.1063/1.869966
from which the input first-/second-order turbulence statistics data for the
smooth-wall plane channel flow at Re=395 were used.
The data is available online from (Retrieved: 21-06-2019):
http://turbulence.ices.utexas.edu/MKM_1999.html
Serial executing:
./Allrun
Parallel (decompositionMethod=scotch) executing:
./Allrunparallel
Both scripts run the test case, and collect the OpenFOAM samples, and plots into
the 'results' directory.
(
0
1.76693e-06
1.06447e-07
2.85582e-08
1.73393e-08
3.56243e-08
3.79499e-08
1.50479e-07
1.55614e-07
1.93408e-07
4.50118e-08
2.6295e-10
6.18128e-08
4.4709e-08
5.98657e-07
2.25711e-06
4.20946e-06
6.292e-06
7.5414e-06
9.02814e-06