From 33ef139ac1ac539a556626e13fc49719866f984d Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Mon, 18 Feb 2019 20:12:48 +0000 Subject: [PATCH] ENH: Digital-Filter Based Synthetic Turbulence Generation Method for LES/DES Inflows Velocity boundary condition generating synthetic turbulence-alike time-series for LES and DES turbulent flow computations. To this end, two synthetic turbulence generators can be chosen: - Digital-filter method-based generator (DFM) \verbatim Klein, M., Sadiki, A., and Janicka, J. A digital filter based generation of inflow data for spatially developing direct numerical or large eddy simulations, Journal of Computational Physics (2003) 186(2):652-665. doi:10.1016/S0021-9991(03)00090-1 \endverbatim - Forward-stepwise method-based generator (FSM) \verbatim Xie, Z.-T., and Castro, I. Efficient generation of inflow conditions for large eddy simulation of street-scale flows, Flow, Turbulence and Combustion (2008) 81(3):449-470 doi:10.1007/s10494-008-9151-5 \endverbatim In DFM or FSM, a random number set (mostly white noise), and a group of target statistics (mostly mean flow, Reynolds stress tensor profiles and length-scale sets) are fused into a new number set (stochastic time-series, yet consisting of the statistics) by a chain of mathematical operations whose characteristics are designated by the target statistics, so that the realised statistics of the new sets could match the target. Random number sets ---->-| | DFM or FSM ---> New stochastic time-series consisting | turbulence statistics Turbulence statistics ->-| The main difference between DFM and FSM is that the latter replaces the streamwise convolution summation in DFM by a simpler and a quantitatively justified equivalent procedure in order to reduce computational costs. Accordingly, the latter potentially brings resource advantages for computations involving relatively large length-scale sets and small time-steps. --- src/finiteVolume/Make/files | 1 + ...lentDigitalFilterInletFvPatchVectorField.C | 1261 +++++++++++++++++ ...lentDigitalFilterInletFvPatchVectorField.H | 569 ++++++++ ...alFilterInletFvPatchVectorFieldTemplates.C | 127 ++ 4 files changed, 1958 insertions(+) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.H create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorFieldTemplates.C diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 791ef91c32..81500b3e13 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -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 diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C new file mode 100644 index 0000000000..c1a2b841ab --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDigitalFilterInlet/turbulentDigitalFilterInletFvPatchVectorField.C @@ -0,0 +1,1261 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 "turbulentDigitalFilterInletFvPatchVectorField.H" +#include "volFields.H" +#include "mathematicalConstants.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const Foam::Enum +< + Foam::turbulentDigitalFilterInletFvPatchVectorField::variantType +> +Foam::turbulentDigitalFilterInletFvPatchVectorField::variantNames +({ + { variantType::DIGITAL_FILTER, "digitalFilter" }, + { variantType::DIGITAL_FILTER, "DFM" }, + { variantType::FORWARD_STEPWISE, "forwardStepwise" }, + { variantType::FORWARD_STEPWISE, "reducedDigitalFilter" }, + { variantType::FORWARD_STEPWISE, "FSM" } +}); + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +const Foam::pointToPointPlanarInterpolation& +Foam::turbulentDigitalFilterInletFvPatchVectorField::patchMapper() const +{ + // Initialise interpolation (2D planar interpolation by triangulation) + if (mapperPtr_.empty()) + { + // Reread values and interpolate + fileName samplePointsFile + ( + this->db().time().path() + /this->db().time().caseConstant() + /"boundaryData" + /this->patch().name() + /"points" + ); + + pointField samplePoints((IFstream(samplePointsFile)())); + + // tbd: run-time selection + bool nearestOnly = + ( + !mapMethod_.empty() + && mapMethod_ != "planarInterpolation" + ); + + // Allocate the interpolator + mapperPtr_.reset + ( + new pointToPointPlanarInterpolation + ( + samplePoints, + this->patch().patch().faceCentres(), + perturb_, + nearestOnly + ) + ); + } + + return *mapperPtr_; +} + + +Foam::List> +Foam::turbulentDigitalFilterInletFvPatchVectorField::patchIndexPairs() +{ + // Get patch normal direction into the domain + const vector nf(computePatchNormal()); + + // Find the second local coordinate direction + direction minCmpt = -1; + scalar minMag = VGREAT; + for (direction cmpt = 0; cmpt < pTraits::nComponents; ++cmpt) + { + scalar s = mag(nf[cmpt]); + if (s < minMag) + { + minMag = s; + minCmpt = cmpt; + } + } + + // Create the second local coordinate direction + vector e2(Zero); + e2[minCmpt] = 1.0; + + // Remove normal component + e2 -= (nf&e2)*nf; + + // Create the local coordinate system + coordSystem::cartesian cs + ( + Zero, // origin + nf, // normal + e2 // 0-axis + ); + + // Convert patch points into local coordinate system + const pointField localPos + ( + cs.localPosition + ( + pointField + ( + patch().patch().points(), + patch().patch().meshPoints() + ) + ) + ); + + const boundBox bb(localPos); + + // Normalise to (i, j) coordinates + const Vector2D