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)";
<< tab
<< "local forces(pressure, viscous) local moment(pressure, viscous)" if (localSystem_)
<< endl; {
forcesFilePtr_()
<< tab
<< "local forces(pressure, viscous) "
<< "local moment(pressure, viscous)";
}
forcesFilePtr_()<< endl;
} }
} }
@ -413,33 +423,42 @@ void Foam::forces::write()
if (Pstream::master()) if (Pstream::master())
{ {
forcesMoments fmLocal;
fmLocal.first().first() =
coordSys_.localVector(fm.first().first());
fmLocal.first().second() =
coordSys_.localVector(fm.first().second());
fmLocal.second().first() =
coordSys_.localVector(fm.second().first());
fmLocal.second().second() =
coordSys_.localVector(fm.second().second());
forcesFilePtr_() << obr_.time().value()
<< tab << fm
<< tab << fmLocal << endl;
if (log_) if (log_)
{ {
Info<< "forces output:" << nl Info<< "forces output:" << nl
<< " forces(pressure, viscous)" << fm.first() << nl << " forces(pressure, viscous)" << fm.first() << nl
<< " moment(pressure, viscous)" << fm.second() << nl << " moment(pressure, viscous)" << fm.second() << nl;
<< " local:" << nl
<< " forces(pressure, viscous)" << fmLocal.first() << nl forcesFilePtr_() << obr_.time().value() << tab << fm;
<< " moment(pressure, viscous)" << fmLocal.second() << nl
<< endl; if (localSystem_)
{
forcesMoments fmLocal;
fmLocal.first().first() =
coordSys_.localVector(fm.first().first());
fmLocal.first().second() =
coordSys_.localVector(fm.first().second());
fmLocal.second().first() =
coordSys_.localVector(fm.second().first());
fmLocal.second().second() =
coordSys_.localVector(fm.second().second());
forcesFilePtr_() << tab << fmLocal;
Info<< " local:" << nl
<< " forces(pressure, viscous)" << fmLocal.first()
<< nl
<< " moment(pressure, viscous)" << fmLocal.second()
<< nl;
}
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_;