Commit 33a97bb8 authored by Henry Weller's avatar Henry Weller
Browse files

rigidBodyDynamics: Simplified the IO of bodies

parent e2c9cb45
......@@ -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;
}
}
......@@ -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;
}
// ************************************************************************* //
......@@ -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;
......
......@@ -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&);
};
......
......@@ -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;
}
// ************************************************************************* //
......@@ -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;
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment