Updates in constraints and restraints classes

They now hold a reference to underlying sixDOFODE object. Need to handle more
complex restraints/constraints depending on its state.
This commit is contained in:
Vuko Vukcevic 2017-03-13 16:03:30 +01:00 committed by Hrvoje Jasak
parent 658362e122
commit a2f33fc147
19 changed files with 179 additions and 63 deletions

View file

@ -44,10 +44,11 @@ namespace Foam
Foam::constantAngularAcceleration::constantAngularAcceleration
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
rotationalConstraint(name, dict),
rotationalConstraint(name, dict, sixDOF),
dir_(dict.lookup("constraintDirection")),
alpha_(readScalar(dict.lookup("angularAcceleration"))),
inGlobal_(dict.lookup("inGlobalCoordinateSystem"))

View file

@ -81,7 +81,8 @@ public:
constantAngularAcceleration
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "rotationalConstraint.H"
#include "sixDOFODE.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,10 +39,12 @@ namespace Foam
Foam::rotationalConstraint::rotationalConstraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
name_(name)
name_(name),
sixDOF_(sixDOF)
{}
@ -56,7 +59,8 @@ Foam::rotationalConstraint::~rotationalConstraint()
Foam::autoPtr<Foam::rotationalConstraint> Foam::rotationalConstraint::New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
{
const word constraintType(dict.lookup("type"));
@ -85,7 +89,8 @@ Foam::autoPtr<Foam::rotationalConstraint> Foam::rotationalConstraint::New
cstrIter()
(
name,
dict
dict,
sixDOF
)
);
}

View file

@ -72,6 +72,8 @@ SourceFiles
namespace Foam
{
class sixDOFODE;
/*---------------------------------------------------------------------------*\
Class rotationalConstraint Declaration
\*---------------------------------------------------------------------------*/
@ -83,6 +85,8 @@ class rotationalConstraint
//- Name of the constraint
word name_;
//- Reference to underlying sixDOFODE
const sixDOFODE& sixDOF_;
public:
@ -99,9 +103,10 @@ public:
word,
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
),
(name, dict)
(name, dict, sixDOF)
);
@ -109,16 +114,20 @@ public:
// PtrLists of rotationalConstraint
class iNew
{
const sixDOFODE& sixDOF_;
public:
iNew()
iNew(const sixDOFODE& sixDOF)
:
sixDOF_(sixDOF)
{}
autoPtr<rotationalConstraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return rotationalConstraint::New(name, dict);
return rotationalConstraint::New(name, dict, sixDOF_);
}
};
@ -129,7 +138,8 @@ public:
rotationalConstraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone
@ -142,7 +152,8 @@ public:
static autoPtr<rotationalConstraint> New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);

View file

@ -44,10 +44,11 @@ namespace Foam
Foam::constantTranslationalAcceleration::constantTranslationalAcceleration
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
translationalConstraint(name, dict),
translationalConstraint(name, dict, sixDOF),
dir_(dict.lookup("constraintDirection")),
a_(readScalar(dict.lookup("translationalAcceleration")))
{

View file

@ -77,7 +77,8 @@ public:
constantTranslationalAcceleration
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone

View file

@ -45,10 +45,11 @@ namespace Foam
Foam::periodicOscillation::periodicOscillation
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
translationalConstraint(name, dict),
translationalConstraint(name, dict, sixDOF),
dir_(dict.lookup("direction")),
a_(readScalar(dict.lookup("motionAmplitude"))),
period_(readScalar(dict.lookup("period"))),

View file

@ -94,7 +94,8 @@ public:
periodicOscillation
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "translationalConstraint.H"
#include "sixDOFODE.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,10 +39,12 @@ namespace Foam
Foam::translationalConstraint::translationalConstraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
name_(name)
name_(name),
sixDOF_(sixDOF)
{}
@ -56,7 +59,8 @@ Foam::translationalConstraint::~translationalConstraint()
Foam::autoPtr<Foam::translationalConstraint> Foam::translationalConstraint::New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
{
const word constraintType(dict.lookup("type"));
@ -85,7 +89,8 @@ Foam::autoPtr<Foam::translationalConstraint> Foam::translationalConstraint::New
cstrIter()
(
name,
dict
dict,
sixDOF
)
);
}

View file

@ -72,6 +72,8 @@ SourceFiles
namespace Foam
{
class sixDOFODE;
/*---------------------------------------------------------------------------*\
Class translationalConstraint Declaration
\*---------------------------------------------------------------------------*/
@ -83,6 +85,8 @@ class translationalConstraint
//- Name of the constraint
word name_;
//- Reference to underlying sixDOFODE
const sixDOFODE& sixDOF_;
public:
@ -99,9 +103,10 @@ public:
word,
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
),
(name, dict)
(name, dict, sixDOF)
);
@ -109,16 +114,20 @@ public:
// PtrLists of translationalConstraint
class iNew
{
const sixDOFODE& sixDOF_;
public:
iNew()
iNew(const sixDOFODE& sixDOF)
:
sixDOF_(sixDOF)
{}
autoPtr<translationalConstraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return translationalConstraint::New(name, dict);
return translationalConstraint::New(name, dict, sixDOF_);
}
};
@ -129,7 +138,8 @@ public:
translationalConstraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone
@ -142,7 +152,8 @@ public:
static autoPtr<translationalConstraint> New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);

View file

@ -44,10 +44,11 @@ namespace Foam
Foam::angularDamper::angularDamper
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
rotationalRestraint(name, dict),
rotationalRestraint(name, dict, sixDOF),
angDampingCoeffs_(dict.lookup("angularDamping")),
inGlobal_(dict.lookup("inGlobalCoordinateSystem"))
{}

View file

@ -75,7 +75,8 @@ public:
angularDamper
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "rotationalRestraint.H"
#include "sixDOFODE.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,10 +39,12 @@ namespace Foam
Foam::rotationalRestraint::rotationalRestraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
name_(name)
name_(name),
sixDOF_(sixDOF)
{}
@ -56,7 +59,8 @@ Foam::rotationalRestraint::~rotationalRestraint()
Foam::autoPtr<Foam::rotationalRestraint> Foam::rotationalRestraint::New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
{
const word restraintType(dict.lookup("type"));
@ -85,7 +89,8 @@ Foam::autoPtr<Foam::rotationalRestraint> Foam::rotationalRestraint::New
cstrIter()
(
name,
dict
dict,
sixDOF
)
);
}

View file

@ -54,6 +54,8 @@ SourceFiles
namespace Foam
{
class sixDOFODE;
/*---------------------------------------------------------------------------*\
Class rotationalRestraint Declaration
\*---------------------------------------------------------------------------*/
@ -65,6 +67,8 @@ class rotationalRestraint
//- Name of the restraint
word name_;
//- Reference to underlying sixDOFODE
const sixDOFODE& sixDOF_;
public:
@ -81,9 +85,10 @@ public:
word,
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
),
(name, dict)
(name, dict, sixDOF)
);
@ -91,16 +96,20 @@ public:
// PtrLists of rotationalRestraint
class iNew
{
const sixDOFODE& sixDOF_;
public:
iNew()
iNew(const sixDOFODE& sixDOF)
:
sixDOF_(sixDOF)
{}
autoPtr<rotationalRestraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return rotationalRestraint::New(name, dict);
return rotationalRestraint::New(name, dict, sixDOF_);
}
};
@ -111,7 +120,8 @@ public:
rotationalRestraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone
@ -124,7 +134,8 @@ public:
static autoPtr<rotationalRestraint> New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);

View file

@ -44,10 +44,11 @@ namespace Foam
Foam::linearSpringDamper::linearSpringDamper
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
translationalRestraint(name, dict),
translationalRestraint(name, dict, sixDOF),
linSpringCoeffs_(dict.lookup("linearSpring")),
linDampingCoeffs_(dict.lookup("linearDamping"))
{}

View file

@ -75,7 +75,8 @@ public:
linearSpringDamper
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "translationalRestraint.H"
#include "sixDOFODE.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,10 +39,12 @@ namespace Foam
Foam::translationalRestraint::translationalRestraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
name_(name)
name_(name),
sixDOF_(sixDOF)
{}
@ -56,7 +59,8 @@ Foam::translationalRestraint::~translationalRestraint()
Foam::autoPtr<Foam::translationalRestraint> Foam::translationalRestraint::New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
)
{
const word restraintType(dict.lookup("type"));
@ -85,7 +89,8 @@ Foam::autoPtr<Foam::translationalRestraint> Foam::translationalRestraint::New
cstrIter()
(
name,
dict
dict,
sixDOF
)
);
}

View file

@ -54,6 +54,8 @@ SourceFiles
namespace Foam
{
class sixDOFODE;
/*---------------------------------------------------------------------------*\
Class translationalRestraint Declaration
\*---------------------------------------------------------------------------*/
@ -65,6 +67,8 @@ class translationalRestraint
//- Name of the restraint
word name_;
//- Reference to underlying sixDOFODE
const sixDOFODE& sixDOF_;
public:
@ -81,9 +85,10 @@ public:
word,
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
),
(name, dict)
(name, dict, sixDOF)
);
@ -91,16 +96,20 @@ public:
// PtrLists of translationalRestraint
class iNew
{
const sixDOFODE& sixDOF_;
public:
iNew()
iNew(const sixDOFODE& sixDOF)
:
sixDOF_(sixDOF)
{}
autoPtr<translationalRestraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return translationalRestraint::New(name, dict);
return translationalRestraint::New(name, dict, sixDOF_);
}
};
@ -111,7 +120,8 @@ public:
translationalRestraint
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone
@ -124,7 +134,8 @@ public:
static autoPtr<translationalRestraint> New
(
const word& name,
const dictionary& dict
const dictionary& dict,
const sixDOFODE& sixDOF
);

View file

@ -195,13 +195,55 @@ void Foam::sixDOFODE::setState(const sixDOFODE& sd)
force_ = sd.force_;
moment_ = sd.moment_;
// Copy constraints
translationalConstraints_ = sd.translationalConstraints_;
rotationalConstraints_ = sd.rotationalConstraints_;
// Translational constraints
translationalConstraints_.setSize(sd.translationalConstraints_.size());
forAll(sd.translationalConstraints_, trI)
{
translationalConstraints_.set
(
trI,
sd.translationalConstraints_[trI].clone()
);
}
// Rotational constraints
rotationalConstraints_.setSize(sd.rotationalConstraints_.size());
forAll(sd.rotationalConstraints_, rrI)
{
rotationalConstraints_.set
(
rrI,
sd.rotationalConstraints_[rrI].clone()
);
}
// Copy restraints
translationalRestraints_ = sd.translationalRestraints_;
rotationalRestraints_ = sd.rotationalRestraints_;
// Translational restraints
translationalRestraints_.setSize(sd.translationalRestraints_.size());
forAll(sd.translationalRestraints_, trI)
{
translationalRestraints_.set
(
trI,
sd.translationalRestraints_[trI].clone()
);
}
// Rotational restraints
rotationalRestraints_.setSize(sd.rotationalRestraints_.size());
forAll(sd.rotationalRestraints_, rrI)
{
rotationalRestraints_.set
(
rrI,
sd.rotationalRestraints_[rrI].clone()
);
}
}
@ -352,7 +394,7 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
PtrList<translationalConstraint> tcList
(
dict().lookup("translationalConstraints"),
translationalConstraint::iNew()
translationalConstraint::iNew(*this)
);
translationalConstraints_.transfer(tcList);
}
@ -363,7 +405,7 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
PtrList<rotationalConstraint> rcList
(
dict().lookup("rotationalConstraints"),
rotationalConstraint::iNew()
rotationalConstraint::iNew(*this)
);
rotationalConstraints_.transfer(rcList);
}
@ -374,7 +416,7 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
PtrList<translationalRestraint> tcList
(
dict().lookup("translationalRestraints"),
translationalRestraint::iNew()
translationalRestraint::iNew(*this)
);
translationalRestraints_.transfer(tcList);
}
@ -385,7 +427,7 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
PtrList<rotationalRestraint> rcList
(
dict().lookup("rotationalRestraints"),
rotationalRestraint::iNew()
rotationalRestraint::iNew(*this)
);
rotationalRestraints_.transfer(rcList);
}