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.
This commit is contained in:
Henry Weller
2019-06-18 22:06:17 +01:00
parent 8e9f692aa4
commit 251f91cfa5
10 changed files with 666 additions and 130 deletions

View File

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

View File

@ -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,15 +23,9 @@ 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 * * * * * * * * * * * * * //
@ -39,59 +33,18 @@ 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));
const DimensionedField<scalar, volMesh>& V = mesh_.V();
// 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];
}
// Write out the force coefficient for debugging
if (debug && mesh_.time().writeTime())
{
volScalarField forceCoeff
tmp<volScalarField::Internal> tforceCoeff
(
new volScalarField::Internal
(
IOobject
(
@ -100,18 +53,47 @@ void Foam::fv::verticalDamping::add
mesh_
),
mesh_,
lambda_*mag(g),
dimensionedScalar(lambda_.dimensions(), scale_.valid() ? 0 : 1)
)
);
scalarField& forceCoeff = tforceCoeff.ref();
const scalar lambda = lambda_.value();
forAll(origins_, i)
{
const vectorField& c = mesh_.cellCentres();
const scalarField x((c - origins_[i]) & directions_[i]);
forceCoeff = lambda*max(forceCoeff, scale_->value(x));
}
// Write out the force coefficient for debugging
if (debug && mesh_.time().writeTime())
{
volScalarField vForceCoeff
(
IOobject
(
type() + ":forceCoeff",
mesh_.time().timeName(),
mesh_
),
mesh_,
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))
{

View File

@ -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
// ************************************************************************* //

View File

@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 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/>.
\*---------------------------------------------------------------------------*/
#include "isotropicDamping.H"
#include "fvMatrix.H"
#include "fvmSup.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(isotropicDamping, 0);
addToRunTimeSelectionTable(option, isotropicDamping, dictionary);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fv::isotropicDamping::add
(
const volScalarField::Internal& forceCoeff,
fvMatrix<vector>& eqn
)
{
eqn -= fvm::Sp(forceCoeff, eqn.psi());
eqn += forceCoeff*value_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::isotropicDamping::isotropicDamping
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
damping(name, modelType, dict, mesh),
value_("value", dimVelocity, coeffs_.lookup("value"))
{
read(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::isotropicDamping::addSup
(
fvMatrix<vector>& eqn,
const label fieldi
)
{
add(this->forceCoeff(), eqn);
}
void Foam::fv::isotropicDamping::addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
add(rho*forceCoeff(), eqn);
}
void Foam::fv::isotropicDamping::addSup
(
const volScalarField& alpha,
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
add(alpha()*rho()*this->forceCoeff(), eqn);
}
bool Foam::fv::isotropicDamping::read(const dictionary& dict)
{
if (damping::read(dict))
{
value_ =
dimensionedVector
(
value_.name(),
value_.dimensions(),
coeffs_.lookup(value_.name())
);
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 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::isotropicDamping
Description
This fvOption applies an implicit damping force to all components of the
vector field to relax the field towards a specified uniform value. Its
intended purpose is to damp the motions of an interface in the region
approaching an outlet so that no reflections are generated.
The damping force coefficient \f$\lambda\f$ should be set based on the
desired level of damping and the residence time of a perturbation through
the damping zone. For example, if waves moving at 2 [m/s] are travelling
through a damping zone 8 [m] in length, then the residence time is 4 [s]. If
it is deemed necessary to damp for 5 time-scales, then \f$\lambda\f$ should
be set to equal 5/(4 [s]) = 1.2 [1/s].
Usage
Example usage:
\verbatim
isotropicDamping1
{
type isotropicDamping;
selectionMode cellZone;
cellZone nearOutlet;
value (2 0 0); // Value towards which the field it relaxed
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
timeStart 0;
duration 1e6;
}
\endverbatim
Example usage with graduated onset:
\verbatim
isotropicDamping1
{
type isotropicDamping;
selectionMode all;
// Define the line along which to apply the graduation
origin (1200 0 0);
direction (1 0 0);
// Or, define multiple lines
// origins ((1200 0 0) (1200 -300 0) (1200 300 0));
// directions ((1 0 0) (0 -1 0) (0 1 0));
scale
{
type halfCosineRamp;
start 0;
duration 600;
}
value (2 0 0); // Value towards which the field it relaxed
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
timeStart 0;
duration 1e6;
}
\endverbatim
See also
Foam::fv::damping
Foam::fv::verticalDamping
SourceFiles
isotropicDamping.C
\*---------------------------------------------------------------------------*/
#ifndef isotropicDamping_H
#define isotropicDamping_H
#include "damping.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class isotropicDamping Declaration
\*---------------------------------------------------------------------------*/
class isotropicDamping
:
public damping
{
// Private Data
//- Reference value
dimensionedVector value_;
// Private Member Functions
//- Source term to momentum equation
void add
(
const volScalarField::Internal& forceCoeff,
fvMatrix<vector>& eqn
);
public:
//- Runtime type information
TypeName("isotropicDamping");
// Constructors
//- Construct from components
isotropicDamping
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~isotropicDamping()
{}
// 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
// ************************************************************************* //

View File

@ -0,0 +1,111 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
#include "verticalDamping.H"
#include "fvMatrix.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::add
(
const volVectorField& alphaRhoU,
fvMatrix<vector>& eqn
)
{
const uniformDimensionedVectorField& g =
mesh_.lookupObject<uniformDimensionedVectorField>("g");
const dimensionedSymmTensor gg(sqr(g)/magSqr(g));
eqn -= forceCoeff()*(gg & alphaRhoU());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::verticalDamping::verticalDamping
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
damping(name, modelType, dict, mesh)
{
read(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::verticalDamping::addSup
(
fvMatrix<vector>& eqn,
const label fieldi
)
{
add(eqn.psi(), eqn);
}
void Foam::fv::verticalDamping::addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
add(rho*eqn.psi(), eqn);
}
void Foam::fv::verticalDamping::addSup
(
const volScalarField& alpha,
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
add(alpha*rho*eqn.psi(), eqn);
}
// ************************************************************************* //

View File

@ -97,6 +97,10 @@ Usage
}
\endverbatim
See also
Foam::fv::damping
Foam::fv::isotropicDamping
SourceFiles
verticalDamping.C
@ -105,15 +109,12 @@ SourceFiles
#ifndef verticalDamping_H
#define verticalDamping_H
#include "cellSetOption.H"
#include "damping.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type> class Function1;
namespace fv
{
@ -123,31 +124,15 @@ namespace fv
class verticalDamping
:
public cellSetOption
public damping
{
// Private 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_;
// Private Member Functions
//- Source term to momentum equation
void add
(
const volVectorField& alphaRhoU,
fvMatrix<vector>& eqn,
const label fieldi
fvMatrix<vector>& eqn
);
@ -201,12 +186,6 @@ public:
fvMatrix<vector>& eqn,
const label fieldi
);
// IO
//- Read dictionary
virtual bool read(const dictionary& dict);
};

View File

@ -113,15 +113,13 @@ Usage
)
);
Note
- the table with name "file" should have the same units as the
- the table with name "file" should have the same units as the
secondary mass flow rate and kg/s for phi
- faceZone is the faces at the inlet of the cellzone, it needs to be
- faceZone is the faces at the inlet of the cellzone, it needs to be
created with flip map flags. It is used to integrate the net mass flow
rate into the heat exchanger
SourceFiles
effectivenessHeatExchangerSource.C

View File

@ -17,7 +17,7 @@ FoamFile
option1
{
type verticalDamping;
type isotropicDamping;
selectionMode all;
@ -30,6 +30,7 @@ option1
duration 600;
}
value (2 0 0);
lambda 0.5;
timeStart 0;

View File

@ -0,0 +1,40 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
option1
{
type verticalDamping;
selectionMode all;
origin (1200 0 0);
direction (1 0 0);
scale
{
type halfCosineRamp;
start 0;
duration 600;
}
lambda 0.5;
timeStart 0;
duration 1e6;
}
//************************************************************************* //