From 5179e8ea3bcb24cdb6ad0ac96764c0d562a55945 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 9 Mar 2015 10:47:13 +0000 Subject: [PATCH] functionObjects/forces: limit the bins to handle moving meshes This approach simply accumulates data outside the range of the bins into the first or last bin which may be OK for small motions. For larger motions it may be better if the bins are updated or operate in a coordinate system attached to the body for solid-body motion. Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1560 --- .../functionObjects/forces/forces/forces.C | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 539e14b3..dfc63544 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -377,13 +377,13 @@ void Foam::forces::applyBins forAll(dd, i) { - label binI = floor(dd[i]/binDx_); - force_[0][binI] += fN[i]; - force_[1][binI] += fT[i]; - force_[2][binI] += fP[i]; - moment_[0][binI] += Md[i]^fN[i]; - moment_[1][binI] += Md[i]^fT[i]; - moment_[2][binI] += Md[i]^fP[i]; + label bini = min(max(floor(dd[i]/binDx_), 0), force_[0].size()); + force_[0][bini] += fN[i]; + force_[1][bini] += fT[i]; + force_[2][bini] += fP[i]; + moment_[0][bini] += Md[i]^fN[i]; + moment_[1][bini] += Md[i]^fT[i]; + moment_[2][bini] += Md[i]^fP[i]; } } }