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.
This commit is contained in:
Vuko Vukcevic 2017-03-07 12:37:03 +01:00 committed by Hrvoje Jasak
parent 041fddd197
commit bd820ac31b
9 changed files with 14 additions and 94 deletions

View file

@ -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"))

View file

@ -81,7 +81,6 @@ public:
constantAngularAcceleration
(
const word& name,
const sixDOFODE& sixDOFODE,
const dictionary& dict
);

View file

@ -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> Foam::rotationalConstraint::New
(
const word& name,
const sixDOFODE& sixDOFODE,
const dictionary& dict
)
{
@ -74,7 +69,6 @@ Foam::autoPtr<Foam::rotationalConstraint> 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> Foam::rotationalConstraint::New
cstrIter()
(
name,
sixDOFODE,
dict
)
);

View file

@ -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<rotationalConstraint> 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<rotationalConstraint> 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)

View file

@ -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")))
{}

View file

@ -77,7 +77,6 @@ public:
constantTranslationalAcceleration
(
const word& name,
const sixDOFODE& sixDOFODE,
const dictionary& dict
);

View file

@ -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> Foam::translationalConstraint::New
(
const word& name,
const sixDOFODE& sixDOFODE,
const dictionary& dict
)
{
@ -74,7 +69,6 @@ Foam::autoPtr<Foam::translationalConstraint> 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> Foam::translationalConstraint::New
cstrIter()
(
name,
sixDOFODE,
dict
)
);

View file

@ -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<translationalConstraint> 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<translationalConstraint> 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)

View file

@ -374,7 +374,7 @@ Foam::geometricSixDOF::geometricSixDOF(const IOobject& io)
PtrList<translationalConstraint> tcList
(
dict().lookup("translationalConstraints"),
translationalConstraint::iNew(*this)
translationalConstraint::iNew()
);
translationalConstraints_.transfer(tcList);
}
@ -385,7 +385,7 @@ Foam::geometricSixDOF::geometricSixDOF(const IOobject& io)
PtrList<rotationalConstraint> 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();
}