mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
SpatialVector: Added cross-product and dual cross-product operators
SpatialTensor: Added SpatialVector cross-product and dual cross-product -> SpatialTensor operators
This commit is contained in:
@ -23,6 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Identity.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
@ -131,7 +133,7 @@ inline Foam::SpatialTensor<Cmpt>::SpatialTensor(Istream& is)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline void Foam::SpatialTensor<Cmpt>::operator=(const Foam::zero z)
|
||||
@ -140,4 +142,55 @@ inline void Foam::SpatialTensor<Cmpt>::operator=(const Foam::zero z)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the cross-product tensor
|
||||
template<class Cmpt>
|
||||
inline Foam::SpatialTensor<Cmpt> operator^
|
||||
(
|
||||
const SpatialVector<Cmpt>& v,
|
||||
const Identity<Cmpt>&
|
||||
)
|
||||
{
|
||||
return SpatialTensor<Cmpt>
|
||||
(
|
||||
0, -v.wz(), v.wy(), 0, 0, 0,
|
||||
v.wz(), 0, -v.wx(), 0, 0, 0,
|
||||
-v.wy(), v.wx(), 0, 0, 0, 0,
|
||||
0, -v.lz(), v.ly(), 0, -v.wz(), v.wy(),
|
||||
v.lz(), 0, -v.lx(), v.wz(), 0, -v.wx(),
|
||||
-v.ly(), v.lx(), 0, -v.wy(), v.wx(), 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the dual cross-product tensor
|
||||
template<class Cmpt>
|
||||
inline Foam::SpatialTensor<Cmpt> operator^
|
||||
(
|
||||
const SpatialVector<Cmpt>& f,
|
||||
const typename Identity<Cmpt>::dual&
|
||||
)
|
||||
{
|
||||
return SpatialTensor<Cmpt>
|
||||
(
|
||||
0, -f.wz(), f.wy(), 0, -f.lz(), f.ly(),
|
||||
f.wz(), 0, -f.wx(), f.lz(), 0, -f.lx(),
|
||||
-f.wy(), f.wx(), 0, -f.ly(), f.lx(), 0,
|
||||
0, 0, 0, 0, -f.wz(), f.wy(),
|
||||
0, 0, 0, f.wz(), 0, -f.wx(),
|
||||
0, 0, 0, -f.wy(), f.wx(), 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -71,6 +71,21 @@ public:
|
||||
enum components { WX, WY, WZ, LX, LY, LZ };
|
||||
|
||||
|
||||
//- Class to represent the dual spatial vector
|
||||
class dual
|
||||
{
|
||||
const SpatialVector& v_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct the dual of the given SpatialVector
|
||||
inline dual(const SpatialVector& v);
|
||||
|
||||
//- Return the parent SpatialVector
|
||||
inline const SpatialVector& v() const;
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -137,6 +152,9 @@ public:
|
||||
// Member Operators
|
||||
|
||||
inline void operator=(const Foam::zero);
|
||||
|
||||
//- Return the dual spatial vector
|
||||
inline dual operator*() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -90,6 +90,13 @@ inline Foam::SpatialVector<Cmpt>::SpatialVector(Istream& is)
|
||||
{}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::SpatialVector<Cmpt>::dual::dual(const SpatialVector& v)
|
||||
:
|
||||
v_(v)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
@ -189,6 +196,13 @@ inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::l() const
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
const Foam::SpatialVector<Cmpt>& Foam::SpatialVector<Cmpt>::dual::v() const
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
@ -198,4 +212,65 @@ inline void Foam::SpatialVector<Cmpt>::operator=(const Foam::zero z)
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline typename Foam::SpatialVector<Cmpt>::dual
|
||||
Foam::SpatialVector<Cmpt>::operator*() const
|
||||
{
|
||||
return dual(*this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the cross-product between two spatial vectors
|
||||
template<class Cmpt>
|
||||
inline SpatialVector<Cmpt> operator^
|
||||
(
|
||||
const SpatialVector<Cmpt>& u,
|
||||
const SpatialVector<Cmpt>& v
|
||||
)
|
||||
{
|
||||
return SpatialVector<Cmpt>
|
||||
(
|
||||
-u.wz()*v.wy() + u.wy()*v.wz(),
|
||||
u.wz()*v.wx() - u.wx()*v.wz(),
|
||||
-u.wy()*v.wx() + u.wx()*v.wy(),
|
||||
-u.lz()*v.wy() + u.ly()*v.wz() - u.wz()*v.ly() + u.wy()*v.lz(),
|
||||
u.lz()*v.wx() - u.lx()*v.wz() + u.wz()*v.lx() - u.wx()*v.lz(),
|
||||
-u.ly()*v.wx() + u.lx()*v.wy() - u.wy()*v.lx() + u.wx()*v.ly()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the dual cross-product between two spatial vectors
|
||||
template<class Cmpt>
|
||||
inline SpatialVector<Cmpt> operator^
|
||||
(
|
||||
const SpatialVector<Cmpt>& v,
|
||||
const typename SpatialVector<Cmpt>::dual& df
|
||||
)
|
||||
{
|
||||
const SpatialVector<Cmpt>& f = df.v();
|
||||
|
||||
return SpatialVector<Cmpt>
|
||||
(
|
||||
-v.wz()*f.wy() + v.wy()*f.wz() - v.lz()*f.ly() + v.ly()*f.lz(),
|
||||
v.wz()*f.wx() - v.wx()*f.wz() + v.lz()*f.lx() - v.lx()*f.lz(),
|
||||
-v.wy()*f.wx() + v.wx()*f.wy() - v.ly()*f.lx() + v.lx()*f.ly(),
|
||||
-v.wz()*f.ly() + v.wy()*f.lz(),
|
||||
v.wz()*f.lx() - v.wx()*f.lz(),
|
||||
-v.wy()*f.lx() + v.wx()*f.ly()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user