src/rigidBodyDynamics/bodies: Added write
This commit is contained in:
parent
343136e6cc
commit
67c2cbfe4b
@ -1,5 +1,6 @@
|
|||||||
bodies/rigidBody/rigidBody.C
|
bodies/rigidBody/rigidBody.C
|
||||||
bodies/masslessBody/masslessBody.C
|
bodies/masslessBody/masslessBody.C
|
||||||
|
bodies/subBody/subBody.C
|
||||||
bodies/sphere/sphere.C
|
bodies/sphere/sphere.C
|
||||||
|
|
||||||
joints/joint/joint.C
|
joints/joint/joint.C
|
||||||
|
@ -39,4 +39,8 @@ bool Foam::RBD::masslessBody::massless() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::RBD::masslessBody::write(Ostream& os) const
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -41,19 +41,9 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of Foam classes
|
|
||||||
class Istream;
|
|
||||||
class Ostream;
|
|
||||||
|
|
||||||
namespace RBD
|
namespace RBD
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
class masslessBody;
|
|
||||||
Ostream& operator<<(Ostream&, const masslessBody&);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class masslessBody Declaration
|
Class masslessBody Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -83,10 +73,8 @@ public:
|
|||||||
//- Return true if this body is a massless component of a composite body
|
//- Return true if this body is a massless component of a composite body
|
||||||
virtual bool massless() const;
|
virtual bool massless() const;
|
||||||
|
|
||||||
|
//- Write
|
||||||
// IOstream Operators
|
virtual void write(Ostream&) const;
|
||||||
|
|
||||||
//friend Ostream& operator<<(Ostream&, const masslessBody&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,4 +64,17 @@ void Foam::RBD::rigidBody::merge(const subBody& subBody)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::RBD::rigidBody::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.writeKeyword("mass")
|
||||||
|
<< m() << token::END_STATEMENT << nl;
|
||||||
|
|
||||||
|
os.writeKeyword("centreOfMass")
|
||||||
|
<< c() << token::END_STATEMENT << nl;
|
||||||
|
|
||||||
|
os.writeKeyword("Inertia")
|
||||||
|
<< Ic() << token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -40,22 +40,12 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of Foam classes
|
|
||||||
class Istream;
|
|
||||||
class Ostream;
|
|
||||||
|
|
||||||
namespace RBD
|
namespace RBD
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
// Forward declaration of classes
|
||||||
class subBody;
|
class subBody;
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
class rigidBody;
|
|
||||||
Ostream& operator<<(Ostream&, const rigidBody&);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class rigidBody Declaration
|
Class rigidBody Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -122,10 +112,8 @@ public:
|
|||||||
//- Merge a body into this parent body
|
//- Merge a body into this parent body
|
||||||
void merge(const subBody&);
|
void merge(const subBody&);
|
||||||
|
|
||||||
|
//- Write
|
||||||
// IOstream Operators
|
virtual void write(Ostream&) const;
|
||||||
|
|
||||||
//friend Ostream& operator<<(Ostream&, const rigidBody&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,4 +33,14 @@ Foam::RBD::sphere::~sphere()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::RBD::sphere::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.writeKeyword("mass")
|
||||||
|
<< m() << token::END_STATEMENT << nl;
|
||||||
|
|
||||||
|
os.writeKeyword("radius")
|
||||||
|
<< r() << token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -25,6 +25,7 @@ Class
|
|||||||
Foam::sphere
|
Foam::sphere
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
Specialization of rigidBody to construct a sphere given the mass and radius.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
sphereI.H
|
sphereI.H
|
||||||
@ -41,19 +42,9 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of Foam classes
|
|
||||||
class Istream;
|
|
||||||
class Ostream;
|
|
||||||
|
|
||||||
namespace RBD
|
namespace RBD
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
class sphere;
|
|
||||||
Ostream& operator<<(Ostream&, const sphere&);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class sphere Declaration
|
Class sphere Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -62,6 +53,11 @@ class sphere
|
|||||||
:
|
:
|
||||||
public rigidBody
|
public rigidBody
|
||||||
{
|
{
|
||||||
|
// Private member data
|
||||||
|
|
||||||
|
//- Radius
|
||||||
|
scalar r_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -77,9 +73,11 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// IOstream Operators
|
//- Return the radius of the sphere
|
||||||
|
inline scalar r() const;
|
||||||
|
|
||||||
//friend Ostream& operator<<(Ostream&, const sphere&);
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,8 +32,17 @@ inline Foam::RBD::sphere::sphere
|
|||||||
const scalar r
|
const scalar r
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
rigidBody(name, m, Zero, (2.0/5.0)*m*sqr(r)*I)
|
rigidBody(name, m, Zero, (2.0/5.0)*m*sqr(r)*I),
|
||||||
|
r_(r)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::RBD::sphere::r() const
|
||||||
|
{
|
||||||
|
return r_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
46
src/rigidBodyDynamics/bodies/subBody/subBody.C
Normal file
46
src/rigidBodyDynamics/bodies/subBody/subBody.C
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "subBody.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::RBD::subBody::~subBody()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::RBD::subBody::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.writeKeyword("parentBody")
|
||||||
|
<< parentName_ << token::END_STATEMENT << nl;
|
||||||
|
|
||||||
|
os.writeKeyword("transform")
|
||||||
|
<< parentXT_ << token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -43,19 +43,9 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of Foam classes
|
|
||||||
class Istream;
|
|
||||||
class Ostream;
|
|
||||||
|
|
||||||
namespace RBD
|
namespace RBD
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
class subBody;
|
|
||||||
Ostream& operator<<(Ostream&, const subBody&);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class subBody Declaration
|
Class subBody Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -69,6 +59,9 @@ class subBody
|
|||||||
//- Original body from which this sub-body was constructed
|
//- Original body from which this sub-body was constructed
|
||||||
autoPtr<rigidBody> body_;
|
autoPtr<rigidBody> body_;
|
||||||
|
|
||||||
|
//- Parent body name
|
||||||
|
word parentName_;
|
||||||
|
|
||||||
//- Parent body ID
|
//- Parent body ID
|
||||||
label parentID_;
|
label parentID_;
|
||||||
|
|
||||||
@ -86,26 +79,32 @@ public:
|
|||||||
inline subBody
|
inline subBody
|
||||||
(
|
(
|
||||||
autoPtr<rigidBody> bodyPtr,
|
autoPtr<rigidBody> bodyPtr,
|
||||||
|
const word& parentName,
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& parentXT
|
const spatialTransform& parentXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~subBody();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the original body from which this sub-body was constructed
|
//- Return the original body from which this sub-body was constructed
|
||||||
inline const rigidBody& body() const;
|
inline const rigidBody& body() const;
|
||||||
|
|
||||||
|
//- Return the parent body name
|
||||||
|
inline const word& parentName() const;
|
||||||
|
|
||||||
//- Return the parent body Id
|
//- Return the parent body Id
|
||||||
inline label parentID() const;
|
inline label parentID() const;
|
||||||
|
|
||||||
//- Return the transform with respect to the parent body
|
//- Return the transform with respect to the parent body
|
||||||
inline const spatialTransform& parentXT() const;
|
inline const spatialTransform& parentXT() const;
|
||||||
|
|
||||||
|
//- Write
|
||||||
// IOstream Operators
|
virtual void write(Ostream&) const;
|
||||||
|
|
||||||
//friend Ostream& operator<<(Ostream&, const subBody&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,12 +28,14 @@ License
|
|||||||
inline Foam::RBD::subBody::subBody
|
inline Foam::RBD::subBody::subBody
|
||||||
(
|
(
|
||||||
autoPtr<rigidBody> bodyPtr,
|
autoPtr<rigidBody> bodyPtr,
|
||||||
|
const word& parentName,
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& parentXT
|
const spatialTransform& parentXT
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
rigidBody(bodyPtr()),
|
rigidBody(bodyPtr()),
|
||||||
body_(bodyPtr),
|
body_(bodyPtr),
|
||||||
|
parentName_(parentName),
|
||||||
parentID_(parentID),
|
parentID_(parentID),
|
||||||
parentXT_(parentXT)
|
parentXT_(parentXT)
|
||||||
{}
|
{}
|
||||||
@ -47,6 +49,12 @@ inline const Foam::RBD::rigidBody& Foam::RBD::subBody::body() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::word& Foam::RBD::subBody::parentName() const
|
||||||
|
{
|
||||||
|
return parentName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::RBD::subBody::parentID() const
|
inline Foam::label Foam::RBD::subBody::parentID() const
|
||||||
{
|
{
|
||||||
return parentID_;
|
return parentID_;
|
||||||
|
@ -188,6 +188,7 @@ Foam::label Foam::RBD::rigidBodyModel::merge
|
|||||||
new subBody
|
new subBody
|
||||||
(
|
(
|
||||||
bodyPtr,
|
bodyPtr,
|
||||||
|
bodies_[sBody.parentID()].name(),
|
||||||
sBody.parentID(),
|
sBody.parentID(),
|
||||||
XT & sBody.parentXT()
|
XT & sBody.parentXT()
|
||||||
)
|
)
|
||||||
@ -195,7 +196,16 @@ Foam::label Foam::RBD::rigidBodyModel::merge
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sBodyPtr.set(new subBody(bodyPtr, parentID, XT));
|
sBodyPtr.set
|
||||||
|
(
|
||||||
|
new subBody
|
||||||
|
(
|
||||||
|
bodyPtr,
|
||||||
|
bodies_[parentID].name(),
|
||||||
|
parentID,
|
||||||
|
XT
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const subBody& sBody = sBodyPtr();
|
const subBody& sBody = sBodyPtr();
|
||||||
|
Loading…
Reference in New Issue
Block a user