11 #ifndef _REALTENSOR_H_ 12 #define _REALTENSOR_H_ 20 #include "NamespaceHeader.H" 38 #elif CH_SPACEDIM == 2 42 m_T[0] = a_t11;
m_T[1] = a_t12;
43 m_T[2] = a_t21;
m_T[3] = a_t22;
45 #elif CH_SPACEDIM == 3 50 m_T[0] = a_t11;
m_T[1] = a_t12;
m_T[2] = a_t13;
51 m_T[3] = a_t21;
m_T[4] = a_t22;
m_T[5] = a_t23;
52 m_T[6] = a_t31;
m_T[7] = a_t32;
m_T[8] = a_t33;
54 #elif CH_SPACEDIM == 4 60 m_T[ 0] = a_t11;
m_T[ 1] = a_t12;
m_T[ 2] = a_t13;
m_T[ 3] = a_t14;
61 m_T[ 4] = a_t21;
m_T[ 5] = a_t22;
m_T[ 6] = a_t23;
m_T[ 7] = a_t24;
62 m_T[ 8] = a_t31;
m_T[ 9] = a_t32;
m_T[10] = a_t33;
m_T[11] = a_t34;
63 m_T[12] = a_t31;
m_T[13] = a_t32;
m_T[14] = a_t33;
m_T[15] = a_t44;
65 #elif CH_SPACEDIM == 5 72 m_T[ 0] = a_t11;
m_T[ 1] = a_t12;
m_T[ 2] = a_t13;
m_T[ 3] = a_t14;
m_T[ 4] = a_t15;
73 m_T[ 5] = a_t21;
m_T[ 6] = a_t22;
m_T[ 7] = a_t23;
m_T[ 8] = a_t24;
m_T[ 9] = a_t25;
74 m_T[10] = a_t31;
m_T[11] = a_t32;
m_T[12] = a_t33;
m_T[13] = a_t34;
m_T[14] = a_t35;
75 m_T[15] = a_t41;
m_T[16] = a_t42;
m_T[17] = a_t43;
m_T[18] = a_t44;
m_T[19] = a_t45;
76 m_T[20] = a_t51;
m_T[21] = a_t52;
m_T[22] = a_t53;
m_T[23] = a_t54;
m_T[24] = a_t55;
78 #elif CH_SPACEDIM == 6 86 m_T[ 0] = a_t11;
m_T[ 1] = a_t12;
m_T[ 2] = a_t13;
m_T[ 3] = a_t14;
m_T[ 4] = a_t15;
m_T[ 5] = a_t16;
87 m_T[ 6] = a_t21;
m_T[ 7] = a_t22;
m_T[ 8] = a_t23;
m_T[ 9] = a_t24;
m_T[10] = a_t25;
m_T[11] = a_t26;
88 m_T[12] = a_t31;
m_T[13] = a_t32;
m_T[14] = a_t33;
m_T[15] = a_t34;
m_T[16] = a_t35;
m_T[17] = a_t36;
89 m_T[18] = a_t41;
m_T[19] = a_t42;
m_T[20] = a_t43;
m_T[21] = a_t44;
m_T[22] = a_t45;
m_T[23] = a_t46;
90 m_T[24] = a_t51;
m_T[25] = a_t52;
m_T[26] = a_t53;
m_T[27] = a_t54;
m_T[28] = a_t55;
m_T[29] = a_t56;
91 m_T[30] = a_t61;
m_T[31] = a_t62;
m_T[32] = a_t63;
m_T[33] = a_t64;
m_T[34] = a_t65;
m_T[35] = a_t66;
94 #error "RealTensor is only implemented for SpaceDim <= 6." 143 std::swap(t(0, 1), t(1, 0));
146 std::swap(t(0, 2), t(2, 0));
147 std::swap(t(1, 2), t(2, 1));
150 std::swap(t(0, 3), t(3, 0));
151 std::swap(t(1, 3), t(3, 1));
152 std::swap(t(2, 3), t(3, 2));
155 std::swap(t(0, 4), t(4, 0));
156 std::swap(t(1, 4), t(4, 1));
157 std::swap(t(2, 4), t(4, 2));
158 std::swap(t(3, 4), t(4, 3));
161 std::swap(t(0, 5), t(5, 0));
162 std::swap(t(1, 5), t(5, 1));
163 std::swap(t(2, 5), t(5, 2));
164 std::swap(t(3, 5), t(5, 3));
165 std::swap(t(4, 5), t(5, 4));
174 const int& a_size)
const 184 int subSize = a_size - 1;
185 Real* subTensor =
new Real[subSize*subSize];
190 for (
int col1 = 0; col1 < a_size; col1++)
193 for (
int row2 = 0; row2 < a_size; row2++)
198 for (
int col2 = 0; col2 < a_size; col2++)
202 subTensor[subSize*subRow + subCol] = a_tensor[a_size*row2 + col2];
212 retval += sign * a_tensor[a_size*row1 + col1] *
recurDet(subTensor,subSize);
226 #include "NamespaceFooter.H" Definition: RealTensor.H:24
#define CH_SPACEDIM
Definition: SPACE.H:52
RealTensor()
Definition: RealTensor.H:28
Real recurDet(const Real *a_tensor, const int &a_size) const
Definition: RealTensor.H:173
const int SpaceDim
Definition: SPACE.H:39
Real det() const
Computes the determinant of this tensor using cofactors.
Definition: RealTensor.H:131
int sign(const Side::LoHiSide &a_side)
double Real
Definition: REAL.H:33
RealTensor transpose() const
Computes the transpose of this tensor.
Definition: RealTensor.H:139
Real operator()(int a_i, int a_j) const
Returns the (i,j) component of this tensor.
Definition: RealTensor.H:120
~RealTensor()
Destructor.
Definition: RealTensor.H:104
RealTensor & operator=(const RealTensor &a_rhs)
Assignment operator.
Definition: RealTensor.H:109
RealTensor(const RealTensor &a_rhs)
Definition: RealTensor.H:98
Real & operator()(int a_i, int a_j)
Definition: RealTensor.H:125
Real m_T[CH_SPACEDIM *CH_SPACEDIM]
Definition: RealTensor.H:223