fvOptions: verticalDamping: Added spatial ramping

The onset of vertical damping can now be graduated over a distance. The
user specifies an origin and a direction along which the graduation
occurs, and a ramping function to specify the form of the graduation. An
example specification for the fvOption is:

    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;
    }

If the origin, direction or ramp entries are omitted then the fvOption
functions as before; applying the damping to the entire volume or the
specified cell set.

This work was supported by Jan Kaufmann and Jan Oberhagemann at DNV GL.
This commit is contained in:
Will Bainbridge
2018-01-08 17:59:55 +00:00
parent 139523c17e
commit d2175f8fe0
6 changed files with 83 additions and 52 deletions

View File

@ -40,7 +40,7 @@ Usage
velocity (-2.572 0 0);
ramp
{
type quarterSineRamp;
type halfCosineRamp;
start 0;
duration 10;
}

View File

@ -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<scalar, volMesh>& V = mesh_.V();
// Calculate the scale
const scalarField s
(
ramp_.valid()
? ramp_->value((mesh_.cellCentres() - origin_) & direction_)
: tmp<scalarField>(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<scalar>::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<word>("U", "U"));
applied_.setSize(1, false);

View File

@ -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 Type> class Function1;
namespace fv
{
@ -99,6 +126,15 @@ private:
//- Damping coefficient [1/s]
dimensionedScalar lambda_;
//- The ramping function
autoPtr<Function1<scalar>> ramp_;
//- Origin of the ramping coordinate
vector origin_;
//- Direction of increasing ramping coordinate
vector direction_;
// Private Member Functions

View File

@ -22,8 +22,6 @@ do
runApplication -s $i refineMesh -dict system/refineMeshDictY -overwrite
done
runApplication topoSet
runApplication setWaves -alpha alpha.water
runApplication decomposePar

View File

@ -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;

View File

@ -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;
}
}
);
// ************************************************************************* //