Chi-Tech
chi_mesh_utilities.cc
Go to the documentation of this file.
1#include "chi_mesh.h"
2
3//###################################################################
4/**Tensor product of two vectors.
5 * \f$ \vec{\vec{T}} = \vec{x} \otimes \vec{y} \f$*/
7{
8 TensorRank2Dim3 new_t;
9 for (int i=0; i<3; ++i)
10 for (int j=0; j<3; ++j)
11 new_t[i](j) = this->operator[](i)*that[j];
12
13 return new_t;
14}
15
16//###################################################################
17/**Dot product of vector and a rank-2 tensor.
18 * \f$ \vec{w} = \vec{x} \bullet \vec{\vec{T}} \f$*/
20{
21 chi_mesh::Vector3 new_vec;
22 for (int i=0; i<3; ++i)
23 new_vec(i) = this->Dot(that.t[i]);
24
25 return new_vec;
26}
27
28//###################################################################
29/**Returns a 3D vector multiplied by the given scalar from the left.
30 * \f$ \vec{w} = \alpha \vec{x}\f$*/
31chi_mesh::Vector3 operator*(const double value,const chi_mesh::Vector3& that)
32{
33 chi_mesh::Vector3 newVector;
34 newVector.x = that.x*value;
35 newVector.y = that.y*value;
36 newVector.z = that.z*value;
37
38 return newVector;
39}
40
41//###################################################################
42/**Dot product of rank-2 tensor with a vector.
43 * \f$ \vec{w} = \vec{\vec{T}} \bullet \vec{x} \f$*/
45{
46 chi_mesh::Vector3 newVector;
47 for (int i=0; i<3; ++i)
48 newVector(i) = t[i].Dot(v);
49
50 return newVector;
51}
52
53//###################################################################
54/**Returns the diagonal of a rank-2 dim-3 tensor as a vector3.
55 * \f$ \vec{w} = \text{diag} \vec{\vec{T}} \f$*/
57{
58 chi_mesh::Vector3 newVector;
59 for (int i=0; i<3; ++i)
60 newVector(i) = t[i][i];
61
62 return newVector;
63}
64
65//###################################################################
66/**Rank-2 dim-3 tensor multiplied from the left with a scalar.
67 * \f$ \vec{\vec{W}} = \alpha \vec{\vec{T}} \f$*/
69 operator*(const double value, const chi_mesh::TensorRank2Dim3& that)
70{
71 chi_mesh::TensorRank2Dim3 new_t = that;
72 for (int i=0; i<3; ++i)
73 {
74 for (int j=0; j<3; ++j)
75 new_t[i](j) *= value;
76 }
77
78 return new_t;
79}
chi_mesh::Vector3 operator*(const double value, const chi_mesh::Vector3 &that)
double Dot(const VecDbl &x, const VecDbl &y)
std::vector< chi_mesh::Vector3 > t
Tensor entries.
Vector3 Dot(const chi_mesh::Vector3 &v) const
chi_mesh::Vector3 Diag() const
double x
Element-0.
double operator[](const size_t i) const
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const
chi_mesh::TensorRank2Dim3 OTimes(const Vector3 &that) const
double y
Element-1.
double z
Element-2.