rigidBodyMotion: Change the transform averaging to use approximate inverse-distance weighting

Now works correctly for an arbitrary number of bodies
Resolves bug-report http://bugs.openfoam.org/view.php?id=2211
This commit is contained in:
Henry Weller
2016-09-14 14:14:14 +01:00
parent 8dc78d188a
commit f281477d85

View File

@ -271,25 +271,23 @@ Foam::tmp<Foam::pointField> Foam::RBD::rigidBodyMotion::transformPoints
forAll(points, i)
{
// Sum (1 - wi) and find the maximum wi
scalar sum1mw = 0;
scalar maxw = 0;
// Initialize to 1 for the far-field weight
scalar sum1mw = 1;
forAll(bodyIDs, bi)
{
w[bi] = (*(weights[bi]))[i];
sum1mw += 1 - w[bi];
maxw = max(maxw, w[bi]);
sum1mw += w[bi]/(1 + SMALL - w[bi]);
}
// Calculate the limiter for (1 - wi) to ensure the sum(wi) = maxw
scalar lambda = (w.size() - 1 - maxw)/sum1mw;
// Calculate the limiter for wi/(1 - wi) to ensure the sum(wi) = 1
scalar lambda = 1/sum1mw;
// Limit (1 - wi) and sum the resulting wi
// Limit wi/(1 - wi) and sum the resulting wi
scalar sumw = 0;
forAll(bodyIDs, bi)
{
w[bi] = 1 - lambda*(1 - w[bi]);
w[bi] = lambda*w[bi]/(1 + SMALL - w[bi]);
sumw += w[bi];
}