mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Only output local forces/moments when needed
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user