diff --git a/src/fvOptions/sources/derived/velocityRamping/velocityRamping.H b/src/fvOptions/sources/derived/velocityRamping/velocityRamping.H index 9d92e09c99..f15d890052 100644 --- a/src/fvOptions/sources/derived/velocityRamping/velocityRamping.H +++ b/src/fvOptions/sources/derived/velocityRamping/velocityRamping.H @@ -40,7 +40,7 @@ Usage velocity (-2.572 0 0); ramp { - type quarterSineRamp; + type halfCosineRamp; start 0; duration 10; } diff --git a/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C index ab6e1e1089..99ab064407 100644 --- a/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C +++ b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,6 +28,7 @@ License #include "fvMatrix.H" #include "geometricOneField.H" #include "meshTools.H" +#include "Function1.H" #include "uniformDimensionedFields.H" #include "addToRunTimeSelectionTable.H" @@ -59,6 +60,14 @@ void Foam::fv::verticalDamping::add const DimensionedField& V = mesh_.V(); + // Calculate the scale + const scalarField s + ( + ramp_.valid() + ? ramp_->value((mesh_.cellCentres() - origin_) & direction_) + : tmp(new scalarField(mesh_.nCells(), 1)) + ); + // Check dimensions eqn.dimensions() - V.dimensions()*(lgg.dimensions() & alphaRhoU.dimensions()); @@ -68,7 +77,7 @@ void Foam::fv::verticalDamping::add forAll(cells_, i) { const label c = cells_[i]; - force[i] = V[c]*(lgg.value() & alphaRhoU[c]); + force[i] = V[c]*s[c]*(lgg.value() & alphaRhoU[c]); } meshTools::constrainDirection(mesh_, mesh_.solutionD(), force); forAll(cells_, i) @@ -90,7 +99,10 @@ Foam::fv::verticalDamping::verticalDamping ) : cellSetOption(name, modelType, dict, mesh), - lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda")) + lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda")), + ramp_(), + origin_(), + direction_() { read(dict); } @@ -143,6 +155,25 @@ bool Foam::fv::verticalDamping::read(const dictionary& dict) coeffs_.lookup(lambda_.name()) ); + const bool foundRamp = coeffs_.found("ramp"); + const bool foundOrigin = coeffs_.found("origin"); + const bool foundDirection = coeffs_.found("direction"); + if (foundRamp && foundOrigin && foundDirection) + { + ramp_ = Function1::New("ramp", coeffs_); + coeffs_.lookup("origin") >> origin_; + coeffs_.lookup("direction") >> direction_; + direction_ /= mag(direction_); + } + else if (foundRamp || foundOrigin || foundDirection) + { + WarningInFunction + << "The ramping specification is incomplete. \"ramp\", " + << "\"origin\" and \"direction\", must all be specified in " + << "order to ramp the damping. The damping will be applied " + << "uniformly across the cell set." << endl; + } + fieldNames_ = wordList(1, coeffs_.lookupOrDefault("U", "U")); applied_.setSize(1, false); diff --git a/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H index 1eaef6aa77..d43896470b 100644 --- a/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H +++ b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,6 +67,30 @@ Usage } \endverbatim + Example usage with graduated onset: + \verbatim + verticalDamping1 + { + type verticalDamping; + + selectionMode all; + + origin (1200 0 0); + direction (1 0 0); + ramp + { + type halfCosineRamp; + start 0; + duration 600; + } + + lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient + + timeStart 0; + duration 1e6; + } + \endverbatim + SourceFiles verticalDamping.C @@ -81,6 +105,9 @@ SourceFiles namespace Foam { + +template class Function1; + namespace fv { @@ -99,6 +126,15 @@ private: //- Damping coefficient [1/s] dimensionedScalar lambda_; + //- The ramping function + autoPtr> ramp_; + + //- Origin of the ramping coordinate + vector origin_; + + //- Direction of increasing ramping coordinate + vector direction_; + // Private Member Functions diff --git a/tutorials/multiphase/interFoam/laminar/wave/Allrun b/tutorials/multiphase/interFoam/laminar/wave/Allrun index c3b6a368c8..99393456ad 100755 --- a/tutorials/multiphase/interFoam/laminar/wave/Allrun +++ b/tutorials/multiphase/interFoam/laminar/wave/Allrun @@ -22,8 +22,6 @@ do runApplication -s $i refineMesh -dict system/refineMeshDictY -overwrite done -runApplication topoSet - runApplication setWaves -alpha alpha.water runApplication decomposePar diff --git a/tutorials/multiphase/interFoam/laminar/wave/constant/fvOptions b/tutorials/multiphase/interFoam/laminar/wave/constant/fvOptions index a2691bbb96..73a539fbff 100644 --- a/tutorials/multiphase/interFoam/laminar/wave/constant/fvOptions +++ b/tutorials/multiphase/interFoam/laminar/wave/constant/fvOptions @@ -19,10 +19,18 @@ option1 { type verticalDamping; - selectionMode cellZone; - cellZone right; + selectionMode all; - lambda 0.1; + origin (1200 0 0); + direction (1 0 0); + ramp + { + type halfCosineRamp; + start 0; + duration 600; + } + + lambda 0.5; timeStart 0; duration 1e6; diff --git a/tutorials/multiphase/interFoam/laminar/wave/system/topoSetDict b/tutorials/multiphase/interFoam/laminar/wave/system/topoSetDict deleted file mode 100644 index d9f4d4ef83..0000000000 --- a/tutorials/multiphase/interFoam/laminar/wave/system/topoSetDict +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "system"; - object topoSetDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -actions -( - { - name right; - type cellSet; - action new; - source boxToCell; - sourceInfo - { - box (1800 -1e6 -1e6) (1e6 1e6 1e6); - } - } - { - name right; - type cellZoneSet; - action new; - source setToCellZone; - sourceInfo - { - set right; - } - } -); - -// ************************************************************************* //