/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template inline Foam::MatrixSpace::MatrixSpace() {} template inline Foam::MatrixSpace::MatrixSpace ( const Foam::zero ) : MatrixSpace::vsType(Zero) {} template template inline Foam::MatrixSpace::MatrixSpace ( const VectorSpace& vs ) : MatrixSpace::vsType(vs) {} template template < template class Block2, Foam::direction BRowStart, Foam::direction BColStart > inline Foam::MatrixSpace::MatrixSpace ( const Block2& block ) { for (direction i=0; i inline Foam::MatrixSpace::MatrixSpace(Istream& is) : MatrixSpace::vsType(is) {} template template inline Foam::MatrixSpace:: ConstBlock:: ConstBlock(const msType& matrix) : matrix_(matrix) { static_assert ( msType::mRows >= BRowStart + mRows, "Rows in block > rows in matrix" ); static_assert ( msType::nCols >= BColStart + nCols, "Columns in block > columns in matrix" ); } template template inline Foam::MatrixSpace:: Block:: Block(msType& matrix) : matrix_(matrix) { static_assert ( msType::mRows >= BRowStart + mRows, "Rows in block > rows in matrix" ); static_assert ( msType::nCols >= BColStart + nCols, "Columns in block > columns in matrix" ); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template template inline const Cmpt& Foam::MatrixSpace::elmt() const { static_assert(Row < Mrows && Col < Ncols, "Address outside matrix"); return this->v_[Row*Ncols + Col]; } template template inline Cmpt& Foam::MatrixSpace::elmt() { static_assert(Row < Mrows && Col < Ncols, "Address outside matrix"); return this->v_[Row*Ncols + Col]; } template inline const Cmpt& Foam::MatrixSpace::xx() const { return elmt<0, 0>(); } template inline Cmpt& Foam::MatrixSpace::xx() { return elmt<0, 0>(); } template inline const Cmpt& Foam::MatrixSpace::xy() const { return elmt<0,1>(); } template inline Cmpt& Foam::MatrixSpace::xy() { return elmt<0,1>(); } template inline const Cmpt& Foam::MatrixSpace::xz() const { return elmt<0,2>(); } template inline Cmpt& Foam::MatrixSpace::xz() { return elmt<0,2>(); } template inline const Cmpt& Foam::MatrixSpace::yx() const { return elmt<1,0>(); } template inline Cmpt& Foam::MatrixSpace::yx() { return elmt<1,0>(); } template inline const Cmpt& Foam::MatrixSpace::yy() const { return elmt<1,1>(); } template inline Cmpt& Foam::MatrixSpace::yy() { return elmt<1,1>(); } template inline const Cmpt& Foam::MatrixSpace::yz() const { return elmt<1,2>(); } template inline Cmpt& Foam::MatrixSpace::yz() { return elmt<1,2>(); } template inline const Cmpt& Foam::MatrixSpace::zx() const { return elmt<2,0>(); } template inline Cmpt& Foam::MatrixSpace::zx() { return elmt<2,0>(); } template inline const Cmpt& Foam::MatrixSpace::zy() const { return elmt<2,1>(); } template inline Cmpt& Foam::MatrixSpace::zy() { return elmt<2,1>(); } template inline const Cmpt& Foam::MatrixSpace::zz() const { return elmt<2,2>(); } template inline Cmpt& Foam::MatrixSpace::zz() { return elmt<2,2>(); } template inline Foam::MatrixSpace Foam::MatrixSpace::identityMap() { static_assert(Mrows == Ncols, "Matrix is not square"); msType result(Zero); for (direction i=0; i inline typename Foam::typeOfTranspose::type Foam::MatrixSpace::T() const { typename typeOfTranspose::type result; for (direction i=0; i template < class SubTensor, Foam::direction BRowStart, Foam::direction BColStart > inline typename Foam::MatrixSpace::template ConstBlock Foam::MatrixSpace::block() const { return *this; } template template < class SubTensor, Foam::direction BRowStart, Foam::direction BColStart > inline typename Foam::MatrixSpace::template Block Foam::MatrixSpace::block() { return *this; } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template inline const Cmpt& Foam::MatrixSpace::operator() ( const direction& i, const direction& j ) const { #ifdef FULLDEBUG if (i > Mrows-1 || j > Ncols-1) { FatalErrorInFunction << "indices out of range" << abort(FatalError); } #endif return this->v_[i*Ncols + j]; } template inline Cmpt& Foam::MatrixSpace::operator() ( const direction& i, const direction& j ) { #ifdef FULLDEBUG if (i > Mrows-1 || j > Ncols-1) { FatalErrorInFunction << "indices out of range" << abort(FatalError); } #endif return this->v_[i*Ncols + j]; } template template inline SubTensor Foam::MatrixSpace:: ConstBlock:: operator()() const { return *this; } template template inline const Cmpt& Foam::MatrixSpace:: ConstBlock:: operator()(const direction i, const direction j) const { return matrix_(BRowStart + i, BColStart + j); } template template inline SubTensor Foam::MatrixSpace:: Block:: operator()() const { SubTensor st; for (direction i=0; i template inline const Cmpt& Foam::MatrixSpace:: Block:: operator()(const direction i, const direction j) const { return matrix_(BRowStart + i, BColStart + j); } template template inline Cmpt& Foam::MatrixSpace:: Block:: operator()(const direction i, const direction j) { return matrix_(BRowStart + i, BColStart + j); } template inline void Foam::MatrixSpace::operator= ( const Foam::zero ) { MatrixSpace::vsType::operator=(Zero); } template template inline void Foam::MatrixSpace::operator&= ( const MatrixSpace& matrix ) { *this = *this & matrix; } template template < template class Block2, Foam::direction BRowStart, Foam::direction BColStart > inline void Foam::MatrixSpace::operator= ( const Block2& block ) { for (direction i = 0; i < Mrows; ++i) { for (direction j = 0; j < Ncols; ++j) { operator()(i, j) = block(i, j); } } } template template template inline void Foam::MatrixSpace:: Block:: operator= ( const MatrixSpace& matrix ) { for (direction i=0; i template template inline void Foam::MatrixSpace:: Block:: operator= ( const VectorSpace& v ) { static_assert(nCols == 1, "Matrix must have a single column"); for (direction i=0; i inline typename typeOfTranspose::type T ( const MatrixSpace& matrix ) { return matrix.T(); } template inline typename typeOfTranspose::type T ( const VectorSpace& v ) { typename typeOfTranspose::type result; for (direction i=0; i inline typename typeOfInnerProduct::type operator& ( const MatrixSpace& matrix1, const MatrixSpace& matrix2 ) { static_assert ( Ncols1 == Mrows2, "Number of columns in matrix 1 != number of rows in matrix 2" ); typename typeOfInnerProduct::type result(Zero); for (direction i=0; i inline typename typeOfInnerProduct::type operator& ( const MatrixSpace& matrix, const VectorSpace& v ) { typename typeOfInnerProduct::type result(Zero); for (direction i=0; i inline typename typeOfOuterProduct::type operator* ( const VectorSpace& v1, const VectorSpace& v2 ) { typename typeOfOuterProduct::type result; for (direction i=0; i