From d3f0cb33d98b261c41498b703aefb0383d8e8cab Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 1 Nov 2016 16:36:15 +0000 Subject: [PATCH] BUG: forces FO - corrected after bugs introduced by last merging effort --- src/functionObjects/forces/forces/forces.C | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 1a7018fb4c..8e1ed4abe7 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -180,7 +180,7 @@ void Foam::functionObjects::forces::initialise() if (!foundObject(fDName_)) { FatalErrorInFunction - << "Could not find " << fDName_ << " in database." + << "Could not find " << fDName_ << " in database" << exit(FatalError); } } @@ -194,14 +194,15 @@ void Foam::functionObjects::forces::initialise() ) { FatalErrorInFunction - << "Could not find " << UName_ << ", " << pName_ + << "Could not find U: " << UName_ << " or p:" << pName_ + << " in database" << exit(FatalError); } if (rhoName_ != "rhoInf" && !foundObject(rhoName_)) { FatalErrorInFunction - << "Could not find " << rhoName_ + << "Could not find rho:" << rhoName_ << exit(FatalError); } } @@ -269,13 +270,13 @@ void Foam::functionObjects::forces::initialiseBins() { binPoints_[i] = (i + 0.5)*binDir_*binDx_; } + } - // Allocate storage for forces and moments - forAll(force_, i) - { - force_[i].setSize(nBin_, vector::zero); - moment_[i].setSize(nBin_, vector::zero); - } + // Allocate storage for forces and moments + forAll(force_, i) + { + force_[i].setSize(nBin_, vector::zero); + moment_[i].setSize(nBin_, vector::zero); } } @@ -908,9 +909,10 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) } else if (nBin_ == 0) { + // Case of no bins equates to a single bin to collect all data nBin_ = 1; } - else if ((nBin_ == 0) || (nBin_ == 1)) + else { binDict.lookup("cumulative") >> binCumulative_; binDict.lookup("direction") >> binDir_; @@ -918,16 +920,6 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) } } - if (nBin_ == 1) - { - // Allocate storage for forces and moments - forAll(force_, i) - { - force_[i].setSize(1, vector::zero); - moment_[i].setSize(1, vector::zero); - } - } - writeFields_ = dict.lookupOrDefault("writeFields", false); if (writeFields_)