diff --git a/src/rigidBodyDynamics/joints/Pa/Pa.C b/src/rigidBodyDynamics/joints/Pa/Pa.C index b30997aca..04276db45 100644 --- a/src/rigidBodyDynamics/joints/Pa/Pa.C +++ b/src/rigidBodyDynamics/joints/Pa/Pa.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Pa.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Pa::Pa(const vector& axis) +Foam::RBD::joints::Pa::Pa(const rigidBodyModel& model, const vector& axis) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(Zero, axis/mag(axis)); } -Foam::RBD::joints::Pa::Pa(const dictionary& dict) +Foam::RBD::joints::Pa::Pa(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { vector axis(dict.lookup("axis")); S_[0] = spatialVector(Zero, axis/mag(axis)); @@ -84,13 +84,12 @@ Foam::RBD::joints::Pa::~Pa() void Foam::RBD::joints::Pa::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xt(S_[0].l()*q[qIndex_]); + J.X = Xt(S_[0].l()*state.q()[qIndex_]); J.S1 = S_[0]; - J.v = S_[0]*qDot[qIndex_]; + J.v = S_[0]*state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Pa/Pa.H b/src/rigidBodyDynamics/joints/Pa/Pa.H index d67af31d9..e40d6e74c 100644 --- a/src/rigidBodyDynamics/joints/Pa/Pa.H +++ b/src/rigidBodyDynamics/joints/Pa/Pa.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model and axis - Pa(const vector& axis); + Pa(const rigidBodyModel& model, const vector& axis); //- Construct for given model from dictionary - Pa(const dictionary& dict); + Pa(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; //- Write diff --git a/src/rigidBodyDynamics/joints/Px/Px.C b/src/rigidBodyDynamics/joints/Px/Px.C index a4a382c2a..0f208648f 100644 --- a/src/rigidBodyDynamics/joints/Px/Px.C +++ b/src/rigidBodyDynamics/joints/Px/Px.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Px.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Px::Px() +Foam::RBD::joints::Px::Px(const rigidBodyModel& model) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 0, 1, 0, 0); } -Foam::RBD::joints::Px::Px(const dictionary& dict) +Foam::RBD::joints::Px::Px(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 0, 1, 0, 0); } @@ -83,13 +83,12 @@ Foam::RBD::joints::Px::~Px() void Foam::RBD::joints::Px::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xt(S_[0].l()*q[qIndex_]); + J.X = Xt(S_[0].l()*state.q()[qIndex_]); J.S1 = S_[0]; - J.v = S_[0]*qDot[qIndex_]; + J.v = S_[0]*state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Px/Px.H b/src/rigidBodyDynamics/joints/Px/Px.H index 979abcf5c..a40ec6717 100644 --- a/src/rigidBodyDynamics/joints/Px/Px.H +++ b/src/rigidBodyDynamics/joints/Px/Px.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Px(); + Px(const rigidBodyModel& model); //- Construct for given model from dictionary - Px(const dictionary& dict); + Px(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Pxyz/Pxyz.C b/src/rigidBodyDynamics/joints/Pxyz/Pxyz.C index 6d87412e8..58edbbf8e 100644 --- a/src/rigidBodyDynamics/joints/Pxyz/Pxyz.C +++ b/src/rigidBodyDynamics/joints/Pxyz/Pxyz.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Pxyz.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,9 +50,9 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Pxyz::Pxyz() +Foam::RBD::joints::Pxyz::Pxyz(const rigidBodyModel& model) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(0, 0, 0, 1, 0, 0); S_[1] = spatialVector(0, 0, 0, 0, 1, 0); @@ -60,9 +60,13 @@ Foam::RBD::joints::Pxyz::Pxyz() } -Foam::RBD::joints::Pxyz::Pxyz(const dictionary& dict) +Foam::RBD::joints::Pxyz::Pxyz +( + const rigidBodyModel& model, + const dictionary& dict +) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(0, 0, 0, 1, 0, 0); S_[1] = spatialVector(0, 0, 0, 0, 1, 0); @@ -87,19 +91,18 @@ Foam::RBD::joints::Pxyz::~Pxyz() void Foam::RBD::joints::Pxyz::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { J.X.E() = tensor::I; - J.X.r() = q.block(qIndex_); + J.X.r() = state.q().block(qIndex_); J.S = Zero; J.S(3,0) = 1; J.S(4,1) = 1; J.S(5,2) = 1; - J.v = spatialVector(Zero, qDot.block(qIndex_)); + J.v = spatialVector(Zero, state.qDot().block(qIndex_)); J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Pxyz/Pxyz.H b/src/rigidBodyDynamics/joints/Pxyz/Pxyz.H index 02746bf14..2be3f96bb 100644 --- a/src/rigidBodyDynamics/joints/Pxyz/Pxyz.H +++ b/src/rigidBodyDynamics/joints/Pxyz/Pxyz.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Pxyz(); + Pxyz(const rigidBodyModel& model); //- Construct for given model from dictionary - Pxyz(const dictionary& dict); + Pxyz(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Py/Py.C b/src/rigidBodyDynamics/joints/Py/Py.C index 6fb02c4f5..71e4adccf 100644 --- a/src/rigidBodyDynamics/joints/Py/Py.C +++ b/src/rigidBodyDynamics/joints/Py/Py.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Py.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Py::Py() +Foam::RBD::joints::Py::Py(const rigidBodyModel& model) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 0, 0, 1, 0); } -Foam::RBD::joints::Py::Py(const dictionary& dict) +Foam::RBD::joints::Py::Py(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 0, 0, 1, 0); } @@ -83,13 +83,12 @@ Foam::RBD::joints::Py::~Py() void Foam::RBD::joints::Py::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xt(S_[0].l()*q[qIndex_]); + J.X = Xt(S_[0].l()*state.q()[qIndex_]); J.S1 = S_[0]; - J.v = S_[0]*qDot[qIndex_]; + J.v = S_[0]*state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Py/Py.H b/src/rigidBodyDynamics/joints/Py/Py.H index bcbcd4778..b8f044f74 100644 --- a/src/rigidBodyDynamics/joints/Py/Py.H +++ b/src/rigidBodyDynamics/joints/Py/Py.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Py(); + Py(const rigidBodyModel& model); //- Construct for given model from dictionary - Py(const dictionary& dict); + Py(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Pz/Pz.C b/src/rigidBodyDynamics/joints/Pz/Pz.C index 6c90c3679..a4171c480 100644 --- a/src/rigidBodyDynamics/joints/Pz/Pz.C +++ b/src/rigidBodyDynamics/joints/Pz/Pz.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Pz.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Pz::Pz() +Foam::RBD::joints::Pz::Pz(const rigidBodyModel& model) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 0, 0, 0, 1); } -Foam::RBD::joints::Pz::Pz(const dictionary& dict) +Foam::RBD::joints::Pz::Pz(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 0, 0, 0, 1); } @@ -83,13 +83,12 @@ Foam::RBD::joints::Pz::~Pz() void Foam::RBD::joints::Pz::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xt(S_[0].l()*q[qIndex_]); + J.X = Xt(S_[0].l()*state.q()[qIndex_]); J.S1 = S_[0]; - J.v = S_[0]*qDot[qIndex_]; + J.v = S_[0]*state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Pz/Pz.H b/src/rigidBodyDynamics/joints/Pz/Pz.H index 611397ded..143f36156 100644 --- a/src/rigidBodyDynamics/joints/Pz/Pz.H +++ b/src/rigidBodyDynamics/joints/Pz/Pz.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Pz(); + Pz(const rigidBodyModel& model); //- Construct for given model from dictionary - Pz(const dictionary& dict); + Pz(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Ra/Ra.C b/src/rigidBodyDynamics/joints/Ra/Ra.C index 468985ea6..25c6c4d6a 100644 --- a/src/rigidBodyDynamics/joints/Ra/Ra.C +++ b/src/rigidBodyDynamics/joints/Ra/Ra.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Ra.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Ra::Ra(const vector& axis) +Foam::RBD::joints::Ra::Ra(const rigidBodyModel& model, const vector& axis) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(axis/mag(axis), Zero); } -Foam::RBD::joints::Ra::Ra(const dictionary& dict) +Foam::RBD::joints::Ra::Ra(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { vector axis(dict.lookup("axis")); S_[0] = spatialVector(axis/mag(axis), Zero); @@ -84,13 +84,12 @@ Foam::RBD::joints::Ra::~Ra() void Foam::RBD::joints::Ra::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xr(S_[0].w(), q[qIndex_]); + J.X = Xr(S_[0].w(), state.q()[qIndex_]); J.S1 = S_[0]; - J.v = S_[0]*qDot[qIndex_]; + J.v = S_[0]*state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Ra/Ra.H b/src/rigidBodyDynamics/joints/Ra/Ra.H index cd634f7b8..9fb65181f 100644 --- a/src/rigidBodyDynamics/joints/Ra/Ra.H +++ b/src/rigidBodyDynamics/joints/Ra/Ra.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model and axis - Ra(const vector& axis); + Ra(const rigidBodyModel& model, const vector& axis); //- Construct for given model from dictionary - Ra(const dictionary& dict); + Ra(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; //- Write diff --git a/src/rigidBodyDynamics/joints/Rs/Rs.C b/src/rigidBodyDynamics/joints/Rs/Rs.C index da4bd3618..f87ddc78b 100644 --- a/src/rigidBodyDynamics/joints/Rs/Rs.C +++ b/src/rigidBodyDynamics/joints/Rs/Rs.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Rs.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,9 +50,9 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Rs::Rs() +Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(1, 0, 0, 0, 0, 0); S_[1] = spatialVector (0, 1, 0, 0, 0, 0); @@ -60,9 +60,9 @@ Foam::RBD::joints::Rs::Rs() } -Foam::RBD::joints::Rs::Rs(const dictionary& dict) +Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model, const dictionary& dict) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(1, 0, 0, 0, 0, 0); S_[1] = spatialVector (0, 1, 0, 0, 0, 0); @@ -93,11 +93,10 @@ bool Foam::RBD::joints::Rs::unitQuaternion() const void Foam::RBD::joints::Rs::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X.E() = joint::unitQuaternion(q).R().T(); + J.X.E() = joint::unitQuaternion(state.q()).R().T(); J.X.r() = Zero; J.S = Zero; @@ -105,7 +104,7 @@ void Foam::RBD::joints::Rs::jcalc J.S.yy() = 1; J.S.zz() = 1; - J.v = spatialVector(qDot.block(qIndex_), Zero); + J.v = spatialVector(state.qDot().block(qIndex_), Zero); J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Rs/Rs.H b/src/rigidBodyDynamics/joints/Rs/Rs.H index f68986905..fa8227d44 100644 --- a/src/rigidBodyDynamics/joints/Rs/Rs.H +++ b/src/rigidBodyDynamics/joints/Rs/Rs.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,10 +73,10 @@ public: // Constructors //- Construct for given model - Rs(); + Rs(const rigidBodyModel& model); //- Construct for given model from dictionary - Rs(const dictionary& dict); + Rs(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -95,8 +95,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Rx/Rx.C b/src/rigidBodyDynamics/joints/Rx/Rx.C index e2d3f6953..6db4399a1 100644 --- a/src/rigidBodyDynamics/joints/Rx/Rx.C +++ b/src/rigidBodyDynamics/joints/Rx/Rx.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Rx.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Rx::Rx() +Foam::RBD::joints::Rx::Rx(const rigidBodyModel& model) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(1, 0, 0, 0, 0, 0); } -Foam::RBD::joints::Rx::Rx(const dictionary& dict) +Foam::RBD::joints::Rx::Rx(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(1, 0, 0, 0, 0, 0); } @@ -83,14 +83,13 @@ Foam::RBD::joints::Rx::~Rx() void Foam::RBD::joints::Rx::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xrx(q[qIndex_]); + J.X = Xrx(state.q()[qIndex_]); J.S1 = S_[0]; J.v = Zero; - J.v.wx() = qDot[qIndex_]; + J.v.wx() = state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Rx/Rx.H b/src/rigidBodyDynamics/joints/Rx/Rx.H index 892cfcb70..8db4f9091 100644 --- a/src/rigidBodyDynamics/joints/Rx/Rx.H +++ b/src/rigidBodyDynamics/joints/Rx/Rx.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Rx(); + Rx(const rigidBodyModel& model); //- Construct for given model from dictionary - Rx(const dictionary& dict); + Rx(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Rxyz/Rxyz.C b/src/rigidBodyDynamics/joints/Rxyz/Rxyz.C index 2055c6748..c038a10a2 100644 --- a/src/rigidBodyDynamics/joints/Rxyz/Rxyz.C +++ b/src/rigidBodyDynamics/joints/Rxyz/Rxyz.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Rxyz.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,9 +50,9 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Rxyz::Rxyz() +Foam::RBD::joints::Rxyz::Rxyz(const rigidBodyModel& model) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(1, 0, 0, 0, 0, 0); S_[1] = spatialVector(0, 1, 0, 0, 0, 0); @@ -60,9 +60,13 @@ Foam::RBD::joints::Rxyz::Rxyz() } -Foam::RBD::joints::Rxyz::Rxyz(const dictionary& dict) +Foam::RBD::joints::Rxyz::Rxyz +( + const rigidBodyModel& model, + const dictionary& dict +) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(1, 0, 0, 0, 0, 0); S_[1] = spatialVector(0, 1, 0, 0, 0, 0); @@ -87,11 +91,10 @@ Foam::RBD::joints::Rxyz::~Rxyz() void Foam::RBD::joints::Rxyz::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - vector qj(q.block(qIndex_)); + vector qj(state.q().block(qIndex_)); scalar s0 = sin(qj.x()); scalar c0 = cos(qj.x()); @@ -116,7 +119,7 @@ void Foam::RBD::joints::Rxyz::jcalc J.S.zx() = s1; J.S.zz() = 1; - vector qDotj(qDot.block(qIndex_)); + vector qDotj(state.qDot().block(qIndex_)); J.v = J.S & qDotj; J.c = spatialVector diff --git a/src/rigidBodyDynamics/joints/Rxyz/Rxyz.H b/src/rigidBodyDynamics/joints/Rxyz/Rxyz.H index 43582796d..b64105702 100644 --- a/src/rigidBodyDynamics/joints/Rxyz/Rxyz.H +++ b/src/rigidBodyDynamics/joints/Rxyz/Rxyz.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,10 +73,10 @@ public: // Constructors //- Construct for given model - Rxyz(); + Rxyz(const rigidBodyModel& model); //- Construct for given model from dictionary - Rxyz(const dictionary& dict); + Rxyz(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -92,8 +92,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Ry/Ry.C b/src/rigidBodyDynamics/joints/Ry/Ry.C index 89d414ecc..ae9a50a8a 100644 --- a/src/rigidBodyDynamics/joints/Ry/Ry.C +++ b/src/rigidBodyDynamics/joints/Ry/Ry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Ry.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Ry::Ry() +Foam::RBD::joints::Ry::Ry(const rigidBodyModel& model) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 1, 0, 0, 0, 0); } -Foam::RBD::joints::Ry::Ry(const dictionary& dict) +Foam::RBD::joints::Ry::Ry(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 1, 0, 0, 0, 0); } @@ -83,14 +83,13 @@ Foam::RBD::joints::Ry::~Ry() void Foam::RBD::joints::Ry::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xry(q[qIndex_]); + J.X = Xry(state.q()[qIndex_]); J.S1 = S_[0]; J.v = Zero; - J.v.wy() = qDot[qIndex_]; + J.v.wy() = state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Ry/Ry.H b/src/rigidBodyDynamics/joints/Ry/Ry.H index 0a870bd92..00bd59bd4 100644 --- a/src/rigidBodyDynamics/joints/Ry/Ry.H +++ b/src/rigidBodyDynamics/joints/Ry/Ry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Ry(); + Ry(const rigidBodyModel& model); //- Construct for given model from dictionary - Ry(const dictionary& dict); + Ry(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Ryxz/Ryxz.C b/src/rigidBodyDynamics/joints/Ryxz/Ryxz.C index fd5f942e3..d8f18ed9c 100644 --- a/src/rigidBodyDynamics/joints/Ryxz/Ryxz.C +++ b/src/rigidBodyDynamics/joints/Ryxz/Ryxz.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Ryxz.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,9 +50,9 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Ryxz::Ryxz() +Foam::RBD::joints::Ryxz::Ryxz(const rigidBodyModel& model) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(0, 1, 0, 0, 0, 0); S_[1] = spatialVector(1, 0, 0, 0, 0, 0); @@ -60,9 +60,13 @@ Foam::RBD::joints::Ryxz::Ryxz() } -Foam::RBD::joints::Ryxz::Ryxz(const dictionary& dict) +Foam::RBD::joints::Ryxz::Ryxz +( + const rigidBodyModel& model, + const dictionary& dict +) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(0, 1, 0, 0, 0, 0); S_[1] = spatialVector(1, 0, 0, 0, 0, 0); @@ -87,11 +91,10 @@ Foam::RBD::joints::Ryxz::~Ryxz() void Foam::RBD::joints::Ryxz::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - vector qj(q.block(qIndex_)); + vector qj(state.q().block(qIndex_)); scalar s0 = sin(qj.x()); scalar c0 = cos(qj.x()); @@ -116,7 +119,7 @@ void Foam::RBD::joints::Ryxz::jcalc J.S.zx() = -s1; J.S.zz() = 1; - vector qDotj(qDot.block(qIndex_)); + vector qDotj(state.qDot().block(qIndex_)); J.v = J.S & qDotj; J.c = spatialVector diff --git a/src/rigidBodyDynamics/joints/Ryxz/Ryxz.H b/src/rigidBodyDynamics/joints/Ryxz/Ryxz.H index 1371abcf8..a861ab9f9 100644 --- a/src/rigidBodyDynamics/joints/Ryxz/Ryxz.H +++ b/src/rigidBodyDynamics/joints/Ryxz/Ryxz.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,10 +73,10 @@ public: // Constructors //- Construct for given model - Ryxz(); + Ryxz(const rigidBodyModel& model); //- Construct for given model from dictionary - Ryxz(const dictionary& dict); + Ryxz(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -92,8 +92,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Rz/Rz.C b/src/rigidBodyDynamics/joints/Rz/Rz.C index c02ba9cec..b5b868587 100644 --- a/src/rigidBodyDynamics/joints/Rz/Rz.C +++ b/src/rigidBodyDynamics/joints/Rz/Rz.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Rz.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,17 +50,17 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Rz::Rz() +Foam::RBD::joints::Rz::Rz(const rigidBodyModel& model) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 1, 0, 0, 0); } -Foam::RBD::joints::Rz::Rz(const dictionary& dict) +Foam::RBD::joints::Rz::Rz(const rigidBodyModel& model, const dictionary& dict) : - joint(1) + joint(model, 1) { S_[0] = spatialVector(0, 0, 1, 0, 0, 0); } @@ -83,14 +83,13 @@ Foam::RBD::joints::Rz::~Rz() void Foam::RBD::joints::Rz::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - J.X = Xrz(q[qIndex_]); + J.X = Xrz(state.q()[qIndex_]); J.S1 = S_[0]; J.v = Zero; - J.v.wz() = qDot[qIndex_]; + J.v.wz() = state.qDot()[qIndex_]; J.c = Zero; } diff --git a/src/rigidBodyDynamics/joints/Rz/Rz.H b/src/rigidBodyDynamics/joints/Rz/Rz.H index 01ed3139b..f037a2b74 100644 --- a/src/rigidBodyDynamics/joints/Rz/Rz.H +++ b/src/rigidBodyDynamics/joints/Rz/Rz.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,10 +72,10 @@ public: // Constructors //- Construct for given model - Rz(); + Rz(const rigidBodyModel& model); //- Construct for given model from dictionary - Rz(const dictionary& dict); + Rz(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +91,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/Rzyx/Rzyx.C b/src/rigidBodyDynamics/joints/Rzyx/Rzyx.C index 1e3593222..53bef2c76 100644 --- a/src/rigidBodyDynamics/joints/Rzyx/Rzyx.C +++ b/src/rigidBodyDynamics/joints/Rzyx/Rzyx.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Rzyx.H" -#include "rigidBodyModel.H" +#include "rigidBodyModelState.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,9 +50,9 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::Rzyx::Rzyx() +Foam::RBD::joints::Rzyx::Rzyx(const rigidBodyModel& model) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(0, 0, 1, 0, 0, 0); S_[1] = spatialVector(0, 1, 0, 0, 0, 0); @@ -60,9 +60,13 @@ Foam::RBD::joints::Rzyx::Rzyx() } -Foam::RBD::joints::Rzyx::Rzyx(const dictionary& dict) +Foam::RBD::joints::Rzyx::Rzyx +( + const rigidBodyModel& model, + const dictionary& dict +) : - joint(3) + joint(model, 3) { S_[0] = spatialVector(0, 0, 1, 0, 0, 0); S_[1] = spatialVector(0, 1, 0, 0, 0, 0); @@ -87,11 +91,10 @@ Foam::RBD::joints::Rzyx::~Rzyx() void Foam::RBD::joints::Rzyx::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - vector qj(q.block(qIndex_)); + vector qj(state.q().block(qIndex_)); scalar s0 = sin(qj.x()); scalar c0 = cos(qj.x()); @@ -116,7 +119,7 @@ void Foam::RBD::joints::Rzyx::jcalc J.S.zx() = c1*c2; J.S.zy() = -s2; - vector qDotj(qDot.block(qIndex_)); + vector qDotj(state.qDot().block(qIndex_)); J.v = J.S & qDotj; J.c = spatialVector diff --git a/src/rigidBodyDynamics/joints/Rzyx/Rzyx.H b/src/rigidBodyDynamics/joints/Rzyx/Rzyx.H index 3aeb85dd6..ee305948c 100644 --- a/src/rigidBodyDynamics/joints/Rzyx/Rzyx.H +++ b/src/rigidBodyDynamics/joints/Rzyx/Rzyx.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,10 +73,10 @@ public: // Constructors //- Construct for given model - Rzyx(); + Rzyx(const rigidBodyModel& model); //- Construct for given model from dictionary - Rzyx(const dictionary& dict); + Rzyx(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -92,8 +92,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/joints/composite/compositeJoint.C b/src/rigidBodyDynamics/joints/composite/compositeJoint.C index a7d1fd887..30df58b8a 100644 --- a/src/rigidBodyDynamics/joints/composite/compositeJoint.C +++ b/src/rigidBodyDynamics/joints/composite/compositeJoint.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,7 +52,7 @@ namespace joints void Foam::RBD::joints::composite::setLastJoint() { - last().joint::operator=(*this); + //last().joint::operator=(*this); } @@ -65,9 +65,13 @@ Foam::RBD::joints::composite::composite(const PtrList& joints) {} -Foam::RBD::joints::composite::composite(const dictionary& dict) +Foam::RBD::joints::composite::composite +( + const rigidBodyModel& model, + const dictionary& dict +) : - PtrList(dict.lookup("joints")), + PtrList(dict.lookup("joints"), joint::iNew(model)), joint(last()) {} @@ -89,11 +93,10 @@ Foam::RBD::joints::composite::~composite() void Foam::RBD::joints::composite::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { - last().jcalc(J, q, qDot); + last().jcalc(J, state); } diff --git a/src/rigidBodyDynamics/joints/composite/compositeJoint.H b/src/rigidBodyDynamics/joints/composite/compositeJoint.H index f55b6f3d8..10cf5ff55 100644 --- a/src/rigidBodyDynamics/joints/composite/compositeJoint.H +++ b/src/rigidBodyDynamics/joints/composite/compositeJoint.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -89,7 +89,7 @@ public: composite(const PtrList& joints); //- Construct for given model from dictionary - composite(const dictionary& dict); + composite(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -105,8 +105,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; //- Write diff --git a/src/rigidBodyDynamics/joints/floating/floatingJoint.C b/src/rigidBodyDynamics/joints/floating/floatingJoint.C index 49f6bb5ae..e6edbf65f 100644 --- a/src/rigidBodyDynamics/joints/floating/floatingJoint.C +++ b/src/rigidBodyDynamics/joints/floating/floatingJoint.C @@ -55,17 +55,17 @@ namespace joints // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::autoPtr -Foam::RBD::joints::floating::sixDoF() +Foam::RBD::joints::floating::sixDoF(const rigidBodyModel& model) { PtrList cj(2); - cj.set(0, new joints::Pxyz()); + cj.set(0, new joints::Pxyz(model)); // The quaternion-based spherical joint could be used // but then w must be set appropriately - // cj.set(1, new joints::Rs()); + // cj.set(1, new joints::Rs(model)); // Alternatively the Euler-angle joint can be used - cj.set(1, new joints::Rzyx()); + cj.set(1, new joints::Rzyx(model)); return autoPtr(new composite(cj)); } @@ -73,15 +73,19 @@ Foam::RBD::joints::floating::sixDoF() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::floating::floating() +Foam::RBD::joints::floating::floating(const rigidBodyModel& model) : - composite(sixDoF()) + composite(sixDoF(model)) {} -Foam::RBD::joints::floating::floating(const dictionary& dict) +Foam::RBD::joints::floating::floating +( + const rigidBodyModel& model, + const dictionary& dict +) : - composite(sixDoF()) + composite(sixDoF(model)) {} diff --git a/src/rigidBodyDynamics/joints/floating/floatingJoint.H b/src/rigidBodyDynamics/joints/floating/floatingJoint.H index eb6f1e09e..5802d0a20 100644 --- a/src/rigidBodyDynamics/joints/floating/floatingJoint.H +++ b/src/rigidBodyDynamics/joints/floating/floatingJoint.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,7 +65,7 @@ class floating // Private member functions //- Return a list of joints needed to emulate a floating body - static autoPtr sixDoF(); + static autoPtr sixDoF(const rigidBodyModel& model); public: @@ -77,10 +77,10 @@ public: // Constructors //- Construct - floating(); + floating(const rigidBodyModel& model); //- Construct for given model from dictionary - floating(const dictionary& dict); + floating(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; diff --git a/src/rigidBodyDynamics/joints/joint/joint.C b/src/rigidBodyDynamics/joints/joint/joint.C index f13ee347e..32635041e 100644 --- a/src/rigidBodyDynamics/joints/joint/joint.C +++ b/src/rigidBodyDynamics/joints/joint/joint.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,6 +48,7 @@ Foam::autoPtr Foam::RBD::joint::New(joint* jointPtr) Foam::autoPtr Foam::RBD::joint::New ( + const rigidBodyModel& model, const dictionary& dict ) { @@ -66,7 +67,7 @@ Foam::autoPtr Foam::RBD::joint::New << exit(FatalError); } - return autoPtr(cstrIter()(dict)); + return autoPtr(cstrIter()(model, dict)); } diff --git a/src/rigidBodyDynamics/joints/joint/joint.H b/src/rigidBodyDynamics/joints/joint/joint.H index 0ea00b678..227bcfbab 100644 --- a/src/rigidBodyDynamics/joints/joint/joint.H +++ b/src/rigidBodyDynamics/joints/joint/joint.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,6 +66,7 @@ namespace RBD // Forward declaration of classes class rigidBodyModel; +class rigidBodyModelState; // Forward declaration of friend functions and operators class joint; @@ -84,14 +85,17 @@ protected: // Protected data - //- Joint motion sub-space - List S_; + //- Reference to the model + const rigidBodyModel& model_; - //- Index of this joint in the rigidBodyModel - label index_; + //- Joint motion sub-space + List S_; - //- Index of this joints data in the rigidBodyModel state - label qIndex_; + //- Index of this joint in the rigidBodyModel + label index_; + + //- Index of this joints data in the rigidBodyModel state + label qIndex_; private: @@ -160,8 +164,8 @@ public: autoPtr, joint, dictionary, - (const dictionary& dict), - (dict) + (const rigidBodyModel& model, const dictionary& dict), + (model, dict) ); @@ -169,7 +173,7 @@ public: //- Construct joint setting the size of the motion sub-space // to the given degrees of freedom of the joint - inline joint(const label nDoF); + inline joint(const rigidBodyModel& model, const label nDoF); //- Clone this joint (needed by PtrList) virtual autoPtr clone() const = 0; @@ -177,9 +181,13 @@ public: class iNew { + const rigidBodyModel& model_; + public: - iNew() + iNew(const rigidBodyModel& model) + : + model_(model) {} inline autoPtr operator()(Istream& is) const; @@ -196,7 +204,11 @@ public: static autoPtr New(joint* jointPtr); //- Select from dictionary - static autoPtr New(const dictionary& dict); + static autoPtr New + ( + const rigidBodyModel& model, + const dictionary& dict + ); // Member Functions @@ -222,8 +234,7 @@ public: virtual void jcalc ( XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const = 0; //- Write diff --git a/src/rigidBodyDynamics/joints/joint/jointI.H b/src/rigidBodyDynamics/joints/joint/jointI.H index eb6e36a2c..2ec365843 100644 --- a/src/rigidBodyDynamics/joints/joint/jointI.H +++ b/src/rigidBodyDynamics/joints/joint/jointI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,8 +25,9 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::RBD::joint::joint(const label nDoF) +inline Foam::RBD::joint::joint(const rigidBodyModel& model, const label nDoF) : + model_(model), S_(nDoF), index_(0), qIndex_(0) @@ -104,7 +105,7 @@ Foam::autoPtr Foam::RBD::joint::iNew::operator() ) const { dictionary dict(is); - return New(dict); + return New(model_, dict); } diff --git a/src/rigidBodyDynamics/joints/null/nullJoint.C b/src/rigidBodyDynamics/joints/null/nullJoint.C index baed48767..325f58cea 100644 --- a/src/rigidBodyDynamics/joints/null/nullJoint.C +++ b/src/rigidBodyDynamics/joints/null/nullJoint.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,15 +50,19 @@ namespace joints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::RBD::joints::null::null() +Foam::RBD::joints::null::null(const rigidBodyModel& model) : - joint(0) + joint(model, 0) {} -Foam::RBD::joints::null::null(const dictionary& dict) +Foam::RBD::joints::null::null +( + const rigidBodyModel& model, + const dictionary& dict +) : - joint(0) + joint(model, 0) {} @@ -79,8 +83,7 @@ Foam::RBD::joints::null::~null() void Foam::RBD::joints::null::jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const { FatalErrorInFunction diff --git a/src/rigidBodyDynamics/joints/null/nullJoint.H b/src/rigidBodyDynamics/joints/null/nullJoint.H index f242050ac..ef290545b 100644 --- a/src/rigidBodyDynamics/joints/null/nullJoint.H +++ b/src/rigidBodyDynamics/joints/null/nullJoint.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,6 +51,9 @@ namespace Foam { namespace RBD { + +class rigidBodyModel; + namespace joints { @@ -72,10 +75,10 @@ public: // Constructors //- Construct for given model - null(); + null(const rigidBodyModel& model); //- Construct for given model from dictionary - null(const dictionary& dict); + null(const rigidBodyModel& model, const dictionary& dict); //- Clone this joint virtual autoPtr clone() const; @@ -91,8 +94,7 @@ public: virtual void jcalc ( joint::XSvc& J, - const scalarField& q, - const scalarField& qDot + const rigidBodyModelState& state ) const; }; diff --git a/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C b/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C index 97d837abb..0ffae6eea 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C +++ b/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,13 +57,11 @@ void Foam::RBD::rigidBodyModel::forwardDynamics const Field& fx ) const { - const scalarField& q = state.q(); - const scalarField& qDot = state.qDot(); scalarField& qDdot = state.qDdot(); DebugInFunction - << "q = " << q << nl - << "qDot = " << qDot << nl + << "q = " << state.q() << nl + << "qDot = " << state.qDot() << nl << "tau = " << tau << endl; // Joint state returned by jcalc @@ -74,7 +72,7 @@ void Foam::RBD::rigidBodyModel::forwardDynamics for (label i=1; i(qi) - (S_[i].T() & pA_[i]); const label lambdai = lambda_[i]; if (lambdai != 0) { - spatialTensor Ia + const spatialTensor Ia ( - IA_[i] - - (U_[i] & Dinv_[i] & U_[i].T()) + IA_[i] - (U_[i] & Dinv_[i] & U_[i].T()) ); - spatialVector pa + const spatialVector pa ( - pA_[i] - + (Ia & c_[i]) - + (U_[i] & Dinv_[i] & u_[i]) + pA_[i] + (Ia & c_[i]) + (U_[i] & Dinv_[i] & u_[i]) ); IA_[lambdai] += @@ -179,7 +194,11 @@ void Foam::RBD::rigidBodyModel::forwardDynamics a_[i] = (Xlambda_[i] & a_[lambda_[i]]) + c_[i]; - if (jnt.nDoF() == 1) + if (jnt.nDoF() == 0) + { + // do nothing + } + else if (jnt.nDoF() == 1) { qDdot[qi] = Dinv_[i].xx()*(u_[i].x() - (U1_[i] && a_[i])); a_[i] += S1_[i]*qDdot[qi]; @@ -208,12 +227,10 @@ void Foam::RBD::rigidBodyModel::forwardDynamicsCorrection const rigidBodyModelState& state ) const { - DebugInFunction << endl; - - const scalarField& q = state.q(); - const scalarField& qDot = state.qDot(); const scalarField& qDdot = state.qDdot(); + DebugInFunction << endl; + // Joint state returned by jcalc joint::XSvc J; @@ -225,7 +242,7 @@ void Foam::RBD::rigidBodyModel::forwardDynamicsCorrection const joint& jnt = joints()[i]; const label qi = jnt.qIndex(); - jnt.jcalc(J, q, qDot); + jnt.jcalc(J, state); S_[i] = J.S; S1_[i] = J.S1; @@ -247,7 +264,11 @@ void Foam::RBD::rigidBodyModel::forwardDynamicsCorrection c_[i] = J.c + (v_[i] ^ J.v); a_[i] = (Xlambda_[i] & a_[lambdai]) + c_[i]; - if (jnt.nDoF() == 1) + if (jnt.nDoF() == 0) + { + // do nothing + } + else if (jnt.nDoF() == 1) { a_[i] += S1_[i]*qDdot[qi]; } diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C index 4a8de4eac..e9306c564 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C +++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,7 +48,7 @@ void Foam::RBD::rigidBodyModel::initializeRootBody() bodies_.append(new masslessBody("root")); lambda_.append(0); bodyIDs_.insert("root", 0); - joints_.append(new joints::null()); + joints_.append(new joints::null(*this)); XT_.append(spatialTransform()); nDoF_ = 0; @@ -198,7 +198,7 @@ Foam::RBD::rigidBodyModel::rigidBodyModel(const dictionary& dict) ( bodyID(bodyDict.lookup("parent")), bodyDict.lookup("transform"), - joint::New(bodyDict.subDict("joint")), + joint::New(*this, bodyDict.subDict("joint")), rigidBody::New(iter().keyword(), bodyDict) ); }