mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: forceCoeffs function object - added data output into bins
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,6 +27,7 @@ License
|
|||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "Pstream.H"
|
#include "Pstream.H"
|
||||||
|
#include "IOmanip.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -89,7 +90,8 @@ void Foam::forceCoeffs::writeFileHeader()
|
|||||||
if (forcesFilePtr_.valid())
|
if (forcesFilePtr_.valid())
|
||||||
{
|
{
|
||||||
forcesFilePtr_()
|
forcesFilePtr_()
|
||||||
<< "# Time" << tab << "Cd" << tab << "Cl" << tab << "Cm" << endl;
|
<< "# Time" << tab << "Cm" << tab << "Cd" << tab << "Cl" << tab
|
||||||
|
<< "Cl(f)" << "Cl(r)" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,37 +114,77 @@ void Foam::forceCoeffs::write()
|
|||||||
{
|
{
|
||||||
// Create the forces file if not already created
|
// Create the forces file if not already created
|
||||||
makeFile();
|
makeFile();
|
||||||
|
forces::calcForcesMoment();
|
||||||
forcesMoments fm = forces::calcForcesMoment();
|
|
||||||
|
|
||||||
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
|
|
||||||
|
|
||||||
vector totForce = fm.first().first() + fm.first().second();
|
|
||||||
vector totMoment = fm.second().first() + fm.second().second();
|
|
||||||
|
|
||||||
scalar liftForce = totForce & liftDir_;
|
|
||||||
scalar dragForce = totForce & dragDir_;
|
|
||||||
scalar pitchMoment = totMoment & pitchAxis_;
|
|
||||||
|
|
||||||
scalar Cl = liftForce/(Aref_*pDyn);
|
|
||||||
scalar Cd = dragForce/(Aref_*pDyn);
|
|
||||||
scalar Cm = pitchMoment/(Aref_*lRef_*pDyn);
|
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
|
||||||
|
|
||||||
|
Field<vector> totForce(force_[0] + force_[1]);
|
||||||
|
Field<vector> totMoment(moment_[0] + moment_[1]);
|
||||||
|
|
||||||
|
List<Field<scalar> > coeffs(3);
|
||||||
|
coeffs[0].setSize(nBin_);
|
||||||
|
coeffs[1].setSize(nBin_);
|
||||||
|
coeffs[2].setSize(nBin_);
|
||||||
|
|
||||||
|
// lift, drag and moment
|
||||||
|
coeffs[0] = (totForce & liftDir_)/(Aref_*pDyn);
|
||||||
|
coeffs[1] = (totForce & dragDir_)/(Aref_*pDyn);
|
||||||
|
coeffs[2] = (totMoment & pitchAxis_)/(Aref_*lRef_*pDyn);
|
||||||
|
|
||||||
|
scalar Cl = sum(coeffs[0]);
|
||||||
|
scalar Cd = sum(coeffs[1]);
|
||||||
|
scalar Cm = sum(coeffs[2]);
|
||||||
|
|
||||||
|
scalar Clf = Cl/2.0 - Cm;
|
||||||
|
scalar Clr = Cl/2.0 + Cm;
|
||||||
|
|
||||||
forcesFilePtr_()
|
forcesFilePtr_()
|
||||||
<< obr_.time().value() << tab
|
<< obr_.time().value() << tab
|
||||||
<< Cd << tab << Cl << tab << Cm << endl;
|
<< Cm << tab << Cd << tab << Cl << tab << Clf << tab << Clr
|
||||||
|
<< endl;
|
||||||
|
|
||||||
if (log_)
|
if (log_)
|
||||||
{
|
{
|
||||||
Info<< "forceCoeffs output:" << nl
|
Info<< type() << " output:" << nl
|
||||||
<< " Cm = " << Cm << nl
|
<< " Cm = " << Cm << nl
|
||||||
<< " Cd = " << Cd << nl
|
<< " Cd = " << Cd << nl
|
||||||
<< " Cl = " << Cl << nl
|
<< " Cl = " << Cl << nl
|
||||||
<< " Cl(f) = " << Cl/2.0 - Cm << nl
|
<< " Cl(f) = " << Clf << nl
|
||||||
<< " Cl(r) = " << Cl/2.0 + Cm << nl
|
<< " Cl(r) = " << Clr << endl;
|
||||||
<< endl;
|
}
|
||||||
|
|
||||||
|
if (nBin_ > 1)
|
||||||
|
{
|
||||||
|
autoPtr<writer<scalar> >
|
||||||
|
binWriterPtr(writer<scalar>::New(binFormat_));
|
||||||
|
wordList fieldNames(IStringStream("(lift drag moment)")());
|
||||||
|
|
||||||
|
coordSet axis
|
||||||
|
(
|
||||||
|
"forceCoeffs",
|
||||||
|
"distance",
|
||||||
|
binPoints_,
|
||||||
|
mag(binPoints_)
|
||||||
|
);
|
||||||
|
|
||||||
|
fileName forcesDir =
|
||||||
|
baseFileDir()/"bins"/obr_.time().timeName();
|
||||||
|
mkDir(forcesDir);
|
||||||
|
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
Info<< " Writing bins to " << forcesDir << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
OFstream osCoeffs(forcesDir/"forceCoeffs");
|
||||||
|
binWriterPtr->write(axis, fieldNames, coeffs, osCoeffs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
Info<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -26,7 +26,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
Derived from the forces function object, creates a specialisation to
|
Derived from the forces function object, creates a specialisation to
|
||||||
calculate lift and drag forces.
|
calculate lift, drag and moment coefficients.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
forceCoeffs.C
|
forceCoeffs.C
|
||||||
@ -81,6 +81,12 @@ class forceCoeffs
|
|||||||
scalar Aref_;
|
scalar Aref_;
|
||||||
|
|
||||||
|
|
||||||
|
// Bin information
|
||||||
|
|
||||||
|
//- Writer for bin data
|
||||||
|
autoPtr<writer<scalar> > binWriterPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
|
|||||||
Reference in New Issue
Block a user