mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-proudmann-fo' into 'develop'
ENH: Added new function object to compute the Proudman acoustic power See merge request Development/openfoam!303
This commit is contained in:
@ -34,6 +34,7 @@ nearWallFields/findCellParticle.C
|
|||||||
nearWallFields/findCellParticleCloud.C
|
nearWallFields/findCellParticleCloud.C
|
||||||
|
|
||||||
processorField/processorField.C
|
processorField/processorField.C
|
||||||
|
proudmanAcousticPower/proudmanAcousticPower.C
|
||||||
readFields/readFields.C
|
readFields/readFields.C
|
||||||
|
|
||||||
setFlow/setFlow.C
|
setFlow/setFlow.C
|
||||||
|
|||||||
@ -0,0 +1,226 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "proudmanAcousticPower.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "basicThermo.H"
|
||||||
|
#include "turbulenceModel.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(proudmanAcousticPower, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
functionObject,
|
||||||
|
proudmanAcousticPower,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::tmp<Foam::volScalarField>
|
||||||
|
Foam::functionObjects::proudmanAcousticPower::rhoScale
|
||||||
|
(
|
||||||
|
const tmp<volScalarField>& fld
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const basicThermo* thermoPtr =
|
||||||
|
getObjectPtr<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
if (thermoPtr)
|
||||||
|
{
|
||||||
|
return fld*thermoPtr->rho();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhoInf_.value() < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< type() << " " << name() << ": "
|
||||||
|
<< "Incompressible calculation assumed, but no reference density "
|
||||||
|
<< "set. Please set the entry 'rhoInf' to an appropriate value"
|
||||||
|
<< nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rhoInf_*fld;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::volScalarField>
|
||||||
|
Foam::functionObjects::proudmanAcousticPower::a() const
|
||||||
|
{
|
||||||
|
const basicThermo* thermoPtr =
|
||||||
|
getObjectPtr<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
if (thermoPtr)
|
||||||
|
{
|
||||||
|
const basicThermo& thermo = *thermoPtr;
|
||||||
|
return sqrt(thermo.gamma()*thermo.p()/thermo.rho());
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
tmp<volScalarField>::New
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
scopedName("a"),
|
||||||
|
mesh_.time().timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
aRef_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::proudmanAcousticPower::proudmanAcousticPower
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
|
rhoInf_("0", dimDensity, -1),
|
||||||
|
aRef_(dimVelocity, Zero),
|
||||||
|
alphaEps_(0.1)
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
|
||||||
|
volScalarField* PAPtr
|
||||||
|
(
|
||||||
|
new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
scopedName("P_A"),
|
||||||
|
mesh_.time().timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
dimensionedScalar(dimPower/dimVolume, Zero)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
PAPtr->store();
|
||||||
|
|
||||||
|
volScalarField* LPPtr
|
||||||
|
(
|
||||||
|
new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
scopedName("L_P"),
|
||||||
|
mesh_.time().timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
dimensionedScalar(dimless, Zero)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
LPPtr->store();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::proudmanAcousticPower::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (fvMeshFunctionObject::read(dict))
|
||||||
|
{
|
||||||
|
rhoInf_.readIfPresent("rhoInf", dict);
|
||||||
|
aRef_.readIfPresent("aRef", dict);
|
||||||
|
dict.readIfPresent("alphaEps", alphaEps_);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::proudmanAcousticPower::execute()
|
||||||
|
{
|
||||||
|
const turbulenceModel& turb =
|
||||||
|
lookupObject<turbulenceModel>(turbulenceModel::propertiesName);
|
||||||
|
|
||||||
|
const volScalarField Mt(sqrt(2*turb.k())/a());
|
||||||
|
|
||||||
|
volScalarField& P_A =
|
||||||
|
mesh_.lookupObjectRef<volScalarField>(scopedName("P_A"));
|
||||||
|
|
||||||
|
P_A = rhoScale(alphaEps_*turb.epsilon()*pow5(Mt));
|
||||||
|
|
||||||
|
volScalarField& L_P =
|
||||||
|
mesh_.lookupObjectRef<volScalarField>(scopedName("L_P"));
|
||||||
|
|
||||||
|
L_P = 10*log10(P_A/dimensionedScalar("PRef", dimPower/dimVolume, 1e-12));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::proudmanAcousticPower::write()
|
||||||
|
{
|
||||||
|
Log << type() << " " << name() << " write:" << nl;
|
||||||
|
|
||||||
|
const volScalarField& P_A =
|
||||||
|
mesh_.lookupObject<volScalarField>(scopedName("P_A"));
|
||||||
|
|
||||||
|
Log << " writing field " << P_A.name() << nl;
|
||||||
|
|
||||||
|
P_A.write();
|
||||||
|
|
||||||
|
const volScalarField& L_P =
|
||||||
|
mesh_.lookupObject<volScalarField>(scopedName("L_P"));
|
||||||
|
|
||||||
|
Log << " writing field " << L_P.name() << nl;
|
||||||
|
|
||||||
|
L_P.write();
|
||||||
|
|
||||||
|
Log << endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,183 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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::functionObjects::proudmanAcousticPower
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates the acoustic power due to the volume of isotropic turbulence
|
||||||
|
using Proudman's formula
|
||||||
|
|
||||||
|
The acoustic power \f$ P_A \f$ [W/m3] in terms of turbulence \f$ k \f$
|
||||||
|
and \f$ \epsilon \f$ is given as:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
P_A = alpha_\epsilon \rho \epsilon M_t^5
|
||||||
|
\f]
|
||||||
|
|
||||||
|
where \f$ alpha_\epsilon \f$ is a constant (0.1) and
|
||||||
|
|
||||||
|
\f[
|
||||||
|
M_t = \frac{\sqrt{2 k}}{a_0}
|
||||||
|
\f]
|
||||||
|
|
||||||
|
with \f$ a_0 \f$ the speed of sound. The acoustic power is also output in
|
||||||
|
dB using:
|
||||||
|
|
||||||
|
\f[
|
||||||
|
L_P = 10 \log \frac{P_A}{P_ref}
|
||||||
|
\f]
|
||||||
|
|
||||||
|
where \f$ P_ref \f$ is a constant (1e-12 W/m3)
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Example of function object specification to calculate the Proudman acoustic
|
||||||
|
power:
|
||||||
|
\verbatim
|
||||||
|
proudmanAcousticPower1
|
||||||
|
{
|
||||||
|
type proudmanAcousticPower;
|
||||||
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
...
|
||||||
|
|
||||||
|
// Required additional entries for incompressible calculations
|
||||||
|
rhoInf 1.225;
|
||||||
|
aRef 340;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
Where the entries comprise:
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default
|
||||||
|
type | type name: proudmanAcousticPower | yes |
|
||||||
|
rhoInf | Freestream density (for incompressible) | no |
|
||||||
|
aRef | Reference speed of sound (for incompressible) | no |
|
||||||
|
alphaEps | Model coefficient | no | 0.1
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
Note
|
||||||
|
The freestream density and reference speed of sound are only necessary
|
||||||
|
when a thermodynamics package is unavailable, typically for incompressible
|
||||||
|
cases.
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::functionObjects::fvMeshFunctionObject
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
proudmanAcousticPower.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_proudmanAcousticPower_H
|
||||||
|
#define functionObjects_proudmanAcousticPower_H
|
||||||
|
|
||||||
|
#include "fvMeshFunctionObject.H"
|
||||||
|
#include "volFieldsFwd.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class proudmanAcousticPower Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class proudmanAcousticPower
|
||||||
|
:
|
||||||
|
public fvMeshFunctionObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Freestream density (incompressible calcs only)
|
||||||
|
dimensionedScalar rhoInf_;
|
||||||
|
|
||||||
|
//- Reference speed of sound (incompressible calcs only)
|
||||||
|
dimensionedScalar aRef_;
|
||||||
|
|
||||||
|
//- Model coefficient; default = 0.1
|
||||||
|
scalar alphaEps_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Multiply the field by density and return
|
||||||
|
tmp<volScalarField> rhoScale(const tmp<volScalarField>& fld) const;
|
||||||
|
|
||||||
|
//- Speed of sound
|
||||||
|
tmp<volScalarField> a() const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("proudmanAcousticPower");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary
|
||||||
|
proudmanAcousticPower
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~proudmanAcousticPower() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Read the Proudman acoustic power data
|
||||||
|
virtual bool read(const dictionary&);
|
||||||
|
|
||||||
|
//- Calculate the Proudman acoustic power
|
||||||
|
virtual bool execute();
|
||||||
|
|
||||||
|
//- Write the Proudman acoustic power
|
||||||
|
virtual bool write();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user