ENH: Only output local forces/moments when needed

This commit is contained in:
andy
2011-09-19 17:56:42 +01:00
parent 36ee6e8262
commit 295c6176f2
2 changed files with 49 additions and 27 deletions

View File

@ -190,6 +190,7 @@ Foam::forces::forces
rhoRef_(VGREAT), rhoRef_(VGREAT),
pRef_(0), pRef_(0),
coordSys_(), coordSys_(),
localSystem_(false),
forcesFilePtr_(NULL) forcesFilePtr_(NULL)
{ {
// Check if the available mesh is an fvMesh otherise deactivate // Check if the available mesh is an fvMesh otherise deactivate
@ -239,6 +240,7 @@ Foam::forces::forces
rhoRef_(rhoInf), rhoRef_(rhoInf),
pRef_(pRef), pRef_(pRef),
coordSys_(coordSys), coordSys_(coordSys),
localSystem_(false),
forcesFilePtr_(NULL) forcesFilePtr_(NULL)
{} {}
@ -330,6 +332,7 @@ void Foam::forces::read(const dictionary& dict)
if (!dict.readIfPresent<point>("CofR", coordSys_.origin())) if (!dict.readIfPresent<point>("CofR", coordSys_.origin()))
{ {
coordSys_ = coordinateSystem(dict, obr_); coordSys_ = coordinateSystem(dict, obr_);
localSystem_ = true;
} }
} }
} }
@ -382,10 +385,17 @@ void Foam::forces::writeFileHeader()
{ {
forcesFilePtr_() forcesFilePtr_()
<< "# Time" << tab << "# Time" << tab
<< "forces(pressure, viscous) moment(pressure, viscous)" << "forces(pressure, viscous) moment(pressure, viscous)";
if (localSystem_)
{
forcesFilePtr_()
<< tab << tab
<< "local forces(pressure, viscous) local moment(pressure, viscous)" << "local forces(pressure, viscous) "
<< endl; << "local moment(pressure, viscous)";
}
forcesFilePtr_()<< endl;
} }
} }
@ -412,6 +422,16 @@ void Foam::forces::write()
forcesMoments fm = calcForcesMoment(); forcesMoments fm = calcForcesMoment();
if (Pstream::master()) if (Pstream::master())
{
if (log_)
{
Info<< "forces output:" << nl
<< " forces(pressure, viscous)" << fm.first() << nl
<< " moment(pressure, viscous)" << fm.second() << nl;
forcesFilePtr_() << obr_.time().value() << tab << fm;
if (localSystem_)
{ {
forcesMoments fmLocal; forcesMoments fmLocal;
@ -427,19 +447,18 @@ void Foam::forces::write()
fmLocal.second().second() = fmLocal.second().second() =
coordSys_.localVector(fm.second().second()); coordSys_.localVector(fm.second().second());
forcesFilePtr_() << obr_.time().value() forcesFilePtr_() << tab << fmLocal;
<< tab << fm
<< tab << fmLocal << endl;
if (log_)
{ Info<< " local:" << nl
Info<< "forces output:" << nl << " forces(pressure, viscous)" << fmLocal.first()
<< " forces(pressure, viscous)" << fm.first() << nl << nl
<< " moment(pressure, viscous)" << fm.second() << nl << " moment(pressure, viscous)" << fmLocal.second()
<< " local:" << nl << nl;
<< " forces(pressure, viscous)" << fmLocal.first() << nl }
<< " moment(pressure, viscous)" << fmLocal.second() << nl
<< endl; forcesFilePtr_() << endl;
Info<< endl;
} }
} }
} }

View File

@ -165,6 +165,9 @@ protected:
//- Coordinate system used when evaluting forces/moments //- Coordinate system used when evaluting forces/moments
coordinateSystem coordSys_; coordinateSystem coordSys_;
//- Flag to indicate whether we are using a local co-ordinate sys
bool localSystem_;
//- Forces/moment file ptr //- Forces/moment file ptr
autoPtr<OFstream> forcesFilePtr_; autoPtr<OFstream> forcesFilePtr_;