diff --git a/src/sixDoFRigidBodyState/Make/files b/src/sixDoFRigidBodyState/Make/files
index a734265fbf..378a15e028 100644
--- a/src/sixDoFRigidBodyState/Make/files
+++ b/src/sixDoFRigidBodyState/Make/files
@@ -1,3 +1,4 @@
-sixDoFRigidBodyState.C
+sixDoFRigidBodyState/sixDoFRigidBodyState.C
+sixDoFRigidBodyControl/sixDoFRigidBodyControl.C
LIB = $(FOAM_LIBBIN)/libsixDoFRigidBodyState
diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyControl/sixDoFRigidBodyControl.C b/src/sixDoFRigidBodyState/sixDoFRigidBodyControl/sixDoFRigidBodyControl.C
new file mode 100644
index 0000000000..b729ebc727
--- /dev/null
+++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyControl/sixDoFRigidBodyControl.C
@@ -0,0 +1,119 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "sixDoFRigidBodyControl.H"
+#include "Time.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+ defineTypeNameAndDebug(sixDoFRigidBodyControl, 0);
+
+ addToRunTimeSelectionTable
+ (
+ functionObject,
+ sixDoFRigidBodyControl,
+ dictionary
+ );
+}
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::functionObjects::sixDoFRigidBodyControl::sixDoFRigidBodyControl
+(
+ const word& name,
+ const Time& runTime,
+ const dictionary& dict
+)
+:
+ sixDoFRigidBodyState(name, runTime, dict),
+ time_(runTime),
+ meanVelocity_(Zero),
+ meanAngularVelocity_(Zero)
+{
+ read(dict);
+ resetName(typeName);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::sixDoFRigidBodyControl::~sixDoFRigidBodyControl()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::sixDoFRigidBodyControl::read(const dictionary& dict)
+{
+ sixDoFRigidBodyState::read(dict);
+
+ dict.lookup("window") >> w_;
+ dict.lookup("convergedVelocity") >> convergedVelocity_;
+ dict.lookup("convergedAngularVelocity") >> convergedAngularVelocity_;
+
+ return true;
+}
+
+
+bool Foam::functionObjects::sixDoFRigidBodyControl::execute()
+{
+ if (time_.timeIndex() <= time_.startTimeIndex() + 1)
+ {
+ meanVelocity_ = cmptMag(velocity());
+ meanAngularVelocity_ = cmptMag(angularVelocity());
+ }
+ else
+ {
+ const scalar dt = time_.deltaTValue();
+ const scalar beta = min(dt/w_, 1);
+
+ meanVelocity_ = (1 - beta)*meanVelocity_ + beta*cmptMag(velocity());
+
+ meanAngularVelocity_ =
+ (1 - beta)*meanAngularVelocity_ + beta*cmptMag(angularVelocity());
+ }
+
+ if
+ (
+ time_.value() - time_.startTime().value() > w_
+ && meanVelocity_ < convergedVelocity_
+ && meanAngularVelocity_ < convergedAngularVelocity_
+ )
+ {
+ time_.stopAt(Time::saWriteNow);
+ }
+
+ return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyControl/sixDoFRigidBodyControl.H b/src/sixDoFRigidBodyState/sixDoFRigidBodyControl/sixDoFRigidBodyControl.H
new file mode 100644
index 0000000000..733427caa9
--- /dev/null
+++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyControl/sixDoFRigidBodyControl.H
@@ -0,0 +1,155 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Class
+ Foam::functionObjects::sixDoFRigidBodyControl
+
+Description
+ Convergence control based on the 6-DoF motion state.
+
+ The body linear and angular velocities are averaged over a specified time
+ window and compared to specified velocity convergence criteria and the run
+ stopped after writing the current time results, if the criteria are met.
+
+ Example of function object specification:
+ \verbatim
+ sixDoFRigidBodyControl
+ {
+ type sixDoFRigidBodyControl;
+ libs ("libsixDoFRigidBodyState.so");
+
+ angleFormat degrees;
+
+ window 1;
+ convergedVelocity (1e-2 1e-2 1e-2);
+ convergedAngularVelocity (5 5 5);
+ }
+ \endverbatim
+
+ Note the units of the \c convergedAngularVelocity are specified by the \c
+ angleFormat entry.
+
+Usage
+ \table
+ Property | Description | Required | Default value
+ type | Type name: sixDoFRigidBodyControl | yes |
+ angleFormat | Degrees or radians | no | radian
+ window | Averaging window | yes |
+ convergedVelocity | Linear velocity convergence criterion | yes |
+ convergedAngularVelocity | Angular velocity convergence criterion | yes |
+ \endtable
+
+See also
+ Foam::functionObjects::sixDoFRigidBodyState
+
+SourceFiles
+ sixDoFRigidBodyControl.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef sixDoFRigidBodyControl_H
+#define sixDoFRigidBodyControl_H
+
+#include "sixDoFRigidBodyState.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+ Class sixDoFRigidBodyControl Declaration
+\*---------------------------------------------------------------------------*/
+
+class sixDoFRigidBodyControl
+:
+ public sixDoFRigidBodyState
+{
+ // Private data
+
+ //- Reference to the Time
+ const Time& time_;
+
+ scalar w_;
+
+ vector convergedVelocity_;
+
+ vector convergedAngularVelocity_;
+
+ vector meanVelocity_;
+
+ vector meanAngularVelocity_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ sixDoFRigidBodyControl(const sixDoFRigidBodyControl&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const sixDoFRigidBodyControl&);
+
+
+public:
+
+ //- Runtime type information
+ TypeName("sixDoFRigidBodyControl");
+
+
+ // Constructors
+
+ //- Construct from Time and dictionary
+ sixDoFRigidBodyControl
+ (
+ const word& name,
+ const Time& runTime,
+ const dictionary& dict
+ );
+
+
+ //- Destructor
+ virtual ~sixDoFRigidBodyControl();
+
+
+ // Member Functions
+
+ //- Read the sixDoFRigidBodyControl data
+ virtual bool read(const dictionary&);
+
+ //- Execute, currently does nothing
+ virtual bool execute();
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyState.C b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C
similarity index 81%
rename from src/sixDoFRigidBodyState/sixDoFRigidBodyState.C
rename to src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C
index 41b7999176..07dcb167ae 100644
--- a/src/sixDoFRigidBodyState/sixDoFRigidBodyState.C
+++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.C
@@ -104,19 +104,49 @@ bool Foam::functionObjects::sixDoFRigidBodyState::execute()
}
+const Foam::sixDoFRigidBodyMotion&
+Foam::functionObjects::sixDoFRigidBodyState::motion() const
+{
+ const dynamicMotionSolverFvMesh& mesh =
+ refCast(obr_);
+
+ const sixDoFRigidBodyMotionSolver& motionSolver_ =
+ refCast(mesh.motion());
+
+ return motionSolver_.motion();
+}
+
+
+Foam::vector
+Foam::functionObjects::sixDoFRigidBodyState::velocity() const
+{
+ return motion().v();
+}
+
+
+Foam::vector
+Foam::functionObjects::sixDoFRigidBodyState::angularVelocity() const
+{
+ vector angularVelocity(motion().omega());
+
+ if (angleFormat_ == "degrees")
+ {
+ angularVelocity.x() = radToDeg(angularVelocity.x());
+ angularVelocity.y() = radToDeg(angularVelocity.y());
+ angularVelocity.z() = radToDeg(angularVelocity.z());
+ }
+
+ return angularVelocity;
+}
+
+
bool Foam::functionObjects::sixDoFRigidBodyState::write()
{
logFiles::write();
if (Pstream::master())
{
- const dynamicMotionSolverFvMesh& mesh =
- refCast(obr_);
-
- const sixDoFRigidBodyMotionSolver& motionSolver_ =
- refCast(mesh.motion());
-
- const sixDoFRigidBodyMotion& motion = motionSolver_.motion();
+ const sixDoFRigidBodyMotion& motion = this->motion();
vector rotationAngle
(
diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyState.H b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H
similarity index 95%
rename from src/sixDoFRigidBodyState/sixDoFRigidBodyState.H
rename to src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H
index 9a04057c33..42267b32da 100644
--- a/src/sixDoFRigidBodyState/sixDoFRigidBodyState.H
+++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyState/sixDoFRigidBodyState.H
@@ -57,12 +57,15 @@ SourceFiles
#define sixDoFRigidBodyState_H
#include "fvMeshFunctionObject.H"
+#include "vector.H"
#include "logFiles.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
+ class sixDoFRigidBodyMotion;
+
namespace functionObjects
{
@@ -82,6 +85,8 @@ class sixDoFRigidBodyState
// Private Member Functions
+ const sixDoFRigidBodyMotion& motion() const;
+
//- Disallow default bitwise copy construct
sixDoFRigidBodyState(const sixDoFRigidBodyState&);
@@ -120,6 +125,10 @@ public:
// Member Functions
+ vector velocity() const;
+
+ vector angularVelocity() const;
+
//- Read the sixDoFRigidBodyState data
virtual bool read(const dictionary&);