mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Multiple updates to function objects
Updated objects
- corrected Peclet number for compressible cases
- propagated log flag and resultName across objects
New function objects
- new fluxSummary:
- calculates positive, negative, absolute and net flux across face
zones
- new runTimeControl
- abort the calculation when a user-defined metric is achieved.
Available options include:
- average value remains unchanged wrt a given threshold
- equation initial residual exceeds a threshold - useful to abort
diverging cases
- equation max iterations exceeds a threshold - useful to abort
diverging cases
- min/max of a function object value
- min time step exceeds a threshold - useful to abort diverging
cases
- new valueAverage:
- average singular values from other function objects, e.g. Cd, Cl and
Cm from the forceCoeffs function object
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,28 +37,6 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::pressureTools::pName() const
|
||||
{
|
||||
word fieldName = pName_;
|
||||
|
||||
if (calcTotal_)
|
||||
{
|
||||
fieldName = "total(" + fieldName + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = "static(" + fieldName + ")";
|
||||
}
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
fieldName = fieldName + "_coeff";
|
||||
}
|
||||
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionedScalar Foam::pressureTools::rhoScale
|
||||
(
|
||||
const volScalarField& p
|
||||
@ -86,7 +64,23 @@ Foam::tmp<Foam::volScalarField> Foam::pressureTools::rho
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
if (!rhoInfInitialised_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::tmp<Foam::volScalarField> Foam::pressureTools::rho"
|
||||
"("
|
||||
" const volScalarField&"
|
||||
") const"
|
||||
)
|
||||
<< type() << " " << name_ << ": "
|
||||
<< "pressure identified as incompressible, but reference "
|
||||
<< "density is not set. Please set rhoName to rhoInf, and "
|
||||
<< "set an appropriate value for rhoInf"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return
|
||||
tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
@ -193,12 +187,15 @@ Foam::pressureTools::pressureTools
|
||||
pName_("p"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
resultName_(word::null),
|
||||
log_(true),
|
||||
calcTotal_(false),
|
||||
pRef_(0.0),
|
||||
calcCoeff_(false),
|
||||
pInf_(0.0),
|
||||
UInf_(vector::zero),
|
||||
rhoInf_(0.0)
|
||||
rhoInf_(0.0),
|
||||
rhoInfInitialised_(false)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -236,7 +233,7 @@ Foam::pressureTools::pressureTools
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
pName(),
|
||||
resultName_,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
@ -264,13 +261,18 @@ void Foam::pressureTools::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_.readIfPresent("log", dict);
|
||||
|
||||
dict.readIfPresent("pName", pName_);
|
||||
dict.readIfPresent("UName", UName_);
|
||||
dict.readIfPresent("rhoName", rhoName_);
|
||||
|
||||
rhoInfInitialised_ = false;
|
||||
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
rhoInfInitialised_ = true;
|
||||
}
|
||||
|
||||
dict.lookup("calcTotal") >> calcTotal_;
|
||||
@ -296,6 +298,27 @@ void Foam::pressureTools::read(const dictionary& dict)
|
||||
<< "pressure level is zero. Please check the supplied "
|
||||
<< "values of pInf, UInf and rhoInf" << endl;
|
||||
}
|
||||
|
||||
rhoInfInitialised_ = true;
|
||||
}
|
||||
|
||||
if (!dict.readIfPresent("resultName", resultName_))
|
||||
{
|
||||
resultName_ = pName_;
|
||||
|
||||
if (calcTotal_)
|
||||
{
|
||||
resultName_ = "total(" + resultName_ + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
resultName_ = "static(" + resultName_ + ")";
|
||||
}
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
resultName_ = resultName_ + "_coeff";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,7 +333,7 @@ void Foam::pressureTools::execute()
|
||||
volScalarField& pResult =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
obr_.lookupObject<volScalarField>(pName())
|
||||
obr_.lookupObject<volScalarField>(resultName_)
|
||||
);
|
||||
|
||||
pResult == convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef());
|
||||
@ -338,9 +361,10 @@ void Foam::pressureTools::write()
|
||||
if (active_)
|
||||
{
|
||||
const volScalarField& pResult =
|
||||
obr_.lookupObject<volScalarField>(pName());
|
||||
obr_.lookupObject<volScalarField>(resultName_);
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
if (log_) Info
|
||||
<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << pResult.name() << nl
|
||||
<< endl;
|
||||
|
||||
|
||||
@ -101,6 +101,8 @@ Description
|
||||
pInf | Freestream pressure for coefficient calculation | no |
|
||||
UInf | Freestream velocity for coefficient calculation | no |
|
||||
rhoInf | Freestream density for coefficient calculation | no |
|
||||
resultName | Name of derived pressure field | no | auto generated
|
||||
log | log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
@ -114,6 +116,7 @@ SourceFiles
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "dimensionedScalar.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -152,6 +155,12 @@ class pressureTools
|
||||
//- Name of density field, default is "rho"
|
||||
word rhoName_;
|
||||
|
||||
//- Result name
|
||||
word resultName_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
|
||||
// Total pressure calculation
|
||||
|
||||
@ -176,13 +185,13 @@ class pressureTools
|
||||
//- Freestream density
|
||||
scalar rhoInf_;
|
||||
|
||||
//- Flag to show whether rhoInf has been initialised
|
||||
bool rhoInfInitialised_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return the name of the derived pressure field
|
||||
word pName() const;
|
||||
|
||||
//- Return the density scaling if supplied with kinematic pressure
|
||||
//- Return the density scale
|
||||
dimensionedScalar rhoScale(const volScalarField& p) const;
|
||||
|
||||
//- Return the density field
|
||||
|
||||
Reference in New Issue
Block a user