rigidBodyModel: Added movingBodyNames() member function

which returns the list of names of the moving bodies in the model.
This commit is contained in:
Henry Weller
2019-03-01 13:44:01 +00:00
parent f60147fc11
commit a395752fa8
8 changed files with 69 additions and 51 deletions

View File

@ -384,6 +384,25 @@ Foam::spatialTransform Foam::RBD::rigidBodyModel::X0
}
Foam::wordList Foam::RBD::rigidBodyModel::movingBodyNames() const
{
wordList names(nBodies());
label j = 0;
for (label i=1; i<nBodies(); i++)
{
if (!isType<jointBody>(bodies_[i]))
{
names[j++] = bodies_[i].name();
}
}
names.setSize(j);
return names;
}
void Foam::RBD::rigidBodyModel::write(Ostream& os) const
{
os << indent << "bodies" << nl

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -252,6 +252,9 @@ public:
//- Return the name of body with the given ID
inline const word& name(const label bodyID) const;
//- Return the names of the moving bodies
wordList movingBodyNames() const;
//- Return the inertia of body i
inline const rigidBodyInertia& I(const label i) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -88,7 +88,7 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion
)
:
displacementMotionSolver(mesh, dict, typeName),
model_
RBD::rigidBodyMotion
(
coeffDict(),
IOobject
@ -141,7 +141,7 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion
if (bodyDict.found("patches"))
{
const label bodyID = model_.bodyID(iter().keyword());
const label bodyID = this->bodyID(iter().keyword());
if (bodyID == -1)
{
@ -239,7 +239,7 @@ void Foam::rigidBodyMeshMotion::solve()
// Store the motion state at the beginning of the time-step
if (curTimeIndex_ != this->db().time().timeIndex())
{
model_.newTime();
newTime();
curTimeIndex_ = this->db().time().timeIndex();
}
@ -247,7 +247,7 @@ void Foam::rigidBodyMeshMotion::solve()
if (db().foundObject<uniformDimensionedVectorField>("g"))
{
model_.g() =
g() =
ramp*db().lookupObject<uniformDimensionedVectorField>("g").value();
}
@ -257,18 +257,18 @@ void Foam::rigidBodyMeshMotion::solve()
for (label i=0; i<nIter; i++)
{
model_.solve
RBD::rigidBodyMotion::solve
(
t.value(),
t.deltaTValue(),
scalarField(model_.nDoF(), Zero),
Field<spatialVector>(model_.nBodies(), Zero)
scalarField(nDoF(), Zero),
Field<spatialVector>(nBodies(), Zero)
);
}
}
else
{
Field<spatialVector> fx(model_.nBodies(), Zero);
Field<spatialVector> fx(nBodies(), Zero);
forAll(bodyMeshes_, bi)
{
@ -287,27 +287,27 @@ void Foam::rigidBodyMeshMotion::solve()
fx[bodyID] = ramp*spatialVector(f.momentEff(), f.forceEff());
}
model_.solve
RBD::rigidBodyMotion::solve
(
t.value(),
t.deltaTValue(),
scalarField(model_.nDoF(), Zero),
scalarField(nDoF(), Zero),
fx
);
}
if (Pstream::master() && model_.report())
if (Pstream::master() && report())
{
forAll(bodyMeshes_, bi)
{
model_.status(bodyMeshes_[bi].bodyID_);
status(bodyMeshes_[bi].bodyID_);
}
}
// Update the displacements
if (bodyMeshes_.size() == 1)
{
pointDisplacement_.primitiveFieldRef() = model_.transformPoints
pointDisplacement_.primitiveFieldRef() = transformPoints
(
bodyMeshes_[0].bodyID_,
bodyMeshes_[0].weight_,
@ -325,7 +325,7 @@ void Foam::rigidBodyMeshMotion::solve()
}
pointDisplacement_.primitiveFieldRef() =
model_.transformPoints(bodyIDs, weights, points0()) - points0();
transformPoints(bodyIDs, weights, points0()) - points0();
}
// Displacement has changed. Update boundary conditions
@ -358,7 +358,7 @@ bool Foam::rigidBodyMeshMotion::writeObject
)
);
model_.state().write(dict);
state().write(dict);
return dict.regIOobject::write();
}
@ -367,7 +367,7 @@ bool Foam::rigidBodyMeshMotion::read()
{
if (displacementMotionSolver::read())
{
model_.read(coeffDict());
RBD::rigidBodyMotion::read(coeffDict());
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,7 +53,8 @@ namespace Foam
class rigidBodyMeshMotion
:
public displacementMotionSolver
public displacementMotionSolver,
public RBD::rigidBodyMotion
{
//- Class containing the patches and point motion weighting for each body
class bodyMesh
@ -97,9 +98,6 @@ class rigidBodyMeshMotion
// Private data
//- Rigid-body model
RBD::rigidBodyMotion model_;
//- List of the bodyMeshes containing the patches and point motion
// weighting for each body
PtrList<bodyMesh> bodyMeshes_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -71,7 +71,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
)
:
motionSolver(mesh, dict, typeName),
model_
RBD::rigidBodyMotion
(
coeffDict(),
IOobject
@ -132,7 +132,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
if (bodyDict.found("patches"))
{
const label bodyID = model_.bodyID(iter().keyword());
const label bodyID = this->bodyID(iter().keyword());
if (bodyID == -1)
{
@ -189,13 +189,13 @@ void Foam::rigidBodyMeshMotionSolver::solve()
// Store the motion state at the beginning of the time-step
if (curTimeIndex_ != this->db().time().timeIndex())
{
model_.newTime();
newTime();
curTimeIndex_ = this->db().time().timeIndex();
}
if (db().foundObject<uniformDimensionedVectorField>("g"))
{
model_.g() =
g() =
db().lookupObject<uniformDimensionedVectorField>("g").value();
}
@ -205,18 +205,18 @@ void Foam::rigidBodyMeshMotionSolver::solve()
for (label i=0; i<nIter; i++)
{
model_.solve
RBD::rigidBodyMotion::solve
(
t.value(),
t.deltaTValue(),
scalarField(model_.nDoF(), Zero),
Field<spatialVector>(model_.nBodies(), Zero)
scalarField(nDoF(), Zero),
Field<spatialVector>(nBodies(), Zero)
);
}
}
else
{
Field<spatialVector> fx(model_.nBodies(), Zero);
Field<spatialVector> fx(nBodies(), Zero);
forAll(bodyMeshes_, bi)
{
@ -235,20 +235,20 @@ void Foam::rigidBodyMeshMotionSolver::solve()
fx[bodyID] = spatialVector(f.momentEff(), f.forceEff());
}
model_.solve
RBD::rigidBodyMotion::solve
(
t.value(),
t.deltaTValue(),
scalarField(model_.nDoF(), Zero),
scalarField(nDoF(), Zero),
fx
);
}
if (Pstream::master() && model_.report())
if (Pstream::master() && report())
{
forAll(bodyMeshes_, bi)
{
model_.status(bodyMeshes_[bi].bodyID_);
status(bodyMeshes_[bi].bodyID_);
}
}
@ -267,7 +267,7 @@ void Foam::rigidBodyMeshMotionSolver::solve()
meshSolver_.pointDisplacement().boundaryFieldRef()[patchi] ==
(
model_.transformPoints
transformPoints
(
bodyMeshes_[bi].bodyID_,
patchPoints0
@ -302,7 +302,7 @@ bool Foam::rigidBodyMeshMotionSolver::writeObject
)
);
model_.state().write(dict);
state().write(dict);
return dict.regIOobject::write();
}
@ -311,7 +311,7 @@ bool Foam::rigidBodyMeshMotionSolver::read()
{
if (motionSolver::read())
{
model_.read(coeffDict());
RBD::rigidBodyMotion::read(coeffDict());
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -52,7 +52,8 @@ namespace Foam
class rigidBodyMeshMotionSolver
:
public motionSolver
public motionSolver,
public RBD::rigidBodyMotion
{
//- Class containing the patches and point motion weighting for each body
class bodyMesh
@ -86,9 +87,6 @@ class rigidBodyMeshMotionSolver
// Private data
//- Rigid-body model
RBD::rigidBodyMotion model_;
//- List of the bodyMeshes containing the patches and point motion
// weighting for each body
PtrList<bodyMesh> bodyMeshes_;

View File

@ -2,10 +2,8 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/sixDoFRigidBodyMotion/lnInclude \
-I$(LIB_SRC)/OpenFOAM/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
-I$(LIB_SRC)/sixDoFRigidBodyMotion/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools
-ldynamicFvMesh

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -125,9 +125,11 @@ public:
// Member Functions
vector velocity() const;
//- Return the current body velocity
vector velocity() const;
vector angularVelocity() const;
//- Return the current body angular velocity
vector angularVelocity() const;
//- Read the sixDoFRigidBodyState data
virtual bool read(const dictionary&);