From bd820ac31bcf533cca545bdb090c7e7ae84c48c1 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Tue, 7 Mar 2017 12:37:03 +0100 Subject: [PATCH] Implementation of constraints, part 4 Version that works (compiles and runs properly). To do: 1. Writing out constraints to dictionary for proper restart, 2. Stabilisation of round-off errors when using constraints. --- .../constantAngularAcceleration.C | 3 +- .../constantAngularAcceleration.H | 1 - .../rotationalConstraint.C | 7 ---- .../rotationalConstraint.H | 37 ++----------------- .../constantTranslationalAcceleration.C | 3 +- .../constantTranslationalAcceleration.H | 1 - .../translationalConstraint.C | 7 ---- .../translationalConstraint.H | 37 ++----------------- .../sixDOF/geometricSixDOF/geometricSixDOF.C | 12 +++--- 9 files changed, 14 insertions(+), 94 deletions(-) diff --git a/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.C b/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.C index 289c0560b..4a6e2e1b8 100644 --- a/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.C +++ b/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.C @@ -44,11 +44,10 @@ namespace Foam Foam::constantAngularAcceleration::constantAngularAcceleration ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ) : - rotationalConstraint(name, sixDOFODE, dict), + rotationalConstraint(name, dict), dir_(dict.lookup("constraintDirection")), alpha_(readScalar(dict.lookup("angularAcceleration"))), inGlobal_(dict.lookup("inGlobalCoordinateSystem")) diff --git a/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.H b/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.H index ccc8ba922..13abf0295 100644 --- a/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.H +++ b/src/ODE/sixDOF/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.H @@ -81,7 +81,6 @@ public: constantAngularAcceleration ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ); diff --git a/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.C b/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.C index 1bbf07157..0ec019e26 100644 --- a/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.C +++ b/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.C @@ -38,12 +38,8 @@ namespace Foam Foam::rotationalConstraint::rotationalConstraint ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ) -: - name_(name), - sixDOFODE_(sixDOFODE) {} @@ -58,7 +54,6 @@ Foam::rotationalConstraint::~rotationalConstraint() Foam::autoPtr Foam::rotationalConstraint::New ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ) { @@ -74,7 +69,6 @@ Foam::autoPtr Foam::rotationalConstraint::New "rotationalConstraint::New" "\n(" "\n const word& name," - "\n const sixDOFODE& sixDOFODE," "\n const dictionary& dict," "\n)" ) << "Unknown rotation constraint type: " << constraintType @@ -89,7 +83,6 @@ Foam::autoPtr Foam::rotationalConstraint::New cstrIter() ( name, - sixDOFODE, dict ) ); diff --git a/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.H b/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.H index 9b7a32118..223cb01e7 100644 --- a/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.H +++ b/src/ODE/sixDOF/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.H @@ -69,15 +69,6 @@ namespace Foam class rotationalConstraint { - // Private data - - //- Name of the constraint - const word name_; - - //- Reference to underlying sixDOFODE - const sixDOFODE& sixDOFODE_; - - public: //- Runtime type information @@ -93,10 +84,9 @@ public: word, ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ), - (name, sixDOFODE, dict) + (name, dict) ); @@ -104,20 +94,16 @@ public: // PtrLists of rotationalConstraint class iNew { - const sixDOFODE& sixDOFODE_; - public: - iNew(const sixDOFODE& sixDOFODE) - : - sixDOFODE_(sixDOFODE) + iNew() {} autoPtr operator()(Istream& is) const { word name(is); dictionary dict(is); - return rotationalConstraint::New(name, sixDOFODE_, dict); + return rotationalConstraint::New(name, dict); } }; @@ -128,7 +114,6 @@ public: rotationalConstraint ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ); @@ -142,7 +127,6 @@ public: static autoPtr New ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ); @@ -154,21 +138,6 @@ public: // Member Functions - // Access functions - - //- Return const reference to name of the constraint - const word& name() const - { - return name_; - } - - //- Return const reference to underlying sixDOFODE object - const sixDOFODE& sixDOF() const - { - return sixDOFODE_; - } - - // Constraint specific functions //- Return matrix contribution defined by constraint, f(t) diff --git a/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C b/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C index bf99874a7..6d47de405 100644 --- a/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C +++ b/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C @@ -44,11 +44,10 @@ namespace Foam Foam::constantTranslationalAcceleration::constantTranslationalAcceleration ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ) : - translationalConstraint(name, sixDOFODE, dict), + translationalConstraint(name, dict), dir_(dict.lookup("constraintDirection")), a_(readScalar(dict.lookup("translationalAcceleration"))) {} diff --git a/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.H b/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.H index 472f44c1d..9a697baf7 100644 --- a/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.H +++ b/src/ODE/sixDOF/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.H @@ -77,7 +77,6 @@ public: constantTranslationalAcceleration ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ); diff --git a/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C b/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C index e2b2d805a..b7adb8c99 100644 --- a/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C +++ b/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C @@ -38,12 +38,8 @@ namespace Foam Foam::translationalConstraint::translationalConstraint ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ) -: - name_(name), - sixDOFODE_(sixDOFODE) {} @@ -58,7 +54,6 @@ Foam::translationalConstraint::~translationalConstraint() Foam::autoPtr Foam::translationalConstraint::New ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ) { @@ -74,7 +69,6 @@ Foam::autoPtr Foam::translationalConstraint::New "translationalConstraint::New" "\n(" "\n const word& name," - "\n const sixDOFODE& sixDOFODE," "\n const dictionary& dict," "\n)" ) << "Unknown translation constraint type: " << constraintType @@ -89,7 +83,6 @@ Foam::autoPtr Foam::translationalConstraint::New cstrIter() ( name, - sixDOFODE, dict ) ); diff --git a/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.H b/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.H index 3a998e23c..e9de8ed58 100644 --- a/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.H +++ b/src/ODE/sixDOF/constraints/translationalConstraints/translationalConstraint/translationalConstraint.H @@ -69,15 +69,6 @@ namespace Foam class translationalConstraint { - // Private data - - //- Name of the constraint - const word name_; - - //- Reference to underlying sixDOFODE - const sixDOFODE& sixDOFODE_; - - public: //- Runtime type information @@ -93,10 +84,9 @@ public: word, ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ), - (name, sixDOFODE, dict) + (name, dict) ); @@ -104,20 +94,16 @@ public: // PtrLists of translationalConstraint class iNew { - const sixDOFODE& sixDOFODE_; - public: - iNew(const sixDOFODE& sixDOFODE) - : - sixDOFODE_(sixDOFODE) + iNew() {} autoPtr operator()(Istream& is) const { word name(is); dictionary dict(is); - return translationalConstraint::New(name, sixDOFODE_, dict); + return translationalConstraint::New(name, dict); } }; @@ -128,7 +114,6 @@ public: translationalConstraint ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ); @@ -142,7 +127,6 @@ public: static autoPtr New ( const word& name, - const sixDOFODE& sixDOFODE, const dictionary& dict ); @@ -154,21 +138,6 @@ public: // Member Functions - // Access functions - - //- Return const reference to name of the constraint - const word& name() const - { - return name_; - } - - //- Return const reference to underlying sixDOFODE object - const sixDOFODE& sixDOF() const - { - return sixDOFODE_; - } - - // Constraint specific functions //- Return matrix contribution defined by constraint, f(t) diff --git a/src/ODE/sixDOF/geometricSixDOF/geometricSixDOF.C b/src/ODE/sixDOF/geometricSixDOF/geometricSixDOF.C index edfd01340..ed54d7612 100644 --- a/src/ODE/sixDOF/geometricSixDOF/geometricSixDOF.C +++ b/src/ODE/sixDOF/geometricSixDOF/geometricSixDOF.C @@ -374,7 +374,7 @@ Foam::geometricSixDOF::geometricSixDOF(const IOobject& io) PtrList tcList ( dict().lookup("translationalConstraints"), - translationalConstraint::iNew(*this) + translationalConstraint::iNew() ); translationalConstraints_.transfer(tcList); } @@ -385,7 +385,7 @@ Foam::geometricSixDOF::geometricSixDOF(const IOobject& io) PtrList tcList ( dict().lookup("rotationalConstraints"), - rotationalConstraint::iNew(*this) + rotationalConstraint::iNew() ); rotationalConstraints_.transfer(tcList); } @@ -626,10 +626,10 @@ bool Foam::geometricSixDOF::writeData(Ostream& os) const os.writeKeyword("omega") << tab << omega_ << token::END_STATEMENT << nl << nl; - os.writeKeyword("translationalConstraints") << tab - << translationalConstraints_ << token::END_STATEMENT << nl; - os.writeKeyword("rotationalConstraints") << tab - << rotationalConstraints_ << token::END_STATEMENT << nl << endl; +// os.writeKeyword("translationalConstraints") << tab +// << translationalConstraints_ << token::END_STATEMENT << nl; +// os.writeKeyword("rotationalConstraints") << tab +// << rotationalConstraints_ << token::END_STATEMENT << nl << endl; return os.good(); }