BUG: forces/forceCoeffs - corrected behaviour for case that input fields are not available. Fixes #107

This commit is contained in:
Andrew Heather
2016-04-28 14:23:38 +01:00
parent 200c490f44
commit cfcaaa85e4
2 changed files with 15 additions and 9 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -219,7 +219,7 @@ Foam::forceCoeffs::forceCoeffs
CdBinFilePtr_(), CdBinFilePtr_(),
ClBinFilePtr_() ClBinFilePtr_()
{ {
if (readFields) if (active_ && readFields)
{ {
read(dict); read(dict);
if (log_) Info << endl; if (log_) Info << endl;
@ -310,6 +310,12 @@ void Foam::forceCoeffs::execute()
forces::calcForcesMoment(); forces::calcForcesMoment();
// Need to re-check active_ flag - may have been reset in calcForcesMoment
if (!active_)
{
return;
}
createFiles(); createFiles();
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_; scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -279,8 +279,8 @@ void Foam::forces::initialiseBins()
// Allocate storage for forces and moments // Allocate storage for forces and moments
forAll(force_, i) forAll(force_, i)
{ {
force_[i].setSize(nBin_); force_[i].setSize(nBin_, vector::zero);
moment_[i].setSize(nBin_); moment_[i].setSize(nBin_, vector::zero);
} }
} }
} }
@ -841,8 +841,8 @@ Foam::forces::forces
forAll(force_, i) forAll(force_, i)
{ {
force_[i].setSize(nBin_); force_[i].setSize(nBin_, vector::zero);
moment_[i].setSize(nBin_); moment_[i].setSize(nBin_, vector::zero);
} }
} }
@ -944,8 +944,8 @@ void Foam::forces::read(const dictionary& dict)
// Allocate storage for forces and moments // Allocate storage for forces and moments
forAll(force_, i) forAll(force_, i)
{ {
force_[i].setSize(1); force_[i].setSize(1, vector::zero);
moment_[i].setSize(1); moment_[i].setSize(1, vector::zero);
} }
} }