diff --git a/src/VectorN/OpenFOAM/primitives/TensorN.H b/src/VectorN/OpenFOAM/primitives/TensorN.H index d9c87422f..7a2e6d423 100644 --- a/src/VectorN/OpenFOAM/primitives/TensorN.H +++ b/src/VectorN/OpenFOAM/primitives/TensorN.H @@ -101,6 +101,13 @@ public: // Member Functions + //- Return direction given (i, j) indices + static inline direction cmpt + ( + const direction i, + const direction j + ); + //- Return (i, j) component inline const Cmpt& operator() ( diff --git a/src/VectorN/OpenFOAM/primitives/TensorNI.H b/src/VectorN/OpenFOAM/primitives/TensorNI.H index a1853f408..b77275a7e 100644 --- a/src/VectorN/OpenFOAM/primitives/TensorNI.H +++ b/src/VectorN/OpenFOAM/primitives/TensorNI.H @@ -217,6 +217,36 @@ inline TensorN transform // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +template +inline direction TensorN::cmpt +( + const direction i, + const direction j +) +{ + if + ( + i > TensorN::rowLength - 1 + || j > TensorN::rowLength - 1 + ) + { + FatalErrorIn + ( + "direction TensorN::cmpt()\n" + "(\n" + " const direction i,\n" + " const direction j\n" + ") const" + ) << "Direction out of range (0 " + << TensorN::rowLength - 1 << ")" + << " and (i j) = (" << i << " " << j << ")" + << abort(FatalError); + } + + return i*TensorN::rowLength + j; +} + + template inline const Cmpt& TensorN::operator() ( @@ -857,7 +887,11 @@ inline TensorN inv(const TensorN& t) { if (iPivot[k] == 0) { - if ((temp = Foam::mag(result[curRowOffset+k])) >= largestCoeff) + if + ( + (temp = Foam::mag(result[curRowOffset+k])) + >= largestCoeff + ) { largestCoeff = temp; iRow = j;