diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index e5b8e5f2fd..9d21d32b35 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -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(); diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 7ab154f604..9b8f37e252 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -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 { 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