GIT: Initial state after latest Foundation merge
This commit is contained in:
4
src/functionObjects/forces/Make/files
Normal file
4
src/functionObjects/forces/Make/files
Normal file
@ -0,0 +1,4 @@
|
||||
forces/forces.C
|
||||
forceCoeffs/forceCoeffs.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libforces
|
||||
22
src/functionObjects/forces/Make/options
Normal file
22
src/functionObjects/forces/Make/options
Normal file
@ -0,0 +1,22 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfluidThermophysicalModels \
|
||||
-lincompressibleTransportModels \
|
||||
-lcompressibleTransportModels \
|
||||
-lturbulenceModels \
|
||||
-lincompressibleTurbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
-lspecie \
|
||||
-lfileFormats \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools
|
||||
431
src/functionObjects/forces/forceCoeffs/forceCoeffs.C
Normal file
431
src/functionObjects/forces/forceCoeffs/forceCoeffs.C
Normal file
@ -0,0 +1,431 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 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 "forceCoeffs.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "Pstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "fvMesh.H"
|
||||
#include "dimensionedTypes.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(forceCoeffs, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::forceCoeffs::createFiles()
|
||||
{
|
||||
// Note: Only possible to create bin files after bins have been initialised
|
||||
|
||||
if (writeToFile() && !coeffFilePtr_.valid())
|
||||
{
|
||||
coeffFilePtr_ = createFile("coefficient");
|
||||
writeIntegratedHeader("Coefficients", coeffFilePtr_());
|
||||
|
||||
if (nBin_ > 1)
|
||||
{
|
||||
CmBinFilePtr_ = createFile("CmBin");
|
||||
writeBinHeader("Moment coefficient bins", CmBinFilePtr_());
|
||||
CdBinFilePtr_ = createFile("CdBin");
|
||||
writeBinHeader("Drag coefficient bins", CdBinFilePtr_());
|
||||
ClBinFilePtr_ = createFile("ClBin");
|
||||
writeBinHeader("Lift coefficient bins", ClBinFilePtr_());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeIntegratedHeader
|
||||
(
|
||||
const word& header,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeHeader(os, "Force coefficients");
|
||||
writeHeaderValue(os, "liftDir", liftDir_);
|
||||
writeHeaderValue(os, "dragDir", dragDir_);
|
||||
writeHeaderValue(os, "pitchAxis", pitchAxis_);
|
||||
writeHeaderValue(os, "magUInf", magUInf_);
|
||||
writeHeaderValue(os, "lRef", lRef_);
|
||||
writeHeaderValue(os, "Aref", Aref_);
|
||||
writeHeaderValue(os, "CofR", coordSys_.origin());
|
||||
writeHeader(os, "");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "Cm");
|
||||
writeTabbed(os, "Cd");
|
||||
writeTabbed(os, "Cl");
|
||||
writeTabbed(os, "Cl(f)");
|
||||
writeTabbed(os, "Cl(r)");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeBinHeader
|
||||
(
|
||||
const word& header,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeHeader(os, header);
|
||||
writeHeaderValue(os, "bins", nBin_);
|
||||
writeHeaderValue(os, "start", binMin_);
|
||||
writeHeaderValue(os, "delta", binDx_);
|
||||
writeHeaderValue(os, "direction", binDir_);
|
||||
|
||||
vectorField binPoints(nBin_);
|
||||
writeCommented(os, "x co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
binPoints[pointI] = (binMin_ + (pointI + 1)*binDx_)*binDir_;
|
||||
os << tab << binPoints[pointI].x();
|
||||
}
|
||||
os << nl;
|
||||
|
||||
writeCommented(os, "y co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
os << tab << binPoints[pointI].y();
|
||||
}
|
||||
os << nl;
|
||||
|
||||
writeCommented(os, "z co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
os << tab << binPoints[pointI].z();
|
||||
}
|
||||
os << nl;
|
||||
|
||||
writeHeader(os, "");
|
||||
writeCommented(os, "Time");
|
||||
|
||||
for (label j = 0; j < nBin_; j++)
|
||||
{
|
||||
word jn(Foam::name(j) + ':');
|
||||
writeTabbed(os, jn + "total");
|
||||
writeTabbed(os, jn + "pressure");
|
||||
writeTabbed(os, jn + "viscous");
|
||||
|
||||
if (porosity_)
|
||||
{
|
||||
writeTabbed(os, jn + "porous");
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeIntegratedData
|
||||
(
|
||||
const word& title,
|
||||
const List<Field<scalar>>& coeff
|
||||
) const
|
||||
{
|
||||
scalar pressure = sum(coeff[0]);
|
||||
scalar viscous = sum(coeff[1]);
|
||||
scalar porous = sum(coeff[2]);
|
||||
scalar total = pressure + viscous + porous;
|
||||
|
||||
if (log)
|
||||
{
|
||||
Info<< " " << title << " : " << total << token::TAB
|
||||
<< "("
|
||||
<< "pressure: " << pressure << token::TAB
|
||||
<< "viscous: " << viscous;
|
||||
|
||||
if (porosity_)
|
||||
{
|
||||
Info<< token::TAB << "porous: " << porous;
|
||||
}
|
||||
|
||||
Info<< ")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeBinData
|
||||
(
|
||||
const List<Field<scalar>> coeffs,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << obr_.time().value();
|
||||
|
||||
for (label binI = 0; binI < nBin_; binI++)
|
||||
{
|
||||
scalar total = coeffs[0][binI] + coeffs[1][binI] + coeffs[2][binI];
|
||||
|
||||
os << tab << total << tab << coeffs[0][binI] << tab << coeffs[1][binI];
|
||||
|
||||
if (porosity_)
|
||||
{
|
||||
os << tab << coeffs[2][binI];
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::forceCoeffs::forceCoeffs
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
forces(name, runTime, dict),
|
||||
liftDir_(Zero),
|
||||
dragDir_(Zero),
|
||||
pitchAxis_(Zero),
|
||||
magUInf_(0.0),
|
||||
lRef_(0.0),
|
||||
Aref_(0.0),
|
||||
coeffFilePtr_(),
|
||||
CmBinFilePtr_(),
|
||||
CdBinFilePtr_(),
|
||||
ClBinFilePtr_()
|
||||
{
|
||||
read(dict);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::forceCoeffs::~forceCoeffs()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::forceCoeffs::read(const dictionary& dict)
|
||||
{
|
||||
forces::read(dict);
|
||||
|
||||
// Directions for lift and drag forces, and pitch moment
|
||||
dict.lookup("liftDir") >> liftDir_;
|
||||
dict.lookup("dragDir") >> dragDir_;
|
||||
dict.lookup("pitchAxis") >> pitchAxis_;
|
||||
|
||||
// Free stream velocity magnitude
|
||||
dict.lookup("magUInf") >> magUInf_;
|
||||
|
||||
// Reference length and area scales
|
||||
dict.lookup("lRef") >> lRef_;
|
||||
dict.lookup("Aref") >> Aref_;
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
tmp<volVectorField> tforceCoeff
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName("forceCoeff"),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("0", dimless, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
store(tforceCoeff.ptr());
|
||||
|
||||
tmp<volVectorField> tmomentCoeff
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName("momentCoeff"),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("0", dimless, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
store(tmomentCoeff.ptr());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::forceCoeffs::execute()
|
||||
{
|
||||
forces::calcForcesMoment();
|
||||
|
||||
createFiles();
|
||||
|
||||
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
|
||||
|
||||
// Storage for pressure, viscous and porous contributions to coeffs
|
||||
List<Field<scalar>> momentCoeffs(3);
|
||||
List<Field<scalar>> dragCoeffs(3);
|
||||
List<Field<scalar>> liftCoeffs(3);
|
||||
forAll(liftCoeffs, i)
|
||||
{
|
||||
momentCoeffs[i].setSize(nBin_);
|
||||
dragCoeffs[i].setSize(nBin_);
|
||||
liftCoeffs[i].setSize(nBin_);
|
||||
}
|
||||
|
||||
// Calculate coefficients
|
||||
scalar CmTot = 0;
|
||||
scalar CdTot = 0;
|
||||
scalar ClTot = 0;
|
||||
forAll(liftCoeffs, i)
|
||||
{
|
||||
momentCoeffs[i] = (moment_[i] & pitchAxis_)/(Aref_*pDyn*lRef_);
|
||||
dragCoeffs[i] = (force_[i] & dragDir_)/(Aref_*pDyn);
|
||||
liftCoeffs[i] = (force_[i] & liftDir_)/(Aref_*pDyn);
|
||||
|
||||
CmTot += sum(momentCoeffs[i]);
|
||||
CdTot += sum(dragCoeffs[i]);
|
||||
ClTot += sum(liftCoeffs[i]);
|
||||
}
|
||||
|
||||
scalar ClfTot = ClTot/2.0 + CmTot;
|
||||
scalar ClrTot = ClTot/2.0 - CmTot;
|
||||
|
||||
Log << type() << " " << name_ << " output:" << nl
|
||||
<< " Coefficients" << nl;
|
||||
|
||||
writeIntegratedData("Cm", momentCoeffs);
|
||||
writeIntegratedData("Cd", dragCoeffs);
|
||||
writeIntegratedData("Cl", liftCoeffs);
|
||||
|
||||
Log << " Cl(f) : " << ClfTot << nl
|
||||
<< " Cl(r) : " << ClrTot << nl
|
||||
<< endl;
|
||||
|
||||
if (writeToFile())
|
||||
{
|
||||
writeTime(coeffFilePtr_());
|
||||
coeffFilePtr_()
|
||||
<< tab << CmTot << tab << CdTot
|
||||
<< tab << ClTot << tab << ClfTot << tab << ClrTot << endl;
|
||||
|
||||
|
||||
if (nBin_ > 1)
|
||||
{
|
||||
if (binCumulative_)
|
||||
{
|
||||
forAll(liftCoeffs, i)
|
||||
{
|
||||
for (label binI = 1; binI < nBin_; binI++)
|
||||
{
|
||||
liftCoeffs[i][binI] += liftCoeffs[i][binI-1];
|
||||
dragCoeffs[i][binI] += dragCoeffs[i][binI-1];
|
||||
momentCoeffs[i][binI] += momentCoeffs[i][binI-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeBinData(dragCoeffs, CdBinFilePtr_());
|
||||
writeBinData(liftCoeffs, ClBinFilePtr_());
|
||||
writeBinData(momentCoeffs, CmBinFilePtr_());
|
||||
}
|
||||
}
|
||||
|
||||
// Write state/results information
|
||||
{
|
||||
setResult("Cm", CmTot);
|
||||
setResult("Cd", CdTot);
|
||||
setResult("Cl", ClTot);
|
||||
setResult("Cl(f)", ClfTot);
|
||||
setResult("Cl(r)", ClrTot);
|
||||
}
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const volVectorField& force =
|
||||
obr_.lookupObject<volVectorField>(fieldName("force"));
|
||||
|
||||
const volVectorField& moment =
|
||||
obr_.lookupObject<volVectorField>(fieldName("moment"));
|
||||
|
||||
volVectorField& forceCoeff =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
obr_.lookupObject<volVectorField>(fieldName("forceCoeff"))
|
||||
);
|
||||
|
||||
volVectorField& momentCoeff =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
obr_.lookupObject<volVectorField>(fieldName("momentCoeff"))
|
||||
);
|
||||
|
||||
dimensionedScalar f0("f0", dimForce, Aref_*pDyn);
|
||||
dimensionedScalar m0("m0", dimForce*dimLength, Aref_*lRef_*pDyn);
|
||||
|
||||
forceCoeff == force/f0;
|
||||
momentCoeff == moment/m0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::forceCoeffs::write()
|
||||
{
|
||||
if (writeFields_)
|
||||
{
|
||||
const volVectorField& forceCoeff =
|
||||
obr_.lookupObject<volVectorField>(fieldName("forceCoeff"));
|
||||
|
||||
const volVectorField& momentCoeff =
|
||||
obr_.lookupObject<volVectorField>(fieldName("momentCoeff"));
|
||||
|
||||
forceCoeff.write();
|
||||
momentCoeff.write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
248
src/functionObjects/forces/forceCoeffs/forceCoeffs.H
Normal file
248
src/functionObjects/forces/forceCoeffs/forceCoeffs.H
Normal file
@ -0,0 +1,248 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 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::forceCoeffs
|
||||
|
||||
Group
|
||||
grpForcesFunctionObjects
|
||||
|
||||
Description
|
||||
Extends the forces functionObject by providing lift, drag and moment
|
||||
coefficients. The data can optionally be output into bins, defined in a
|
||||
given direction.
|
||||
|
||||
The binned data provides the total and consitituent components per bin:
|
||||
- total coefficient
|
||||
- pressure coefficient contribution
|
||||
- viscous coefficient contribution
|
||||
- porous coefficient contribution
|
||||
|
||||
Data is written into multiple files in the
|
||||
postProcessing/\<functionObjectName\> directory:
|
||||
- coefficient.dat : integrated coefficients over all geometries
|
||||
- CmBin.dat : moment coefficient bins
|
||||
- CdBin.dat : drag coefficient bins
|
||||
- ClBin.dat : lift coefficient bins
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
forceCoeffs1
|
||||
{
|
||||
type forceCoeffs;
|
||||
libs ("libforces.so");
|
||||
...
|
||||
log yes;
|
||||
writeFields yes;
|
||||
patches (walls);
|
||||
liftDir (0 1 0);
|
||||
dragDir (-1 0 0);
|
||||
pitchAxis (0 0 1);
|
||||
magUInf 100;
|
||||
lRef 3.5;
|
||||
Aref 2.2;
|
||||
|
||||
binData
|
||||
{
|
||||
nBin 20;
|
||||
direction (1 0 0);
|
||||
cumulative yes;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: forces | yes |
|
||||
log | Write force data to standard output | no | no
|
||||
writeFields | Write the force and moment coefficient fields | no | no
|
||||
patches | Patches included in the forces calculation | yes |
|
||||
liftDir | Lift direction | yes |
|
||||
dragDir | Drag direction | yes |
|
||||
pitchAxis | Picth axis | yes |
|
||||
magUInf | Free stream velocity magnitude | yes |
|
||||
lRef | Reference length scale for moment calculations | yes |
|
||||
Aref | Reference area | yes |
|
||||
porosity | Flag to include porosity contributions | no | no
|
||||
\endtable
|
||||
|
||||
Bin data is optional, but if the dictionary is present, the entries must
|
||||
be defined according o
|
||||
\table
|
||||
nBin | number of data bins | yes |
|
||||
direction | direction along which bins are defined | yes |
|
||||
cumulative | bin data accumulated with incresing distance | yes |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::timeControl
|
||||
Foam::functionObjects::forces
|
||||
|
||||
SourceFiles
|
||||
forceCoeffs.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_forceCoeffs_H
|
||||
#define functionObjects_forceCoeffs_H
|
||||
|
||||
#include "forces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class forceCoeffs Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class forceCoeffs
|
||||
:
|
||||
public forces
|
||||
{
|
||||
// Private data
|
||||
|
||||
// Force coefficient geometry
|
||||
|
||||
//- Lift
|
||||
vector liftDir_;
|
||||
|
||||
//- Drag
|
||||
vector dragDir_;
|
||||
|
||||
//- Pitch
|
||||
vector pitchAxis_;
|
||||
|
||||
|
||||
// Free-stream conditions
|
||||
|
||||
//- Velocity magnitude
|
||||
scalar magUInf_;
|
||||
|
||||
|
||||
// Reference scales
|
||||
|
||||
//- Length
|
||||
scalar lRef_;
|
||||
|
||||
//- Area
|
||||
scalar Aref_;
|
||||
|
||||
|
||||
// File streams
|
||||
|
||||
//- Integrated coefficients
|
||||
autoPtr<OFstream> coeffFilePtr_;
|
||||
|
||||
//- Moment coefficient
|
||||
autoPtr<OFstream> CmBinFilePtr_;
|
||||
|
||||
//- Drag coefficient
|
||||
autoPtr<OFstream> CdBinFilePtr_;
|
||||
|
||||
//- Lift coefficient
|
||||
autoPtr<OFstream> ClBinFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
forceCoeffs(const forceCoeffs&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const forceCoeffs&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Create the output files
|
||||
void createFiles();
|
||||
|
||||
//- Write header for integrated data
|
||||
void writeIntegratedHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Write header for binned data
|
||||
void writeBinHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Write integrated data
|
||||
void writeIntegratedData
|
||||
(
|
||||
const word& title,
|
||||
const List<Field<scalar>>& coeff
|
||||
) const;
|
||||
|
||||
//- Write binned data
|
||||
void writeBinData(const List<Field<scalar>> coeffs, Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("forceCoeffs");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
forceCoeffs
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~forceCoeffs();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the forces data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the forces
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
1163
src/functionObjects/forces/forces/forces.C
Normal file
1163
src/functionObjects/forces/forces/forces.C
Normal file
File diff suppressed because it is too large
Load Diff
415
src/functionObjects/forces/forces/forces.H
Normal file
415
src/functionObjects/forces/forces/forces.H
Normal file
@ -0,0 +1,415 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 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::forces
|
||||
|
||||
Group
|
||||
grpForcesFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the forces and moments by integrating the pressure and
|
||||
skin-friction forces over a given list of patches, and the resistance
|
||||
from porous zones.
|
||||
|
||||
Forces and moments are calculated, with optional co-ordinate system and
|
||||
writing of binned data, where force and moment contributions are collected
|
||||
into a user-defined number of bins that span the input geometries for a
|
||||
user-defined direction vector.
|
||||
|
||||
Data is written into multiple files in the
|
||||
postProcessing/\<functionObjectName\> directory:
|
||||
- force.dat : forces in global Cartesian co-ordinate system
|
||||
- moment.dat : moments in global Cartesian co-ordinate system
|
||||
- forceBin.dat : force bins in global Cartesian co-ordinate system
|
||||
- momentBin.dat : moment bins in global Cartesian co-ordinate system
|
||||
- localForce.dat : forces in local co-ordinate system
|
||||
- localMoment.dat : moments in local co-ordinate system
|
||||
- localForceBin.dat : force bins in local co-ordinate system
|
||||
- localMomentBin.dat : moment bins in local co-ordinate system
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
forces1
|
||||
{
|
||||
type forces;
|
||||
libs ("libforces.so");
|
||||
...
|
||||
log yes;
|
||||
writeFields yes;
|
||||
patches (walls);
|
||||
|
||||
binData
|
||||
{
|
||||
nBin 20;
|
||||
direction (1 0 0);
|
||||
cumulative yes;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: forces | yes |
|
||||
log | Write force data to standard output | no | no
|
||||
writeFields | Write the force and moment fields | no | no
|
||||
patches | Patches included in the forces calculation | yes |
|
||||
p | Pressure field name | no | p
|
||||
U | Velocity field name | no | U
|
||||
rho | Density field name (see below) | no | rho
|
||||
CofR | Centre of rotation (see below) | no |
|
||||
porosity | flag to include porosity contributions | no | no
|
||||
directForceDensity | Force density supplied directly (see below)|no|no
|
||||
fD | Name of force density field (see below) | no | fD
|
||||
\endtable
|
||||
|
||||
Bin data is optional, but if the dictionary is present, the entries must
|
||||
be defined according o
|
||||
\table
|
||||
nBin | number of data bins | yes |
|
||||
direction | direction along which bins are defined | yes |
|
||||
cumulative | bin data accumulated with incresing distance | yes |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
- For incompressible cases, set \c rho to \c rhoInf. You will then be
|
||||
required to provide a \c rhoInf value corresponding to the free-stream
|
||||
constant density.
|
||||
- If the force density is supplied directly, set the \c directForceDensity
|
||||
flag to 'yes', and supply the force density field using the \c
|
||||
fDName entry
|
||||
- The centre of rotation (CofR) for moment calculations can either be
|
||||
specified by an \c CofR entry, or be taken from origin of the local
|
||||
coordinate system. For example,
|
||||
\verbatim
|
||||
CofR (0 0 0);
|
||||
\endverbatim
|
||||
or
|
||||
\verbatim
|
||||
coordinateSystem
|
||||
{
|
||||
origin (0 0 0);
|
||||
e3 (0 0 1);
|
||||
e1 (1 0 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
forces.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_forces_H
|
||||
#define functionObjects_forces_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
#include "Tuple2.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class forces Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class forces
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Pressure, viscous and porous force per bin
|
||||
List<Field<vector>> force_;
|
||||
|
||||
//- Pressure, viscous and porous moment per bin
|
||||
List<Field<vector>> moment_;
|
||||
|
||||
// File streams
|
||||
|
||||
//- Forces
|
||||
autoPtr<OFstream> forceFilePtr_;
|
||||
|
||||
//- Moments
|
||||
autoPtr<OFstream> momentFilePtr_;
|
||||
|
||||
//- Force bins
|
||||
autoPtr<OFstream> forceBinFilePtr_;
|
||||
|
||||
//- Moment bins
|
||||
autoPtr<OFstream> momentBinFilePtr_;
|
||||
|
||||
//- Local force
|
||||
autoPtr<OFstream> localForceFilePtr_;
|
||||
|
||||
//- Local moment
|
||||
autoPtr<OFstream> localMomentFilePtr_;
|
||||
|
||||
//- Local force bins
|
||||
autoPtr<OFstream> localForceBinFilePtr_;
|
||||
|
||||
//- Local moment bins
|
||||
autoPtr<OFstream> localMomentBinFilePtr_;
|
||||
|
||||
|
||||
// Read from dictionary
|
||||
|
||||
//- Patches to integrate forces over
|
||||
labelHashSet patchSet_;
|
||||
|
||||
//- Name of pressure field
|
||||
word pName_;
|
||||
|
||||
//- Name of velocity field
|
||||
word UName_;
|
||||
|
||||
//- Name of density field (optional)
|
||||
word rhoName_;
|
||||
|
||||
//- Is the force density being supplied directly?
|
||||
Switch directForceDensity_;
|
||||
|
||||
//- The name of the force density (fD) field
|
||||
word fDName_;
|
||||
|
||||
//- Reference density needed for incompressible calculations
|
||||
scalar rhoRef_;
|
||||
|
||||
//- Reference pressure
|
||||
scalar pRef_;
|
||||
|
||||
//- Coordinate system used when evaluting forces/moments
|
||||
coordinateSystem coordSys_;
|
||||
|
||||
//- Flag to indicate whether we are using a local co-ordinate sys
|
||||
bool localSystem_;
|
||||
|
||||
//- Flag to include porosity effects
|
||||
bool porosity_;
|
||||
|
||||
|
||||
// Bin information
|
||||
|
||||
//- Number of bins
|
||||
label nBin_;
|
||||
|
||||
//- Direction used to determine bin orientation
|
||||
vector binDir_;
|
||||
|
||||
//- Distance between bin divisions
|
||||
scalar binDx_;
|
||||
|
||||
//- Minimum bin bounds
|
||||
scalar binMin_;
|
||||
|
||||
//- Bin positions along binDir
|
||||
List<point> binPoints_;
|
||||
|
||||
//- Should bin data be cumulative?
|
||||
bool binCumulative_;
|
||||
|
||||
|
||||
//- Write fields flag
|
||||
bool writeFields_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Create a field name
|
||||
word fieldName(const word& name) const;
|
||||
|
||||
//- Create the output files
|
||||
void createFiles();
|
||||
|
||||
//- Write header for integrated data
|
||||
void writeIntegratedHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Write header for binned data
|
||||
void writeBinHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Initialise the fields
|
||||
void initialise();
|
||||
|
||||
//- Initialise the collection bins
|
||||
void initialiseBins();
|
||||
|
||||
//- Reset the fields prior to accumulation of force/moments
|
||||
void resetFields();
|
||||
|
||||
//- Return the effective viscous stress (laminar + turbulent).
|
||||
tmp<volSymmTensorField> devRhoReff() const;
|
||||
|
||||
//- Dynamic viscosity field
|
||||
tmp<volScalarField> mu() const;
|
||||
|
||||
//- Return rho if specified otherwise rhoRef
|
||||
tmp<volScalarField> rho() const;
|
||||
|
||||
//- Return rhoRef if the pressure field is dynamic, i.e. p/rho
|
||||
// otherwise return 1
|
||||
scalar rho(const volScalarField& p) const;
|
||||
|
||||
//- Accumulate bin data
|
||||
void applyBins
|
||||
(
|
||||
const vectorField& Md,
|
||||
const vectorField& fN,
|
||||
const vectorField& fT,
|
||||
const vectorField& fP,
|
||||
const vectorField& d
|
||||
);
|
||||
|
||||
//- Add patch contributions to force and moment fields
|
||||
void addToFields
|
||||
(
|
||||
const label patchI,
|
||||
const vectorField& Md,
|
||||
const vectorField& fN,
|
||||
const vectorField& fT,
|
||||
const vectorField& fP
|
||||
);
|
||||
|
||||
//- Add cell contributions to force and moment fields
|
||||
void addToFields
|
||||
(
|
||||
const labelList& cellIDs,
|
||||
const vectorField& Md,
|
||||
const vectorField& fN,
|
||||
const vectorField& fT,
|
||||
const vectorField& fP
|
||||
);
|
||||
|
||||
//- Helper function to write integrated forces and moments
|
||||
void writeIntegratedForceMoment
|
||||
(
|
||||
const string& descriptor,
|
||||
const vectorField& fm0,
|
||||
const vectorField& fm1,
|
||||
const vectorField& fm2,
|
||||
autoPtr<OFstream>& osPtr
|
||||
) const;
|
||||
|
||||
//- Write force data
|
||||
void writeForces();
|
||||
|
||||
//- Helper function to write binned forces and moments
|
||||
void writeBinnedForceMoment
|
||||
(
|
||||
const List<Field<vector>>& fm,
|
||||
autoPtr<OFstream>& osPtr
|
||||
) const;
|
||||
|
||||
//- Write binned data
|
||||
void writeBins();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
forces(const forces&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const forces&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("forces");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
forces
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from objectRegistry and dictionary
|
||||
forces
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~forces();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the forces data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the forces and moments
|
||||
virtual void calcForcesMoment();
|
||||
|
||||
//- Return the total force
|
||||
virtual vector forceEff() const;
|
||||
|
||||
//- Return the total moment
|
||||
virtual vector momentEff() const;
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the forces
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
33
src/functionObjects/forces/forcesFunctionObjectsDoc.H
Normal file
33
src/functionObjects/forces/forcesFunctionObjectsDoc.H
Normal file
@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 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/>.
|
||||
|
||||
\defgroup grpForcesFunctionObjects Forces function objects
|
||||
@{
|
||||
\ingroup grpFunctionObjects
|
||||
This group contains force-based function objects
|
||||
|
||||
Function objects in this group are packaged into the
|
||||
libforcesFunctionObjects.so library.
|
||||
@}
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
Reference in New Issue
Block a user