rigidBodyDynamics: Simplified the IO of bodies

This commit is contained in:
Henry Weller
2016-04-08 16:56:48 +01:00
parent e2c9cb4563
commit 33a97bb848
7 changed files with 36 additions and 13 deletions

View File

@ -3,10 +3,10 @@ bodies0
pendulum
{
type rigidBody;
parent root;
mass 1;
centreOfMass (0 -1 0);
inertia (0.001 0 0 0.001 0 0.001);
parent root;
transform (1 0 0 0 1 0 0 0 1) (0 0 0);
joint
{
@ -30,9 +30,9 @@ bodies
weight
{
type sphere;
mergeWith hinge;
mass 1;
radius 0.05;
transform (1 0 0 0 1 0 0 0 1) (0 -1 0);
mergeWith hinge;
}
}

View File

@ -67,7 +67,10 @@ bool Foam::RBD::masslessBody::massless() const
void Foam::RBD::masslessBody::write(Ostream& os) const
{}
{
os.writeKeyword("type")
<< type() << token::END_STATEMENT << nl;
}
// ************************************************************************* //

View File

@ -119,6 +119,9 @@ void Foam::RBD::rigidBody::merge(const subBody& subBody)
void Foam::RBD::rigidBody::write(Ostream& os) const
{
os.writeKeyword("type")
<< type() << token::END_STATEMENT << nl;
os.writeKeyword("mass")
<< m() << token::END_STATEMENT << nl;

View File

@ -48,6 +48,12 @@ namespace RBD
// Forward declaration of classes
class subBody;
// Forward declaration of friend functions and operators
class rigidBody;
inline Ostream& operator<<(Ostream&, const rigidBody&);
/*---------------------------------------------------------------------------*\
Class rigidBody Declaration
\*---------------------------------------------------------------------------*/
@ -146,6 +152,11 @@ public:
//- Write
virtual void write(Ostream&) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const rigidBody&);
};

View File

@ -68,4 +68,13 @@ inline const Foam::word& Foam::RBD::rigidBody::name() const
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Foam::Ostream& Foam::RBD::operator<<(Ostream& os, const rigidBody& rb)
{
rb.write(os);
return os;
}
// ************************************************************************* //

View File

@ -62,6 +62,9 @@ Foam::RBD::sphere::~sphere()
void Foam::RBD::sphere::write(Ostream& os) const
{
os.writeKeyword("type")
<< type() << token::END_STATEMENT << nl;
os.writeKeyword("mass")
<< m() << token::END_STATEMENT << nl;

View File

@ -344,14 +344,11 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const
os << indent << bodies_[i].name() << nl
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
os.writeKeyword("type")
<< bodies_[i].type() << token::END_STATEMENT << nl;
bodies_[i].write(os);
os.writeKeyword("parent")
<< bodies_[lambda_[i]].name() << token::END_STATEMENT << nl;
bodies_[i].write(os);
os.writeKeyword("transform")
<< XT_[i] << token::END_STATEMENT << nl;
@ -366,17 +363,14 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const
os << indent << mergedBodies_[i].name() << nl
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
os.writeKeyword("type")
<< mergedBodies_[i].body().type() << token::END_STATEMENT << nl;
os.writeKeyword("mergeWith")
<< mergedBodies_[i].parentName() << token::END_STATEMENT << nl;
mergedBodies_[i].body().write(os);
os.writeKeyword("transform")
<< mergedBodies_[i].parentXT() << token::END_STATEMENT << nl;
os.writeKeyword("mergeWith")
<< mergedBodies_[i].parentName() << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}