diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index ce38948089..83c26373b2 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -178,6 +178,17 @@ void Foam::forceCoeffs::write() } OFstream osCoeffs(forcesDir/"forceCoeffs_bins"); + + if (binCumulative_) + { + for (label i = 1; i < coeffs[0].size(); i++) + { + coeffs[0][i] += coeffs[0][i-1]; + coeffs[1][i] += coeffs[1][i-1]; + coeffs[2][i] += coeffs[2][i-1]; + } + } + binWriterPtr->write(axis, fieldNames, coeffs, osCoeffs); } diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 5b944cc234..0005e88730 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -241,11 +241,25 @@ void Foam::forces::writeBins() const wordList fieldNames(IStringStream("(pressure viscous)")()); + List > f(force_); + List > m(moment_); + + if (binCumulative_) + { + for (label i = 1; i < f[0].size(); i++) + { + f[0][i] += f[0][i-1]; + f[1][i] += f[1][i-1]; + m[0][i] += m[0][i-1]; + m[1][i] += m[1][i-1]; + } + } + OFstream osForce(forcesDir/"force_bins"); - binWriterPtr->write(axis, fieldNames, force_, osForce); + binWriterPtr->write(axis, fieldNames, f, osForce); OFstream osMoment(forcesDir/"moment_bins"); - binWriterPtr->write(axis, fieldNames, moment_, osMoment); + binWriterPtr->write(axis, fieldNames, m, osMoment); if (localSystem_) @@ -257,6 +271,17 @@ void Foam::forces::writeBins() const localMoment[0] = coordSys_.localVector(moment_[0]); localMoment[1] = coordSys_.localVector(moment_[1]); + if (binCumulative_) + { + for (label i = 1; i < localForce[0].size(); i++) + { + localForce[0][i] += localForce[0][i-1]; + localForce[1][i] += localForce[1][i-1]; + localMoment[0][i] += localMoment[0][i-1]; + localMoment[1][i] += localMoment[1][i-1]; + } + } + OFstream osLocalForce(forcesDir/"force_local"); binWriterPtr->write(axis, fieldNames, localForce, osLocalForce); @@ -298,7 +323,8 @@ Foam::forces::forces binDx_(0.0), binMin_(GREAT), binPoints_(), - binFormat_("undefined") + binFormat_("undefined"), + binCumulative_(true) { // Check if the available mesh is an fvMesh otherise deactivate if (!isA(obr_)) @@ -356,7 +382,8 @@ Foam::forces::forces binDx_(0.0), binMin_(GREAT), binPoints_(), - binFormat_("undefined") + binFormat_("undefined"), + binCumulative_(true) {} @@ -448,9 +475,11 @@ void Foam::forces::read(const dictionary& dict) localSystem_ = true; } - // read bin information if present - if (dict.readIfPresent