Commit 9c0c6c5f authored by Henry Weller's avatar Henry Weller
Browse files

SpatialVector: Added component access member functions

wx(), wy(), wz(), lx(), ly() and lz()
parent 9a04ebae
......@@ -67,6 +67,10 @@ class SpatialVector
public:
//- Component labeling enumeration
enum components { WX, WY, WZ, LX, LY, LZ };
// Constructors
//- Construct null
......@@ -81,19 +85,19 @@ public:
//- Construct from the angular and linear vector components
inline SpatialVector
(
const Vector<Cmpt>& angular,
const Vector<Cmpt>& linear
const Vector<Cmpt>& w,
const Vector<Cmpt>& l
);
//- Construct given 6 components
inline SpatialVector
(
const Cmpt& v0,
const Cmpt& v1,
const Cmpt& v2,
const Cmpt& v3,
const Cmpt& v4,
const Cmpt& v5
const Cmpt& wx,
const Cmpt& wy,
const Cmpt& wz,
const Cmpt& lx,
const Cmpt& ly,
const Cmpt& lz
);
//- Construct from Istream
......@@ -102,11 +106,32 @@ public:
// Member Functions
//- Return the angular part of the spatial vector as a vector
inline Vector<Cmpt> angular() const;
// Component access
inline const Cmpt& wx() const;
inline const Cmpt& wy() const;
inline const Cmpt& wz() const;
inline const Cmpt& lx() const;
inline const Cmpt& ly() const;
inline const Cmpt& lz() const;
inline Cmpt& wx();
inline Cmpt& wy();
inline Cmpt& wz();
inline Cmpt& lx();
inline Cmpt& ly();
inline Cmpt& lz();
// Sub-vector access.
//- Return the angular part of the spatial vector as a vector
inline Vector<Cmpt> w() const;
//- Return the linear part of the spatial vector as a vector
inline Vector<Cmpt> linear() const;
//- Return the linear part of the spatial vector as a vector
inline Vector<Cmpt> l() const;
// Member Operators
......
......@@ -50,16 +50,16 @@ inline Foam::SpatialVector<Cmpt>::SpatialVector
template<class Cmpt>
inline Foam::SpatialVector<Cmpt>::SpatialVector
(
const Vector<Cmpt>& angular,
const Vector<Cmpt>& linear
const Vector<Cmpt>& w,
const Vector<Cmpt>& l
)
{
this->v_[0] = angular.x();
this->v_[1] = angular.y();
this->v_[2] = angular.z();
this->v_[3] = linear.x();
this->v_[4] = linear.y();
this->v_[5] = linear.z();
this->v_[0] = w.x();
this->v_[1] = w.y();
this->v_[2] = w.z();
this->v_[3] = l.x();
this->v_[4] = l.y();
this->v_[5] = l.z();
}
......@@ -93,13 +93,97 @@ inline Foam::SpatialVector<Cmpt>::SpatialVector(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::angular() const
inline const Cmpt& Foam::SpatialVector<Cmpt>::wx() const
{
return this->v_[WX];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::wy() const
{
return this->v_[WY];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::wz() const
{
return this->v_[WZ];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::lx() const
{
return this->v_[LX];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::ly() const
{
return this->v_[LY];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::lz() const
{
return this->v_[LZ];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::wx()
{
return this->v_[WX];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::wy()
{
return this->v_[WY];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::wz()
{
return this->v_[WZ];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::lx()
{
return this->v_[LX];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::ly()
{
return this->v_[LY];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::lz()
{
return this->v_[LZ];
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::w() const
{
return Vector<Cmpt>(this->v_[0], this->v_[1], this->v_[2]);
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::linear() const
inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::l() const
{
return Vector<Cmpt>(this->v_[3], this->v_[4], this->v_[5]);
}
......
......@@ -36,7 +36,7 @@ const char* const Foam::spatialVector::vsType::typeName = "spatialVector";
template<>
const char* const Foam::spatialVector::vsType::componentNames[] =
{
"x", "y", "z"
"wx", "wy", "wz", "lx", "ly", "lz"
};
template<>
......
......@@ -148,8 +148,8 @@ inline Foam::spatialVector Foam::spatialTransform::operator&
{
return spatialVector
(
E_ & v.angular(),
E_ & (v.linear() - (r_ ^ v.angular()))
E_ & v.w(),
E_ & (v.l() - (r_ ^ v.w()))
);
}
......@@ -169,11 +169,11 @@ inline Foam::spatialVector Foam::spatialTransform::transpose::operator&
const spatialVector& f
) const
{
vector ETfl(X_.E().T() & f.linear());
vector ETfl(X_.E().T() & f.l());
return spatialVector
(
(X_.E().T() & f.angular()) + (X_.r() ^ ETfl),
(X_.E().T() & f.w()) + (X_.r() ^ ETfl),
ETfl
);
}
......@@ -196,8 +196,8 @@ inline Foam::spatialVector Foam::spatialTransform::dual::operator&
{
return spatialVector
(
X_.E() & (f.angular() - (X_.r() ^ f.linear())),
X_.E() & f.linear()
X_.E() & (f.w() - (X_.r() ^ f.l())),
X_.E() & f.l()
);
}
......
Markdown is supported
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