diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C index 184cbe608758ba1764d39b40da822be37247e5c6..030fdea85dfadddf8e37bef9ecb7f7770ecb819e 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C @@ -76,6 +76,7 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io) ) ), pointIDs_(), + moveAllCells_(false), UName_(dynamicMeshCoeffs_.lookupOrDefault<word>("UName", "U")) { if (undisplacedPoints_.size() != nPoints()) @@ -142,7 +143,14 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io) cellIDs = set.toc(); } - if (cellIDs.size()) + label nCells = returnReduce(cellIDs.size(), sumOp<label>()); + moveAllCells_ = nCells == 0; + + if (moveAllCells_) + { + Info<< "Applying solid body motion to entire mesh" << endl; + } + else { // collect point IDs of points in cell zone @@ -176,10 +184,6 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io) pointIDs_.transfer(ptIDs); } - else - { - Info<< "Applying solid body motion to entire mesh" << endl; - } } @@ -195,7 +199,18 @@ bool Foam::solidBodyMotionFvMesh::update() { static bool hasWarned = false; - if (pointIDs_.size()) + if (moveAllCells_) + { + fvMesh::movePoints + ( + transform + ( + SBMFPtr_().transformation(), + undisplacedPoints_ + ) + ); + } + else { pointField transformedPts(undisplacedPoints_); @@ -208,17 +223,6 @@ bool Foam::solidBodyMotionFvMesh::update() fvMesh::movePoints(transformedPts); } - else - { - fvMesh::movePoints - ( - transform - ( - SBMFPtr_().transformation(), - undisplacedPoints_ - ) - ); - } if (foundObject<volVectorField>(UName_)) diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.H index 3f691381fb3a3c7dbcd91142b5fe4e2b70eba769..d7d8bf4680815161e0dced4010f3009a0b0273cb 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.H @@ -68,6 +68,9 @@ class solidBodyMotionFvMesh //- Points to move when cell zone is supplied labelList pointIDs_; + //- Flag to indicate whether all cells should move + bool moveAllCells_; + //- Name of velocity field word UName_;