30 #ifndef _GranOO_Geom_Tensor_hpp_
31 #define _GranOO_Geom_Tensor_hpp_
35 #include "GranOO3/3rdParty/Eigen/Dense"
37 #include <boost/archive/text_oarchive.hpp>
38 #include <boost/archive/text_iarchive.hpp>
65 static std::string
class_ID() {
return "Tensor";}
66 static const int N = 9;
75 double,
double,
double,
76 double,
double,
double);
105 const double &
xx()
const;
106 const double &
xy()
const;
107 const double &
xz()
const;
109 const double &
yx()
const;
110 const double &
yy()
const;
111 const double &
yz()
const;
113 const double &
zx()
const;
114 const double &
zy()
const;
115 const double &
zz()
const;
140 template <
typename Axis>
double&
val();
141 template <
typename Axis>
const double&
val()
const;
143 const double &
operator() (
unsigned int i,
unsigned int j)
const;
152 template<
class Archive>
159 #ifndef DOXYGEN_SHOULD_SKIP_THIS
161 template<
class Archive>
163 ar &
xx(); ar &
yx(); ar &
zx();
164 ar &
xy(); ar &
yy(); ar &
zy();
165 ar &
xz(); ar &
yz(); ar &
zz();
175 double YX,
double YY,
double YZ,
176 double ZX,
double ZY,
double ZZ)
178 xx() = XX;
xy() = XY;
xz() = XZ;
179 yx() = YX;
yy() = YY;
yz() = YZ;
180 zx() = ZX;
zy() = ZY;
zz() = ZZ;
190 operator/(
const Tensor &m,
const double &d) {
191 return Tensor(m.xx()/d, m.xy()/d, m.xz()/d,
192 m.yx()/d, m.yy()/d, m.yz()/d,
193 m.zx()/d, m.zy()/d, m.zz()/d);
236 return (
xy() == 0. &&
xz() == 0. &&
xz() == 0. &&
237 yy() == 0. &&
yz() == 0. &&
yz() == 0. &&
238 zy() == 0. &&
zz() == 0. &&
zz() == 0);
339 template<>
inline double& Tensor::val<XX>() {
343 template<>
inline double& Tensor::val<XY>() {
347 template<>
inline double& Tensor::val<XZ>() {
351 template<>
inline double& Tensor::val<YX>() {
355 template<>
inline double& Tensor::val<YY>() {
359 template<>
inline double& Tensor::val<YZ>() {
363 template<>
inline double& Tensor::val<ZX>() {
367 template<>
inline double& Tensor::val<ZY>() {
371 template<>
inline double& Tensor::val<ZZ>() {
375 template<>
inline const double& Tensor::val<XX>()
const {
379 template<>
inline const double& Tensor::val<XY>()
const {
383 template<>
inline const double& Tensor::val<XZ>()
const {
387 template<>
inline const double& Tensor::val<YX>()
const {
391 template<>
inline const double& Tensor::val<YY>()
const {
395 template<>
inline const double& Tensor::val<YZ>()
const {
399 template<>
inline const double& Tensor::val<ZX>()
const {
403 template<>
inline const double& Tensor::val<ZY>()
const {
407 template<>
inline const double& Tensor::val<ZZ>()
const {
498 return xx() +
yy() +
zz();
507 operator<< (std::ostream& o,
const Tensor& M) {
508 return o << M.xx() <<
'\t' << M.xy() <<
'\t' << M.xz() <<
'\n'
509 << M.yx() <<
'\t' << M.yy() <<
'\t' << M.yz() <<
'\n'
510 << M.zx() <<
'\t' << M.zy() <<
'\t' << M.zz() <<
'\n';
514 operator*(
const Tensor &m,
const Vector &v) {
515 return Vector(m.xx()*v.x() + m.xy()*v.y() + m.xz()*v.z(),
516 m.yx()*v.x() + m.yy()*v.y() + m.yz()*v.z(),
517 m.zx()*v.x() + m.zy()*v.y() + m.zz()*v.z());
522 operator*(
const double &d,
const Tensor &m) {
523 return Tensor(m.xx()*d, m.xy()*d, m.xz()*d,
524 m.yx()*d, m.yy()*d, m.yz()*d,
525 m.zx()*d, m.zy()*d, m.zz()*d);
529 operator*(
const Tensor &m,
const double &d) {
534 operator* (
const Tensor &m1,
const Tensor &m2) {
535 return Tensor(m1.xx()*m2.xx() + m1.xy()*m2.yx() + m1.xz()*m2.zx(),
536 m1.xx()*m2.xy() + m1.xy()*m2.yy() + m1.xz()*m2.zy(),
537 m1.xx()*m2.xz() + m1.xy()*m2.yz() + m1.xz()*m2.zz(),
539 m1.yx()*m2.xx() + m1.yy()*m2.yx() + m1.yz()*m2.zx(),
540 m1.yx()*m2.xy() + m1.yy()*m2.yy() + m1.yz()*m2.zy(),
541 m1.yx()*m2.xz() + m1.yy()*m2.yz() + m1.yz()*m2.zz(),
543 m1.zx()*m2.xx() + m1.zy()*m2.yx() + m1.zz()*m2.zx(),
544 m1.zx()*m2.xy() + m1.zy()*m2.yy() + m1.zz()*m2.zy(),
545 m1.zx()*m2.xz() + m1.zy()*m2.yz() + m1.zz()*m2.zz());
549 operator+ (
const Tensor &m1,
const Tensor &m2) {
550 return Tensor(m1.xx()+m2.xx(), m1.xy()+m2.xy(), m1.xz()+m2.xz(),
551 m1.yx()+m2.yx(), m1.yy()+m2.yy(), m1.yz()+m2.yz(),
552 m1.zx()+m2.zx(), m1.zy()+m2.zy(), m1.zz()+m2.zz());
556 operator- (
const Tensor &m1,
const Tensor &m2) {
557 return Tensor(m1.xx()-m2.xx(), m1.xy()-m2.xy(), m1.xz()-m2.xz(),
558 m1.yx()-m2.yx(), m1.yy()-m2.yy(), m1.yz()-m2.yz(),
559 m1.zx()-m2.zx(), m1.zy()-m2.zy(), m1.zz()-m2.zz());
563 operator== (
const Tensor &m1,
const Tensor &m2) {
564 Tensor
t(m1.xx()-m2.xx(), m1.xy()-m2.xy(), m1.xz()-m2.xz(),
565 m1.yx()-m2.yx(), m1.yy()-m2.yy(), m1.yz()-m2.yz(),
566 m1.zx()-m2.zx(), m1.zy()-m2.zy(), m1.zz()-m2.zz());
#define SafeModeAssert(condition, message)
Definition: Macro.hpp:47
Definition: Quaternion.hpp:54
Definition: Tensor.hpp:62
static const int N
Definition: Tensor.hpp:66
void set_xz(const double &)
const double & zz() const
const double & operator()(unsigned int i, unsigned int j) const
void operator+=(const Tensor &m)
const double & yz() const
Tensor & operator=(const Tensor &m)
void set_xy(const double &)
void set_xx(const double &)
void serialize(Archive &ar, const unsigned int)
const double & zy() const
const double & xy() const
const double & zx() const
Eigen::Matrix< double, 3, 3 > coord
Definition: Tensor.hpp:156
static std::string class_ID()
Definition: Tensor.hpp:65
const double & yx() const
void set_yy(const double &)
const double & xz() const
const double & val() const
void operator/=(double d)
void set_yz(const double &)
void set_zy(const double &)
friend class boost::serialization::access
Definition: Tensor.hpp:151
double determinant() const
void eigen_value(Vector &v, Quaternion &q) const
Definition: Tensor.cpp:57
void set_zz(const double &)
Tensor(double, double, double, double, double, double, double, double, double)
void set_zx(const double &)
void set_yx(const double &)
const double & xx() const
const double & yy() const
Definition: Vector.hpp:75
SymTensor operator+(const SymTensor &m1, const SymTensor &m2)
SymTensor operator-(const SymTensor &m1, const SymTensor &m2)
std::ostream & operator<<(std::ostream &, const EulerAngle &)
SymTensor operator/(const SymTensor &m, const double &d)
Vector operator*(const SymTensor &m, const Vector &v)
bool operator==(const EulerAngle &, const EulerAngle &)
Definition: Common.hpp:198
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t t(t+t)") define_sfop3(16