Skip to content
Snippets Groups Projects
Commit f281477d authored by Henry Weller's avatar Henry Weller
Browse files

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
parent 8dc78d18
Branches
Tags
No related merge requests found
...@@ -271,25 +271,23 @@ Foam::tmp<Foam::pointField> Foam::RBD::rigidBodyMotion::transformPoints ...@@ -271,25 +271,23 @@ Foam::tmp<Foam::pointField> Foam::RBD::rigidBodyMotion::transformPoints
forAll(points, i) forAll(points, i)
{ {
// Sum (1 - wi) and find the maximum wi // Initialize to 1 for the far-field weight
scalar sum1mw = 0; scalar sum1mw = 1;
scalar maxw = 0;
forAll(bodyIDs, bi) forAll(bodyIDs, bi)
{ {
w[bi] = (*(weights[bi]))[i]; w[bi] = (*(weights[bi]))[i];
sum1mw += 1 - w[bi]; sum1mw += w[bi]/(1 + SMALL - w[bi]);
maxw = max(maxw, w[bi]);
} }
// Calculate the limiter for (1 - wi) to ensure the sum(wi) = maxw // Calculate the limiter for wi/(1 - wi) to ensure the sum(wi) = 1
scalar lambda = (w.size() - 1 - maxw)/sum1mw; scalar lambda = 1/sum1mw;
// Limit (1 - wi) and sum the resulting wi // Limit wi/(1 - wi) and sum the resulting wi
scalar sumw = 0; scalar sumw = 0;
forAll(bodyIDs, bi) forAll(bodyIDs, bi)
{ {
w[bi] = 1 - lambda*(1 - w[bi]); w[bi] = lambda*w[bi]/(1 + SMALL - w[bi]);
sumw += w[bi]; sumw += w[bi];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment