diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C index 589cbb781b5a3702ea625dcf9df59988c5fcee26..fa4bb144bb2c458cb3d0ef2e5cc31d9feb12e8c4 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.C +++ b/src/OpenFOAM/matrices/Matrix/Matrix.C @@ -33,21 +33,20 @@ License template<class Form, class Type> template<class ListType> -Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiplyImpl +Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::AmulImpl ( - const ListType& colVec + const ListType& x ) const { const Matrix<Form, Type>& mat = *this; #ifdef FULLDEBUG - if (mat.n() != colVec.size()) + if (mat.n() != x.size()) { FatalErrorInFunction << "Attempt to multiply incompatible Matrix and Vector:" << nl << "Matrix : (" << mat.m() << ", " << mat.n() << ')' << nl - << "Vector : " << colVec.size() << " rows" << nl - << "The number of Matrix columns must equal the Vector size" << nl + << "Matrix columns != Vector size (" << x.size() << ')' << nl << abort(FatalError); } #endif @@ -59,7 +58,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiplyImpl { for (label j = 0; j < mat.n(); ++j) { - result[i] += mat(i, j)*colVec[j]; + result[i] += mat(i, j)*x[j]; } } @@ -69,21 +68,20 @@ Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiplyImpl template<class Form, class Type> template<class ListType> -Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiplyImpl +Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::TmulImpl ( - const ListType& rowVec + const ListType& x ) const { const Matrix<Form, Type>& mat = *this; #ifdef FULLDEBUG - if (rowVec.size() != mat.m()) + if (mat.m() != x.size()) { FatalErrorInFunction << "Attempt to multiply incompatible Matrix and Vector:" << nl << "Matrix : (" << mat.m() << ", " << mat.n() << ')' << nl - << "Vector : " << rowVec.size() << " columns" << nl - << "The number of Matrix rows must equal the Vector size" << nl + << "Matrix rows != Vector size (" << x.size() << ')' << nl << abort(FatalError); } #endif @@ -93,7 +91,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiplyImpl for (label i = 0; i < mat.m(); ++i) { - const Type& val = rowVec[i]; + const Type& val = x[i]; for (label j = 0; j < mat.n(); ++j) { result[j] += val*mat(i, j); diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H index 219630cd29d5285206ec438ffa376c049a070901..07dcdeca022bb8ef290d2eefcee430d453c4e14a 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.H +++ b/src/OpenFOAM/matrices/Matrix/Matrix.H @@ -85,13 +85,13 @@ class Matrix //- Allocate storage for the contents inline void doAlloc(); - //- Multiply matrix with a column vector on the right (A * x) + //- Multiply matrix with vector (A * x) template<class ListType> - tmp<Field<Type>> rightMultiplyImpl(const ListType& colVec) const; + tmp<Field<Type>> AmulImpl(const ListType& x) const; - //- Multiply matrix with a row vector on the left (x * A) + //- Multiply matrix transpose with vector (AT * x, or x * A) template<class ListType> - tmp<Field<Type>> leftMultiplyImpl(const ListType& rowVec) const; + tmp<Field<Type>> TmulImpl(const ListType& x) const; public: @@ -310,30 +310,27 @@ public: //- Return the transpose of the matrix Form T() const; - //- Multiply matrix with a column vector on the right (A * x) - inline tmp<Field<Type>> rightMultiply + //- Multiply matrix with vector (A * x) + inline tmp<Field<Type>> Amul ( - const UList<Type>& colVec + const UList<Type>& x ) const; - //- Multiply matrix with a column vector on the right (A * x) + //- Multiply matrix with vector (A * x) template<class Addr> - inline tmp<Field<Type>> rightMultiply + inline tmp<Field<Type>> Amul ( - const IndirectListBase<Type, Addr>& colVec + const IndirectListBase<Type, Addr>& x ) const; - //- Multiply matrix with a row vector on the left (x * A) - inline tmp<Field<Type>> leftMultiply - ( - const UList<Type>& rowVec - ) const; + //- Multiply matrix transpose with vector (AT * x, or x * A) + inline tmp<Field<Type>> Tmul(const UList<Type>& x) const; - //- Multiply matrix with a row vector on the left (x * A) + //- Multiply matrix transpose with vector (AT * x, or x * A) template<class Addr> - inline tmp<Field<Type>> leftMultiply + inline tmp<Field<Type>> Tmul ( - const IndirectListBase<Type, Addr>& rowVec + const IndirectListBase<Type, Addr>& x ) const; diff --git a/src/OpenFOAM/matrices/Matrix/MatrixI.H b/src/OpenFOAM/matrices/Matrix/MatrixI.H index 5c6d8e32221820d3c279747bca4ca7e067d22288..7fa07a383315c157cf0f1836e2f612281d25eeec 100644 --- a/src/OpenFOAM/matrices/Matrix/MatrixI.H +++ b/src/OpenFOAM/matrices/Matrix/MatrixI.H @@ -404,44 +404,44 @@ void Foam::Matrix<Form, Type>::shallowResize(const label m, const label n) template<class Form, class Type> -inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiply +inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Amul ( - const UList<Type>& colVec + const UList<Type>& x ) const { - return this->rightMultiplyImpl(colVec); + return this->AmulImpl(x); } template<class Form, class Type> template<class Addr> -inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiply +inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Amul ( - const IndirectListBase<Type, Addr>& colVec + const IndirectListBase<Type, Addr>& x ) const { - return this->rightMultiplyImpl(colVec); + return this->AmulImpl(x); } template<class Form, class Type> -inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiply +inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Tmul ( - const UList<Type>& rowVec + const UList<Type>& x ) const { - return this->leftMultiplyImpl(rowVec); + return this->TmulImpl(x); } template<class Form, class Type> template<class Addr> -inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiply +inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Tmul ( - const IndirectListBase<Type, Addr>& rowVec + const IndirectListBase<Type, Addr>& x ) const { - return this->leftMultiplyImpl(rowVec); + return this->TmulImpl(x); } @@ -546,7 +546,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator* const UList<Type>& x ) { - mat.rightMultiply(x); + return mat.Amul(x); } @@ -557,7 +557,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator* const IndirectListBase<Type, Addr>& x ) { - mat.rightMultiply(x); + return mat.Amul(x); } @@ -568,7 +568,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator* const Matrix<Form, Type>& mat ) { - mat.leftMultiply(x); + return mat.Tmul(x); } @@ -579,7 +579,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator* const Matrix<Form, Type>& mat ) { - mat.leftMultiply(x); + return mat.Tmul(x); }