1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include "Tensor3333.h"
using namespace FEM;

Tensor3333::
Tensor3333()
{

}
Tensor3333::
Tensor3333(const Tensor3333& other)
{
	A[0][0] = other.A[0][0],A[0][1] = other.A[0][1],A[0][2] = other.A[0][2];
	A[1][0] = other.A[1][0],A[1][1] = other.A[1][1],A[1][2] = other.A[1][2];
	A[2][0] = other.A[2][0],A[2][1] = other.A[2][1],A[2][2] = other.A[2][2];
}
Tensor3333&
Tensor3333::
operator=(const Tensor3333& other)
{
	A[0][0] = other.A[0][0],A[0][1] = other.A[0][1],A[0][2] = other.A[0][2];
	A[1][0] = other.A[1][0],A[1][1] = other.A[1][1],A[1][2] = other.A[1][2];
	A[2][0] = other.A[2][0],A[2][1] = other.A[2][1],A[2][2] = other.A[2][2];
}
Tensor3333
Tensor3333::
operator+() const
{
	Tensor3333 ret = *this;
	return ret;
}
Tensor3333
Tensor3333::
operator-() const
{
	Tensor3333 ret;
	ret.A[0][0] = -A[0][0],ret.A[0][1] = -A[0][1],ret.A[0][2] = -A[0][2];
	ret.A[1][0] = -A[1][0],ret.A[1][1] = -A[1][1],ret.A[1][2] = -A[1][2];
	ret.A[2][0] = -A[2][0],ret.A[2][1] = -A[2][1],ret.A[2][2] = -A[2][2];
	return ret;
}
Tensor3333
Tensor3333::
operator+(const Tensor3333& B) const
{
	Tensor3333 ret;
	ret.A[0][0] = A[0][0] + B.A[0][0],ret.A[0][1] = A[0][1] + B.A[0][1],ret.A[0][2] = A[0][2] + B.A[0][2];
	ret.A[1][0] = A[1][0] + B.A[1][0],ret.A[1][1] = A[1][1] + B.A[1][1],ret.A[1][2] = A[1][2] + B.A[1][2];
	ret.A[2][0] = A[2][0] + B.A[2][0],ret.A[2][1] = A[2][1] + B.A[2][1],ret.A[2][2] = A[2][2] + B.A[2][2];
	return ret;
}
Tensor3333
Tensor3333::
operator-(const Tensor3333& B) const
{
	Tensor3333 ret;
	ret.A[0][0] = A[0][0] - B.A[0][0],ret.A[0][1] = A[0][1] - B.A[0][1],ret.A[0][2] = A[0][2] - B.A[0][2];
	ret.A[1][0] = A[1][0] - B.A[1][0],ret.A[1][1] = A[1][1] - B.A[1][1],ret.A[1][2] = A[1][2] - B.A[1][2];
	ret.A[2][0] = A[2][0] - B.A[2][0],ret.A[2][1] = A[2][1] - B.A[2][1],ret.A[2][2] = A[2][2] - B.A[2][2];
	return ret;
}
Tensor3333
Tensor3333::
operator*(const Eigen::Matrix3d& m) const
{
	Tensor3333 ret;
	ret.A[0][0] = A[0][0]*m(0,0) + A[0][1]*m(1,0) + A[0][2]*m(2,0);
	ret.A[0][1] = A[0][0]*m(0,1) + A[0][1]*m(1,1) + A[0][2]*m(2,1);
	ret.A[0][2] = A[0][0]*m(0,2) + A[0][1]*m(1,2) + A[0][2]*m(2,2);

	ret.A[1][0] = A[1][0]*m(0,0) + A[1][1]*m(1,0) + A[1][2]*m(2,0);
	ret.A[1][1] = A[1][0]*m(0,1) + A[1][1]*m(1,1) + A[1][2]*m(2,1);
	ret.A[1][2] = A[1][0]*m(0,2) + A[1][1]*m(1,2) + A[1][2]*m(2,2);

	ret.A[2][0] = A[2][0]*m(0,0) + A[2][1]*m(1,0) + A[2][2]*m(2,0);
	ret.A[2][1] = A[2][0]*m(0,1) + A[2][1]*m(1,1) + A[2][2]*m(2,1);
	ret.A[2][2] = A[2][0]*m(0,2) + A[2][1]*m(1,2) + A[2][2]*m(2,2);
	return ret;
}
Tensor3333
Tensor3333::
operator*(double a) const
{
	Tensor3333 ret;

	ret.A[0][0] = a*A[0][0],ret.A[0][1] = a*A[0][1],ret.A[0][2] = a*A[0][2];
	ret.A[1][0] = a*A[1][0],ret.A[1][1] = a*A[1][1],ret.A[1][2] = a*A[1][2];
	ret.A[2][0] = a*A[2][0],ret.A[2][1] = a*A[2][1],ret.A[2][2] = a*A[2][2];

	return ret;
}
Eigen::Matrix3d&
Tensor3333::
operator()(int i, int j)
{
	return A[i][j];
}
void
Tensor3333::
SetIdentity()
{
	A[0][0] = Eigen::Matrix3d::Zero(),A[0][1] = Eigen::Matrix3d::Zero(),A[0][2] = Eigen::Matrix3d::Zero();
	A[1][0] = Eigen::Matrix3d::Zero(),A[1][1] = Eigen::Matrix3d::Zero(),A[1][2] = Eigen::Matrix3d::Zero();
	A[2][0] = Eigen::Matrix3d::Zero(),A[2][1] = Eigen::Matrix3d::Zero(),A[2][2] = Eigen::Matrix3d::Zero();

	A[0][0](0,0) = 1.0,A[0][1](0,1) = 1.0,A[0][2](0,2) = 1.0;
	A[1][0](1,0) = 1.0,A[1][1](1,1) = 1.0,A[1][2](1,2) = 1.0;
	A[2][0](2,0) = 1.0,A[2][1](2,1) = 1.0,A[2][2](2,2) = 1.0;	
}
void
Tensor3333::
SetZero()
{
	A[0][0] = Eigen::Matrix3d::Zero(),A[0][1] = Eigen::Matrix3d::Zero(),A[0][2] = Eigen::Matrix3d::Zero();
	A[1][0] = Eigen::Matrix3d::Zero(),A[1][1] = Eigen::Matrix3d::Zero(),A[1][2] = Eigen::Matrix3d::Zero();
	A[2][0] = Eigen::Matrix3d::Zero(),A[2][1] = Eigen::Matrix3d::Zero(),A[2][2] = Eigen::Matrix3d::Zero();
}
Tensor3333
Tensor3333::
Transpose()
{
	Tensor3333 ret;

	ret.A[0][0] = A[0][0],ret.A[0][1] = A[1][0],ret.A[0][2] = A[2][0];
	ret.A[1][0] = A[0][1],ret.A[1][1] = A[1][1],ret.A[1][2] = A[2][1];
	ret.A[2][0] = A[0][2],ret.A[2][1] = A[1][2],ret.A[2][2] = A[2][2];

	A[0][0] = ret.A[0][0],A[0][1] = ret.A[0][1],A[0][2] = ret.A[0][2];
	A[1][0] = ret.A[1][0],A[1][1] = ret.A[1][1],A[1][2] = ret.A[1][2];
	A[2][0] = ret.A[2][0],A[2][1] = ret.A[2][1],A[2][2] = ret.A[2][2];

	return ret;
}
Tensor3333
FEM::operator*(double a,const Tensor3333& B)
{
	Tensor3333 ret;

	ret.A[0][0] = a*B.A[0][0],ret.A[0][1] = a*B.A[0][1],ret.A[0][2] = a*B.A[0][2];
	ret.A[1][0] = a*B.A[1][0],ret.A[1][1] = a*B.A[1][1],ret.A[1][2] = a*B.A[1][2];
	ret.A[2][0] = a*B.A[2][0],ret.A[2][1] = a*B.A[2][1],ret.A[2][2] = a*B.A[2][2];

	return ret;
}
Tensor3333
FEM::operator*(const Eigen::Matrix3d& m,const Tensor3333& B)
{
	Tensor3333 ret;

	ret.A[0][0] = m(0,0)*B.A[0][0] + m(0,1)*B.A[1][0] + m(0,2)*B.A[2][0];
	ret.A[0][1] = m(0,0)*B.A[0][1] + m(0,1)*B.A[1][1] + m(0,2)*B.A[2][1];
	ret.A[0][2] = m(0,0)*B.A[0][2] + m(0,1)*B.A[1][2] + m(0,2)*B.A[2][2];

	ret.A[1][0] = m(1,0)*B.A[0][0] + m(1,1)*B.A[1][0] + m(1,2)*B.A[2][0];
	ret.A[1][1] = m(1,0)*B.A[0][1] + m(1,1)*B.A[1][1] + m(1,2)*B.A[2][1];
	ret.A[1][2] = m(1,0)*B.A[0][2] + m(1,1)*B.A[1][2] + m(1,2)*B.A[2][2];

	ret.A[2][0] = m(2,0)*B.A[0][0] + m(2,1)*B.A[1][0] + m(2,2)*B.A[2][0];
	ret.A[2][1] = m(2,0)*B.A[0][1] + m(2,1)*B.A[1][1] + m(2,2)*B.A[2][1];
	ret.A[2][2] = m(2,0)*B.A[0][2] + m(2,1)*B.A[1][2] + m(2,2)*B.A[2][2];
	return ret;
}

std::ostream&
FEM::operator<<(std::ostream& os,const Tensor3333& B)
{
	std::cout<<"(0,0)\n"<<B.A[0][0]<<std::endl<<std::endl;
	std::cout<<"(0,1)\n"<<B.A[0][1]<<std::endl<<std::endl;
	std::cout<<"(0,2)\n"<<B.A[0][2]<<std::endl<<std::endl;

	std::cout<<"(1,0)\n"<<B.A[1][0]<<std::endl<<std::endl;
	std::cout<<"(1,1)\n"<<B.A[1][1]<<std::endl<<std::endl;
	std::cout<<"(1,2)\n"<<B.A[1][2]<<std::endl<<std::endl;

	std::cout<<"(2,0)\n"<<B.A[2][0]<<std::endl<<std::endl;
	std::cout<<"(2,1)\n"<<B.A[2][1]<<std::endl<<std::endl;
	std::cout<<"(2,2)\n"<<B.A[2][2]<<std::endl<<std::endl;
	
	return os;
}