Skip to content
Permalink
Browse files

fvOptions::isotropicDamping: New wave damping fvOption

This implicit isotropic damping function relaxes the velocity field towards a
specified uniform value which can be set to (0 0 0) if no flow is required.
This is particularly appropriate to damp the waves in a closed wave tank with no
mean flow.

Testing on the interFoam wave has shown that for this simple case with uniform
mean flow the new isotropicDamping fvOption provides more rapid and complete
damping than the original verticalDamping.
  • Loading branch information...
Henry Weller
Henry Weller committed Jun 18, 2019
1 parent 8e9f692 commit 251f91cfa568881fccde70ae9eb6ccba8d784ed0
@@ -37,7 +37,9 @@ $(derivedSources)/buoyancyForce/buoyancyForce.C
$(derivedSources)/buoyancyForce/buoyancyForceIO.C
$(derivedSources)/buoyancyEnergy/buoyancyEnergy.C
$(derivedSources)/buoyancyEnergy/buoyancyEnergyIO.C
$(derivedSources)/verticalDamping/verticalDamping.C
$(derivedSources)/damping/damping/damping.C
$(derivedSources)/damping/isotropicDamping/isotropicDamping.C
$(derivedSources)/damping/verticalDamping/verticalDamping.C
$(derivedSources)/phaseLimitStabilization/phaseLimitStabilization.C
$(derivedSources)/accelerationSource/accelerationSource.C
$(derivedSources)/volumeFractionSource/volumeFractionSource.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -23,75 +23,54 @@ License
\*---------------------------------------------------------------------------*/

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

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

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


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

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

const dimensionedSymmTensor lgg(lambda_*sqr(g)/magSqr(g));
tmp<volScalarField::Internal> tforceCoeff
(
new volScalarField::Internal
(
IOobject
(
type() + ":forceCoeff",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(lambda_.dimensions(), scale_.valid() ? 0 : 1)
)
);
scalarField& forceCoeff = tforceCoeff.ref();

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

// Calculate the scale
scalarField s(mesh_.nCells(), scale_.valid() ? 0 : 1);
forAll(origins_, i)
{
const vectorField& c = mesh_.cellCentres();
const scalarField x((c - origins_[i]) & directions_[i]);
s = max(s, scale_->value(x));
}

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

// Calculate the force and apply it to the equation
vectorField force(cells_.size());
forAll(cells_, i)
{
const label c = cells_[i];
force[i] = V[c]*s[c]*(lgg.value() & alphaRhoU[c]);
}
meshTools::constrainDirection(mesh_, mesh_.solutionD(), force);
forAll(cells_, i)
{
const label c = cells_[i];
eqn.source()[c] += force[i];
forceCoeff = lambda*max(forceCoeff, scale_->value(x));
}

// Write out the force coefficient for debugging
if (debug && mesh_.time().writeTime())
{
volScalarField forceCoeff
volScalarField vForceCoeff
(
IOobject
(
@@ -100,18 +79,21 @@ void Foam::fv::verticalDamping::add
mesh_
),
mesh_,
lambda_*mag(g),
lambda_.dimensions(),
zeroGradientFvPatchField<scalar>::typeName
);
forceCoeff.primitiveFieldRef() *= s;
forceCoeff.write();
vForceCoeff.primitiveFieldRef() = forceCoeff;
vForceCoeff.correctBoundaryConditions();
vForceCoeff.write();
}

return tforceCoeff;
}


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

Foam::fv::verticalDamping::verticalDamping
Foam::fv::damping::damping
(
const word& name,
const word& modelType,
@@ -131,40 +113,7 @@ Foam::fv::verticalDamping::verticalDamping

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

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


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


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


bool Foam::fv::verticalDamping::read(const dictionary& dict)
bool Foam::fv::damping::read(const dictionary& dict)
{
if (cellSetOption::read(dict))
{
@@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 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::damping
Description
Base fvOption for damping functions.
See also
Foam::fv::isotropicDamping
Foam::fv::verticalDamping
SourceFiles
damping.C
\*---------------------------------------------------------------------------*/

#ifndef damping_H
#define damping_H

#include "cellSetOption.H"
#include "Function1.H"
#include "volFields.H"

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

namespace Foam
{
namespace fv
{

/*---------------------------------------------------------------------------*\
Class damping Declaration
\*---------------------------------------------------------------------------*/

class damping
:
public cellSetOption
{
protected:

// Protected Data

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

//- The scaling function
autoPtr<Function1<scalar>> scale_;

//- Origins of the scaling coordinate
vectorField origins_;

//- Directions of increasing scaling coordinate
vectorField directions_;


// Protected Member Functions

tmp<volScalarField::Internal> forceCoeff() const;


public:

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


// Constructors

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


//- Destructor
virtual ~damping()
{}


// Member Functions

// IO

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


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

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

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

#endif

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

0 comments on commit 251f91c

Please sign in to comment.
You can’t perform that action at this time.