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),
pRef_(0),
coordSys_(),
localSystem_(false),
forcesFilePtr_(NULL)
{
// Check if the available mesh is an fvMesh otherise deactivate
@ -239,6 +240,7 @@ Foam::forces::forces
rhoRef_(rhoInf),
pRef_(pRef),
coordSys_(coordSys),
localSystem_(false),
forcesFilePtr_(NULL)
{}
@ -330,6 +332,7 @@ void Foam::forces::read(const dictionary& dict)
if (!dict.readIfPresent<point>("CofR", coordSys_.origin()))
{
coordSys_ = coordinateSystem(dict, obr_);
localSystem_ = true;
}
}
}
@ -382,10 +385,17 @@ void Foam::forces::writeFileHeader()
{
forcesFilePtr_()
<< "# Time" << tab
<< "forces(pressure, viscous) moment(pressure, viscous)"
<< tab
<< "local forces(pressure, viscous) local moment(pressure, viscous)"
<< endl;
<< "forces(pressure, viscous) moment(pressure, viscous)";
if (localSystem_)
{
forcesFilePtr_()
<< tab
<< "local forces(pressure, viscous) "
<< "local moment(pressure, viscous)";
}
forcesFilePtr_()<< endl;
}
}
@ -413,33 +423,42 @@ void Foam::forces::write()
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_)
{
Info<< "forces output:" << nl
<< " forces(pressure, viscous)" << fm.first() << nl
<< " moment(pressure, viscous)" << fm.second() << nl
<< " local:" << nl
<< " forces(pressure, viscous)" << fmLocal.first() << nl
<< " moment(pressure, viscous)" << fmLocal.second() << nl
<< endl;
<< " moment(pressure, viscous)" << fm.second() << nl;
forcesFilePtr_() << obr_.time().value() << tab << fm;
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
coordinateSystem coordSys_;
//- Flag to indicate whether we are using a local co-ordinate sys
bool localSystem_;
//- Forces/moment file ptr
autoPtr<OFstream> forcesFilePtr_;