BUG: forces FO - corrected after bugs introduced by last merging effort

This commit is contained in:
Andrew Heather
2016-11-01 16:36:15 +00:00
parent c10177fc6f
commit d3f0cb33d9

View File

@ -180,7 +180,7 @@ void Foam::functionObjects::forces::initialise()
if (!foundObject<volVectorField>(fDName_)) if (!foundObject<volVectorField>(fDName_))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Could not find " << fDName_ << " in database." << "Could not find " << fDName_ << " in database"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -194,14 +194,15 @@ void Foam::functionObjects::forces::initialise()
) )
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Could not find " << UName_ << ", " << pName_ << "Could not find U: " << UName_ << " or p:" << pName_
<< " in database"
<< exit(FatalError); << exit(FatalError);
} }
if (rhoName_ != "rhoInf" && !foundObject<volScalarField>(rhoName_)) if (rhoName_ != "rhoInf" && !foundObject<volScalarField>(rhoName_))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Could not find " << rhoName_ << "Could not find rho:" << rhoName_
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -269,6 +270,7 @@ void Foam::functionObjects::forces::initialiseBins()
{ {
binPoints_[i] = (i + 0.5)*binDir_*binDx_; binPoints_[i] = (i + 0.5)*binDir_*binDx_;
} }
}
// Allocate storage for forces and moments // Allocate storage for forces and moments
forAll(force_, i) forAll(force_, i)
@ -277,7 +279,6 @@ void Foam::functionObjects::forces::initialiseBins()
moment_[i].setSize(nBin_, vector::zero); moment_[i].setSize(nBin_, vector::zero);
} }
} }
}
void Foam::functionObjects::forces::resetFields() void Foam::functionObjects::forces::resetFields()
@ -908,9 +909,10 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
} }
else if (nBin_ == 0) else if (nBin_ == 0)
{ {
// Case of no bins equates to a single bin to collect all data
nBin_ = 1; nBin_ = 1;
} }
else if ((nBin_ == 0) || (nBin_ == 1)) else
{ {
binDict.lookup("cumulative") >> binCumulative_; binDict.lookup("cumulative") >> binCumulative_;
binDict.lookup("direction") >> binDir_; 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); writeFields_ = dict.lookupOrDefault("writeFields", false);
if (writeFields_) if (writeFields_)