Skip to content

Commit

Permalink
fvOptions: Added vertical damping
Browse files Browse the repository at this point in the history
This fvOption applies an explicit damping force to components of the
vector field in the direction of gravity. Its intended purpose is to
damp the vertical motions of an interface in the region approaching an
outlet so that no reflections are generated. The level of damping is
specified by a coefficient, lambda, given in units of 1/s.

It can be enabled for a cellZone named "nearOutlet", by adding the
following entry to constant/fvOptions:

    verticalDamping1
    {
        type            verticalDamping;

        selectionMode   cellZone;
        cellZone        nearOutlet;

        lambda          [0 0 -1 0 0 0 0] 1;

        timeStart       0;
        duration        1e6;
    }

This work was supported by Jan Kaufmann and Jan Oberhagemann at DNV GL.
  • Loading branch information
Will Bainbridge committed May 31, 2017
1 parent 358770b commit 813a674
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/fvOptions/Make/files
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $(derivedSources)/buoyancyForce/buoyancyForce.C
$(derivedSources)/buoyancyForce/buoyancyForceIO.C
$(derivedSources)/buoyancyEnergy/buoyancyEnergy.C
$(derivedSources)/buoyancyEnergy/buoyancyEnergyIO.C
$(derivedSources)/verticalDamping/verticalDamping.C

interRegion = sources/interRegion
$(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
Expand Down
153 changes: 153 additions & 0 deletions src/fvOptions/sources/derived/verticalDamping/verticalDamping.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/

#include "verticalDamping.H"
#include "fvMesh.H"
#include "fvMatrix.H"
#include "geometricOneField.H"
#include "meshTools.H"
#include "uniformDimensionedFields.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(verticalDamping, 0);
addToRunTimeSelectionTable(option, verticalDamping, dictionary);
}
}


// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

void Foam::fv::verticalDamping::addSup
(
const volVectorField& alphaRhoU,
fvMatrix<vector>& eqn,
const label fieldi
)
{
const uniformDimensionedVectorField& g =
mesh_.lookupObject<uniformDimensionedVectorField>("g");

const dimensionedSymmTensor lgg(lambda_*sqr(g)/magSqr(g));

const DimensionedField<scalar, volMesh>& V = mesh_.V();

// Check dimensions
eqn.dimensions()
- V.dimensions()*(lgg.dimensions() & alphaRhoU.dimensions());

forAll(cells_, i)
{
const label c = cells_[i];
vector f = V[c]*(lgg.value() & alphaRhoU[c]);
meshTools::constrainDirection(mesh_, mesh_.solutionD(), f);
eqn.source()[c] += f;
}
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::fv::verticalDamping::verticalDamping
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
cellSetOption(name, modelType, dict, mesh),
lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda"))
{
read(dict);
}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

void Foam::fv::verticalDamping::addSup
(
fvMatrix<vector>& eqn,
const label fieldi
)
{
addSup(eqn.psi(), eqn, fieldi);
}


void Foam::fv::verticalDamping::addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
addSup(rho*eqn.psi(), eqn, fieldi);
}


void Foam::fv::verticalDamping::addSup
(
const volScalarField& alpha,
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
addSup(alpha*rho*eqn.psi(), eqn, fieldi);
}


bool Foam::fv::verticalDamping::read(const dictionary& dict)
{
if (cellSetOption::read(dict))
{
lambda_ =
dimensionedScalar
(
lambda_.name(),
lambda_.dimensions(),
coeffs_.lookup(lambda_.name())
);

fieldNames_ = wordList(1, coeffs_.lookupOrDefault<word>("U", "U"));

applied_.setSize(1, false);

return true;
}
else
{
return false;
}
}


// ************************************************************************* //
162 changes: 162 additions & 0 deletions src/fvOptions/sources/derived/verticalDamping/verticalDamping.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ 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 <http://www.gnu.org/licenses/>.
Class
Foam::fv::verticalDamping
Description
This fvOption applies an explicit damping force to components of the vector
field in the direction of gravity. Its intended purpose is to damp the
vertical motions of an interface in the region approaching an outlet so that
no reflections are generated.
Usage
Example usage:
\verbatim
verticalDamping1
{
type verticalDamping;
selectionMode cellZone;
cellZone nearOutlet;
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
timeStart 0;
duration 1e6;
}
\endverbatim
SourceFiles
verticalDamping.C
\*---------------------------------------------------------------------------*/

#ifndef verticalDamping_H
#define verticalDamping_H

#include "cellSetOption.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace fv
{

/*---------------------------------------------------------------------------*\
Class verticalDamping Declaration
\*---------------------------------------------------------------------------*/

class verticalDamping
:
public cellSetOption
{
private:

// Private data

//- Damping coefficient [1/s]
dimensionedScalar lambda_;


// Private Member Functions

//- Source term to momentum equation
void addSup
(
const volVectorField& alphaRhoU,
fvMatrix<vector>& eqn,
const label fieldi
);


public:

//- Runtime type information
TypeName("verticalDamping");


// Constructors

//- Construct from components
verticalDamping
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);


//- Destructor
virtual ~verticalDamping()
{}


// Member Functions

// Add explicit and implicit contributions

//- Source term to momentum equation
virtual void addSup
(
fvMatrix<vector>& eqn,
const label fieldi
);

//- Source term to compressible momentum equation
virtual void addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
);

//- Source term to phase momentum equation
virtual void addSup
(
const volScalarField& alpha,
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
);


// IO

//- Read dictionary
virtual bool read(const dictionary& dict);
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace fv
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

0 comments on commit 813a674

Please sign in to comment.