mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fvOptions - added new acousticDampingSource to damp spurious pressure perturbations
This commit is contained in:
@ -12,6 +12,7 @@ $(generalSources)/codedSource/codedSource.C
|
||||
$(generalSources)/semiImplicitSource/semiImplicitSource.C
|
||||
|
||||
derivedSources=sources/derived
|
||||
$(derivedSources)/acousticDampingSource/acousticDampingSource.C
|
||||
$(derivedSources)/actuationDiskSource/actuationDiskSource.C
|
||||
$(derivedSources)/buoyancyForce/buoyancyForce.C
|
||||
$(derivedSources)/buoyancyForce/buoyancyForceIO.C
|
||||
|
||||
@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ 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 "acousticDampingSource.H"
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "fvmSup.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
defineTypeNameAndDebug(acousticDampingSource, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
option,
|
||||
acousticDampingSource,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fv::acousticDampingSource::setBlendingFactor()
|
||||
{
|
||||
blendFactor_.internalField() = 1;
|
||||
|
||||
const vectorField& Cf = mesh_.C();
|
||||
|
||||
const scalar pi = constant::mathematical::pi;
|
||||
|
||||
forAll(cells_, i)
|
||||
{
|
||||
label celli = cells_[i];
|
||||
scalar d = mag(Cf[celli] - x0_);
|
||||
|
||||
if (d < r1_)
|
||||
{
|
||||
blendFactor_[celli] = 0.0;
|
||||
}
|
||||
else if ((d >= r1_) && (d <= (r1_ + r2_)))
|
||||
{
|
||||
blendFactor_[celli] = (1.0 - cos(pi*mag(d - r1_)/r2_))/2.0;
|
||||
}
|
||||
}
|
||||
|
||||
blendFactor_.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fv::acousticDampingSource::acousticDampingSource
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
:
|
||||
cellSetOption(name, modelType, dict, mesh),
|
||||
frequency_("frequency", dimless/dimTime, 0),
|
||||
blendFactor_
|
||||
(
|
||||
volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name_ + ":blend",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("blend0", dimless, 1.0),
|
||||
zeroGradientFvPatchField<vector>::typeName
|
||||
)
|
||||
),
|
||||
URefName_("unknown-URefName"),
|
||||
x0_(Zero),
|
||||
r1_(0),
|
||||
r2_(0),
|
||||
w_(20)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fv::acousticDampingSource::addSup
|
||||
(
|
||||
fvMatrix<vector>& eqn,
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
const volVectorField& U = eqn.psi();
|
||||
const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_);
|
||||
const volVectorField& URef(mesh().lookupObject<volVectorField>(URefName_));
|
||||
|
||||
fvMatrix<vector> dampingEqn
|
||||
(
|
||||
fvm::Sp(coeff, U) - coeff*URef
|
||||
);
|
||||
eqn -= dampingEqn;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::acousticDampingSource::addSup
|
||||
(
|
||||
const volScalarField& rho,
|
||||
fvMatrix<vector>& eqn,
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
const volVectorField& U = eqn.psi();
|
||||
const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_);
|
||||
const volVectorField& URef(mesh().lookupObject<volVectorField>(URefName_));
|
||||
|
||||
fvMatrix<vector> dampingEqn
|
||||
(
|
||||
fvm::Sp(rho*coeff, U) - rho*coeff*URef
|
||||
);
|
||||
eqn -= dampingEqn;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::acousticDampingSource::addSup
|
||||
(
|
||||
const volScalarField& alpha,
|
||||
const volScalarField& rho,
|
||||
fvMatrix<vector>& eqn,
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
const volVectorField& U = eqn.psi();
|
||||
const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_);
|
||||
const volVectorField& URef(mesh().lookupObject<volVectorField>(URefName_));
|
||||
|
||||
fvMatrix<vector> dampingEqn
|
||||
(
|
||||
fvm::Sp(alpha*rho*coeff, U) - alpha*rho*coeff*URef
|
||||
);
|
||||
eqn -= dampingEqn;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::acousticDampingSource::read(const dictionary& dict)
|
||||
{
|
||||
if (cellSetOption::read(dict))
|
||||
{
|
||||
if (coeffs_.found("UNames"))
|
||||
{
|
||||
coeffs_.lookup("UNames") >> fieldNames_;
|
||||
}
|
||||
else if (coeffs_.found("UName"))
|
||||
{
|
||||
word UName(coeffs_.lookup("UName"));
|
||||
fieldNames_ = wordList(1, UName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldNames_ = wordList(1, "U");
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
coeffs_.lookup("frequency") >> frequency_.value();
|
||||
coeffs_.lookup("URef") >> URefName_;
|
||||
coeffs_.lookup("centre") >> x0_;
|
||||
coeffs_.lookup("radius1") >> r1_;
|
||||
coeffs_.lookup("radius2") >> r2_;
|
||||
|
||||
if (coeffs_.readIfPresent("w", w_))
|
||||
{
|
||||
Info<< name_ << ": Setting stencil width to " << w_ << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,184 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ 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::acousticDampingSource
|
||||
|
||||
Group
|
||||
grpFvOptionsSources
|
||||
|
||||
Description
|
||||
Acoustic damping source
|
||||
|
||||
\heading Source usage
|
||||
|
||||
Example usage:
|
||||
\verbatim
|
||||
acousticDampingSourceCoeffs
|
||||
{
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
acousticDampingSource.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef acousticDampingSource_H
|
||||
#define acousticDampingSource_H
|
||||
|
||||
#include "cellSetOption.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class porosityModel;
|
||||
|
||||
namespace fv
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class acousticDampingSource Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class acousticDampingSource
|
||||
:
|
||||
public cellSetOption
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Frequency [Hz]
|
||||
dimensionedScalar frequency_;
|
||||
|
||||
//- Blending factor []
|
||||
volScalarField blendFactor_;
|
||||
|
||||
//- Name of reference velocity field
|
||||
word URefName_;
|
||||
|
||||
// Sphere centre location or damping
|
||||
point x0_;
|
||||
|
||||
// Inner radius at which to start damping
|
||||
scalar r1_;
|
||||
|
||||
// Outer radius beyond which damping is applied
|
||||
scalar r2_;
|
||||
|
||||
//- Stencil width, default = 20
|
||||
label w_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Helper function to set the blending factor
|
||||
void setBlendingFactor();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
acousticDampingSource(const acousticDampingSource&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const acousticDampingSource&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("acousticDampingSource");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
acousticDampingSource
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~acousticDampingSource()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Add explicit and implicit contributions
|
||||
|
||||
//- Add implicit contribution to momentum equation
|
||||
virtual void addSup
|
||||
(
|
||||
fvMatrix<vector>& eqn,
|
||||
const label fieldI
|
||||
);
|
||||
|
||||
//- Add implicit contribution to compressible momentum equation
|
||||
virtual void addSup
|
||||
(
|
||||
const volScalarField& rho,
|
||||
fvMatrix<vector>& eqn,
|
||||
const label fieldI
|
||||
);
|
||||
|
||||
//- Add implicit contribution 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
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user