Pz.C
src/rigidBodyDynamics/joints/Pz/Pz.C
sourceCode
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "Pz.H"
#include "rigidBodyModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
defineTypeNameAndDebug(Pz, 0);
addToRunTimeSelectionTable
(
joint,
Pz,
dictionary
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Pz::Pz()
:
joint(1)
{
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
}
Foam::RBD::joints::Pz::Pz(const dictionary& dict)
:
joint(1)
{
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
}
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joints::Pz::clone() const
{
return autoPtr<joint>(new Pz(*this));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::joints::Pz::~Pz()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::joints::Pz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
) const
{
J.X = Xt(S_[0].l()*q[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.c = Zero;
}
// ************************************************************************* //
プログラム内部から直接呼び出す用
Foam::RBD::joints::Pz::Pz()
:
joint(1)
{
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
}
ディクショナリから読み込んで呼び出す用
Foam::RBD::joints::Pz::Pz(const dictionary& dict)
:
joint(1)
{
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
}
joint(1)は1自由度という意味。
この数値は計算の軽量化のために存在する.
ジョイントの変位q, 速度qDot, 加速度qDdotは, 全剛体のそれぞれ値を
q = [ Px1, Py1, Pz1, Rx1, Ry1, Rz1, Px2, Py2, Pz2, Rx2, Ry2, Rz2, Px3, ...]
という風に配列で保存している. S_[0]は(回転 並進)だが, この配列は[並進 回転 並進 回転]の順で格納される.)
qIndex_は, その剛体に対応した値が格納されている範囲の最初の配列番号を返す.
例えば、先の例のqで剛体2のq[qIndex_]を出力するなら, 剛体2に対応する値はPx2, Py2, Pz2, Rx2, Ry2, Rz2なので、最初の配列はPx2である.
Px2の配列番号は6なので、q[qIndex_]はq[6]と同義となる.
ここで, 自由度が拘束された場合を考えてみる.
Pz.Cは$x$軸と$y$軸を拘束するため, この拘束を適応した剛体の並進$x$軸と$y$軸は, 変位も速度も加速度も常に$0$である.(ベクトルのランクが2つ落ちている)
変わらないことが分かっている値を計算してもしょうがないので, 拘束された軸の値は省いて格納される. (計算の軽量化)
例えば, 剛体2をjoints ( {type Pz;} {type Rxyz;} );としたならば,
q = [ Px1, Py1, Pz1, Rx1, Ry1, Rz1, Pz2, Rx2, Ry2, Rz2, Px3, ...]
という感じで並進の値が1つになる. この場合もq[qIndex_]はq[6]だが, 始まりの値がPz2なので,
出力される値は$z$軸の並進変位となる.
Pz.Cの末尾に記述されているjcalcの処理では, これを利用している.
void Foam::RBD::joints::Pz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
) const
{
J.X = Xt(S_[0].l()*q[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.c = Zero;
}
q, qDot, qDdotは[剛体1の並進 剛体1の回転 剛体2の並進 剛体2の回転 剛体3の並進 ...]という順で格納されるので,
$x, y$軸の並進が無くなるPz.Cは必然的に剛体に対応した最初の数値がPzになるのである.
そのため, q[qIndex_]と書けばPzの値が取り出せるのである.
J.S1は1自由度の場合に使われる変数で, forwardDynamics内では1自由度か, そうでないかで場合分けされて計算している.
おそらく計算の軽量化のためだと思われる.