diff --git a/applications/test/IjkField/Make/files b/applications/test/IjkField/Make/files index 8e1017d41d8fdb5980bba09153bf42124382a952..d0a905bc00b003aede774a2f310cf7b9024d7829 100644 --- a/applications/test/IjkField/Make/files +++ b/applications/test/IjkField/Make/files @@ -1,3 +1,3 @@ -Test-IjkField.C +Test-IjkField.cxx EXE = $(FOAM_USER_APPBIN)/Test-IjkField diff --git a/applications/test/IjkField/Test-IjkField.C b/applications/test/IjkField/Test-IjkField.cxx similarity index 100% rename from applications/test/IjkField/Test-IjkField.C rename to applications/test/IjkField/Test-IjkField.cxx diff --git a/applications/test/matrices/DiagonalMatrix/Make/files b/applications/test/matrices/DiagonalMatrix/Make/files index 0f5877472a346b75694df94f6ff6b489c99cabdc..e8338d6d5444bce3debb9a643a8e8dfec29af81f 100644 --- a/applications/test/matrices/DiagonalMatrix/Make/files +++ b/applications/test/matrices/DiagonalMatrix/Make/files @@ -1,3 +1,3 @@ -Test-DiagonalMatrix.C +Test-DiagonalMatrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-DiagonalMatrix diff --git a/applications/test/matrices/DiagonalMatrix/Test-DiagonalMatrix.C b/applications/test/matrices/DiagonalMatrix/Test-DiagonalMatrix.cxx similarity index 100% rename from applications/test/matrices/DiagonalMatrix/Test-DiagonalMatrix.C rename to applications/test/matrices/DiagonalMatrix/Test-DiagonalMatrix.cxx diff --git a/applications/test/matrices/EigenMatrix/Make/files b/applications/test/matrices/EigenMatrix/Make/files index 1bd5722a5f46eed41388dc7ddfed37bcc289bc5d..f652095c4f86b73089e7f404269a08033b1643d8 100644 --- a/applications/test/matrices/EigenMatrix/Make/files +++ b/applications/test/matrices/EigenMatrix/Make/files @@ -1,3 +1,3 @@ -Test-EigenMatrix.C +Test-EigenMatrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-EigenMatrix diff --git a/applications/test/matrices/EigenMatrix/Test-EigenMatrix.C b/applications/test/matrices/EigenMatrix/Test-EigenMatrix.cxx similarity index 100% rename from applications/test/matrices/EigenMatrix/Test-EigenMatrix.C rename to applications/test/matrices/EigenMatrix/Test-EigenMatrix.cxx diff --git a/applications/test/matrices/Matrix/Make/files b/applications/test/matrices/Matrix/Make/files index e167e86cdc38ca5c1b88cae9f59ac83fc13c7171..09565ca38a35414374597ffc331938ce87d8d3f1 100644 --- a/applications/test/matrices/Matrix/Make/files +++ b/applications/test/matrices/Matrix/Make/files @@ -1,3 +1,3 @@ -Test-Matrix.C +Test-Matrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-Matrix diff --git a/applications/test/matrices/Matrix/Test-Matrix.C b/applications/test/matrices/Matrix/Test-Matrix.cxx similarity index 100% rename from applications/test/matrices/Matrix/Test-Matrix.C rename to applications/test/matrices/Matrix/Test-Matrix.cxx diff --git a/applications/test/matrices/QRMatrix/Make/files b/applications/test/matrices/QRMatrix/Make/files index 9825bbfcf351043bd03d02a5d50dd924e73a1d41..55c6d30e6873ae9b16df4e9bfb9323d80fd6710b 100644 --- a/applications/test/matrices/QRMatrix/Make/files +++ b/applications/test/matrices/QRMatrix/Make/files @@ -1,3 +1,3 @@ -Test-QRMatrix.C +Test-QRMatrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-QRMatrix diff --git a/applications/test/matrices/QRMatrix/Test-QRMatrix.C b/applications/test/matrices/QRMatrix/Test-QRMatrix.cxx similarity index 100% rename from applications/test/matrices/QRMatrix/Test-QRMatrix.C rename to applications/test/matrices/QRMatrix/Test-QRMatrix.cxx diff --git a/applications/test/matrices/RectangularMatrix/Make/files b/applications/test/matrices/RectangularMatrix/Make/files index 49b520d07986ab159a292f32f6f9455e5e12371e..ad7d686317677fae86c56c7338cf3a3f8ae3253c 100644 --- a/applications/test/matrices/RectangularMatrix/Make/files +++ b/applications/test/matrices/RectangularMatrix/Make/files @@ -1,3 +1,3 @@ -Test-RectangularMatrix.C +Test-RectangularMatrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-RectangularMatrix diff --git a/applications/test/matrices/RectangularMatrix/Test-RectangularMatrix.C b/applications/test/matrices/RectangularMatrix/Test-RectangularMatrix.cxx similarity index 100% rename from applications/test/matrices/RectangularMatrix/Test-RectangularMatrix.C rename to applications/test/matrices/RectangularMatrix/Test-RectangularMatrix.cxx diff --git a/applications/test/matrices/SquareMatrix/Make/files b/applications/test/matrices/SquareMatrix/Make/files index e64b858cd6ba23bcc369939af81137b364927bdf..37b022136fcd0a4c7d766332cc1e48ccfffd399c 100644 --- a/applications/test/matrices/SquareMatrix/Make/files +++ b/applications/test/matrices/SquareMatrix/Make/files @@ -1,3 +1,3 @@ -Test-SquareMatrix.C +Test-SquareMatrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-SquareMatrix diff --git a/applications/test/matrices/SquareMatrix/Test-SquareMatrix.C b/applications/test/matrices/SquareMatrix/Test-SquareMatrix.cxx similarity index 100% rename from applications/test/matrices/SquareMatrix/Test-SquareMatrix.C rename to applications/test/matrices/SquareMatrix/Test-SquareMatrix.cxx diff --git a/applications/test/matrices/SymmetricSquareMatrix/Make/files b/applications/test/matrices/SymmetricSquareMatrix/Make/files index da88933c249e3bfafd2a25c4842babc8f5c5c1f5..d0e7b1173e86f3d12e39fe6d54060a083f75b07c 100644 --- a/applications/test/matrices/SymmetricSquareMatrix/Make/files +++ b/applications/test/matrices/SymmetricSquareMatrix/Make/files @@ -1,3 +1,3 @@ -Test-SymmetricSquareMatrix.C +Test-SymmetricSquareMatrix.cxx EXE = $(FOAM_USER_APPBIN)/Test-SymmetricSquareMatrix diff --git a/applications/test/matrices/SymmetricSquareMatrix/Test-SymmetricSquareMatrix.C b/applications/test/matrices/SymmetricSquareMatrix/Test-SymmetricSquareMatrix.cxx similarity index 100% rename from applications/test/matrices/SymmetricSquareMatrix/Test-SymmetricSquareMatrix.C rename to applications/test/matrices/SymmetricSquareMatrix/Test-SymmetricSquareMatrix.cxx diff --git a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C index 60aee73efc1fd6919f5371299d3cdd65c627e443..d9a888049abc53bb25a0fd77ff9555e4ea79242b 100644 --- a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C +++ b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,7 +38,7 @@ Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label n) template<class Type> -Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label n, const Foam::zero) +Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label n, Foam::zero) : List<Type>(n, Foam::zero{}) {} @@ -55,7 +55,7 @@ template<class Type> template<class Form> Foam::DiagonalMatrix<Type>::DiagonalMatrix(const Matrix<Form, Type>& mat) : - List<Type>(min(mat.m(), mat.n())) + List<Type>(Foam::min(mat.m(), mat.n())) { label i = 0; @@ -86,9 +86,9 @@ void Foam::DiagonalMatrix<Type>::invert() template<class Type> template<class CompOp> -Foam::List<Foam::label> Foam::DiagonalMatrix<Type>::sortPermutation +Foam::labelList Foam::DiagonalMatrix<Type>::sortPermutation ( - CompOp& compare + const CompOp& compare ) const { List<label> p(this->size()); @@ -105,7 +105,7 @@ Foam::List<Foam::label> Foam::DiagonalMatrix<Type>::sortPermutation template<class Type> -void Foam::DiagonalMatrix<Type>::applyPermutation(const List<label>& p) +void Foam::DiagonalMatrix<Type>::applyPermutation(const labelUList& p) { #ifdef FULLDEBUG if (this->size() != p.size()) @@ -153,7 +153,7 @@ DiagonalMatrix<Type> inv(const DiagonalMatrix<Type>& mat) { // Construct with fall-back value conditional calculation // of invert to avoid over-eager compiler optimisation - DiagonalMatrix<Type> Ainv(mat.size(), Zero); + DiagonalMatrix<Type> Ainv(mat.size(), Foam::zero{}); Type* iter = Ainv.begin(); @@ -177,7 +177,7 @@ template<class Type> DiagonalMatrix<Type> applyPermutation ( const DiagonalMatrix<Type>& mat, - const List<label>& p + const labelUList& p ) { #ifdef FULLDEBUG diff --git a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H index ea9adb37a06e72698779f166792aaea6677330f2..60e985a25e1c93a85caaa23d0fd9f60b9059e527 100644 --- a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H +++ b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -82,7 +82,7 @@ public: explicit DiagonalMatrix(const label n); //- Construct from size and initialise all elems to zero - DiagonalMatrix(const label n, const Foam::zero); + DiagonalMatrix(const label n, Foam::zero); //- Construct from size and initialise all elems to value DiagonalMatrix(const label n, const Type& val); @@ -100,11 +100,11 @@ public: //- Return a sort permutation labelList according to //- a given comparison on the diagonal entries template<class CompOp> - List<label> sortPermutation(CompOp& compare) const; + labelList sortPermutation(const CompOp& compare) const; //- Column-reorder this Matrix according to //- a given permutation labelList - void applyPermutation(const List<label>& p); + void applyPermutation(const labelUList& p); }; diff --git a/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.C b/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.C index 30f28d7210676fb07eefaf863fd9171a34e74cd9..21012eb0b74caebbf76dd5656fb67203ab8d3f76 100644 --- a/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.C +++ b/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.C @@ -204,7 +204,7 @@ void Foam::EigenMatrix<cmptType>::symmTridiagonalQL() for (label l = 0; l < n_; l++) { // Find SMALL subdiagonal element - tst1 = max(tst1, mag(EValsRe_[l]) + mag(EValsIm_[l])); + tst1 = Foam::max(tst1, mag(EValsRe_[l]) + mag(EValsIm_[l])); label m = l; // Original while-loop from Java code @@ -462,7 +462,7 @@ void Foam::EigenMatrix<cmptType>::realSchur() EValsIm_[i] = Zero; } - for (label j = max(i - 1, 0); j < nn; ++j) + for (label j = Foam::max(i - 1, 0); j < nn; ++j) { norm += mag(H_[i][j]); } @@ -745,7 +745,7 @@ void Foam::EigenMatrix<cmptType>::realSchur() } // Column modification - for (label i = 0; i <= min(n, k + 3); ++i) + for (label i = 0; i <= Foam::min(n, k + 3); ++i) { p = x*H_[i][k] + y*H_[i][k + 1]; @@ -952,7 +952,7 @@ void Foam::EigenMatrix<cmptType>::realSchur() } // Overflow control - t = max(mag(H_[i][n - 1]), mag(H_[i][n])); + t = Foam::max(mag(H_[i][n - 1]), mag(H_[i][n])); if ((eps*t)*t > 1) { @@ -986,7 +986,7 @@ void Foam::EigenMatrix<cmptType>::realSchur() { z = Zero; - for (label k = low; k <= min(j, high); ++k) + for (label k = low; k <= Foam::min(j, high); ++k) { z = z + EVecs_[i][k]*H_[k][j]; } @@ -999,37 +999,6 @@ void Foam::EigenMatrix<cmptType>::realSchur() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class cmptType> -Foam::EigenMatrix<cmptType>::EigenMatrix(const SquareMatrix<cmptType>& A) -: - n_(A.n()), - EValsRe_(n_, Zero), - EValsIm_(n_, Zero), - EVecs_(n_, Zero), - H_() -{ - if (n_ <= 0) - { - FatalErrorInFunction - << "Input matrix has zero size." - << abort(FatalError); - } - - if (A.symmetric()) - { - EVecs_ = A; - tridiagonaliseSymmMatrix(); - symmTridiagonalQL(); - } - else - { - H_ = A; - Hessenberg(); - realSchur(); - } -} - - template<class cmptType> Foam::EigenMatrix<cmptType>::EigenMatrix ( @@ -1065,6 +1034,13 @@ Foam::EigenMatrix<cmptType>::EigenMatrix } +template<class cmptType> +Foam::EigenMatrix<cmptType>::EigenMatrix(const SquareMatrix<cmptType>& A) +: + EigenMatrix<cmptType>(A, A.symmetric()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class cmptType> diff --git a/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.H b/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.H index e88db3f55b759cdd048a67f6fefefd3397e1ae4b..1eaf79699f664442b07df4c831a42851f63fcfed 100644 --- a/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.H +++ b/src/OpenFOAM/matrices/EigenMatrix/EigenMatrix.H @@ -200,6 +200,12 @@ class EigenMatrix public: + // Typedefs + + //- The value type the Matrix contains + typedef cmptType value_type; + + // Generated Methods //- No default construct diff --git a/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.C b/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.C index 8abbce4eab54c6d9dfbef441c1bc64a49e5c9e70..7d849313db931c4e47dbc99c6a713c0bdf679050 100644 --- a/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.C +++ b/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.C @@ -30,11 +30,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class Type> -Foam::LLTMatrix<Type>::LLTMatrix() -{} - - template<class Type> Foam::LLTMatrix<Type>::LLTMatrix(const SquareMatrix<Type>& mat) { diff --git a/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.H b/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.H index 62749e5f32908b319dbccbe20055c1d12744ba25..92e62c2b19d54063527ceb64857a1f62db65d4ee 100644 --- a/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.H +++ b/src/OpenFOAM/matrices/LLTMatrix/LLTMatrix.H @@ -77,8 +77,8 @@ public: // Constructors - //- Construct null - LLTMatrix(); + //- Default construct + LLTMatrix() = default; //- Construct and perform the decomposition on input square matrix LLTMatrix(const SquareMatrix<Type>& mat); diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C index f98ad1849f819fa21565018012d9acc34f6acbfb..bb1251cf62feadec74ae66583e25f0d38811dab6 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.C +++ b/src/OpenFOAM/matrices/Matrix/Matrix.C @@ -51,7 +51,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::AmulImpl } #endif - auto tresult = tmp<Field<Type>>::New(mat.m(), Zero); + auto tresult = tmp<Field<Type>>::New(mat.m(), Foam::zero{}); auto& result = tresult.ref(); for (label i = 0; i < mat.m(); ++i) @@ -86,7 +86,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::TmulImpl } #endif - auto tresult = tmp<Field<Type>>::New(mat.n(), Zero); + auto tresult = tmp<Field<Type>>::New(mat.n(), Foam::zero{}); auto& result = tresult.ref(); for (label i = 0; i < mat.m(); ++i) @@ -118,7 +118,7 @@ Foam::Matrix<Form, Type>::Matrix(const label m, const label n) template<class Form, class Type> -Foam::Matrix<Form, Type>::Matrix(const label m, const label n, const Foam::zero) +Foam::Matrix<Form, Type>::Matrix(const label m, const label n, Foam::zero) : mRows_(m), nCols_(n), @@ -326,10 +326,10 @@ void Foam::Matrix<Form, Type>::resize(const label m, const label n) return; } - Matrix<Form, Type> newMatrix(m, n, Zero); + Matrix<Form, Type> newMatrix(m, n, Foam::zero{}); - const label mrow = min(m, mRows_); - const label ncol = min(n, nCols_); + const label mrow = Foam::min(m, mRows_); + const label ncol = Foam::min(n, nCols_); for (label i = 0; i < mrow; ++i) { @@ -480,7 +480,7 @@ Foam::scalar Foam::Matrix<Form, Type>::columnNorm const bool noSqrt ) const { - scalar result = Zero; + scalar result(0); for (label i=0; i < mRows_; ++i) { @@ -494,7 +494,7 @@ Foam::scalar Foam::Matrix<Form, Type>::columnNorm template<class Form, class Type> Foam::scalar Foam::Matrix<Form, Type>::norm(const bool noSqrt) const { - scalar result = Zero; + scalar result(0); for (const Type& val : *this) { @@ -596,7 +596,7 @@ void Foam::Matrix<Form, Type>::operator=(const Type& val) template<class Form, class Type> -void Foam::Matrix<Form, Type>::operator=(const Foam::zero) +void Foam::Matrix<Form, Type>::operator=(Foam::zero) { std::fill_n(begin(), size(), Zero); } diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H index 7099fd52a490aa28bf2dacc922ca5a90bc066793..6b9e5cce6fa5aa153d88c33cfe0d1a9f41d2ed5a 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.H +++ b/src/OpenFOAM/matrices/Matrix/Matrix.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -105,11 +105,25 @@ class Matrix public: - //- Matrix type - typedef Matrix<Form, Type> mType; + // Typedefs - //- Component type - typedef Type cmptType; + //- Matrix type + typedef Matrix<Form, Type> mType; + + //- The value type the Matrix contains + typedef Type cmptType; + + //- The value type the Matrix contains + typedef Type value_type; + + //- The type to represent the size of a Matrix + typedef label size_type; + + //- Random access iterator for traversing a Matrix + typedef Type* iterator; + + //- Random access iterator for traversing a Matrix + typedef const Type* const_iterator; // Static Member Functions @@ -122,15 +136,6 @@ public: } - // Iterators - - //- Random access iterator for traversing a Matrix - typedef Type* iterator; - - //- Random access iterator for traversing a Matrix - typedef const Type* const_iterator; - - // Constructors //- Default construct (empty matrix) @@ -141,7 +146,7 @@ public: //- Construct with given number of rows/columns //- initializing all elements to zero - Matrix(const label m, const label n, const Foam::zero); + Matrix(const label m, const label n, Foam::zero); //- Construct with given number of rows/columns //- initializing all elements to the given value @@ -152,7 +157,7 @@ public: //- Construct given number of rows/columns //- initializing all elements to zero - inline Matrix(const labelPair& dims, const Foam::zero); + inline Matrix(const labelPair& dims, Foam::zero); //- Construct with given number of rows/columns //- initializing all elements to the given value @@ -213,7 +218,7 @@ public: inline label size() const noexcept; //- Return row/column sizes - inline labelPair sizes() const; + inline labelPair sizes() const noexcept; //- Return const pointer to the first data element, which can also //- be used to address into Matrix contents @@ -462,7 +467,7 @@ public: void operator=(const MatrixBlock<MatrixType>& Mb); //- Assignment of all elements to zero - void operator=(const Foam::zero); + void operator=(Foam::zero); //- Assignment of all elements to the given value void operator=(const Type& val); diff --git a/src/OpenFOAM/matrices/Matrix/MatrixI.H b/src/OpenFOAM/matrices/Matrix/MatrixI.H index ff6768b14f158d34ab695a9c25a0fa08de8968fc..e16f30b694d62fe3e0252019aa177727186f03d7 100644 --- a/src/OpenFOAM/matrices/Matrix/MatrixI.H +++ b/src/OpenFOAM/matrices/Matrix/MatrixI.H @@ -62,7 +62,7 @@ inline Foam::Matrix<Form, Type>::Matrix(const labelPair& dims) template<class Form, class Type> -inline Foam::Matrix<Form, Type>::Matrix(const labelPair& dims, const Foam::zero) +inline Foam::Matrix<Form, Type>::Matrix(const labelPair& dims, Foam::zero) : Matrix<Form, Type>(dims.first(), dims.second(), Foam::zero{}) {} @@ -88,12 +88,12 @@ Foam::Matrix<Form, Type>::clone() const template<class Form, class Type> inline Foam::label Foam::Matrix<Form, Type>::size() const noexcept { - return mRows_ * nCols_; + return (mRows_ * nCols_); } template<class Form, class Type> -inline Foam::labelPair Foam::Matrix<Form, Type>::sizes() const +inline Foam::labelPair Foam::Matrix<Form, Type>::sizes() const noexcept { return labelPair(mRows_, nCols_); } diff --git a/src/OpenFOAM/matrices/MatrixBlock/MatrixBlock.H b/src/OpenFOAM/matrices/MatrixBlock/MatrixBlock.H index e2d005f018863579221959f6c835ce9d940d7c43..51a5edfc066dfbc937c38e1972dbc049770831f2 100644 --- a/src/OpenFOAM/matrices/MatrixBlock/MatrixBlock.H +++ b/src/OpenFOAM/matrices/MatrixBlock/MatrixBlock.H @@ -83,7 +83,17 @@ class ConstMatrixBlock public: - typedef typename MatrixType::cmptType cmptType; + // Typedefs + + //- The value type the Matrix contains + typedef typename MatrixType::cmptType cmptType; + + //- The value type the Matrix contains + typedef typename MatrixType::value_type value_type; + + //- The type to represent the size of a Matrix + typedef typename MatrixType::size_type size_type; + // Constructors @@ -101,13 +111,16 @@ public: // Member Functions //- Return the number of rows in the block - inline label m() const; + label m() const noexcept { return mRows_; } //- Return the number of columns in the block - inline label n() const; + label n() const noexcept { return nCols_; } + + //- The number of elements in the block (m*n) + inline label size() const noexcept; - //- Return row/column sizes - inline labelPair sizes() const; + //- Return row/column sizes of the block + inline labelPair sizes() const noexcept; //- (i, j) const element access operator inline const cmptType& operator() @@ -153,7 +166,16 @@ class MatrixBlock public: - typedef typename MatrixType::cmptType cmptType; + // Typedefs + + //- The value type the Matrix contains + typedef typename MatrixType::cmptType cmptType; + + //- The value type the Matrix contains + typedef typename MatrixType::value_type value_type; + + //- The type to represent the size of a Matrix + typedef typename MatrixType::size_type size_type; // Generated Methods @@ -178,13 +200,16 @@ public: // Member Functions //- Return the number of rows in the block - inline label m() const; + label m() const noexcept { return mRows_; } //- Return the number of columns in the block - inline label n() const; + label n() const noexcept { return nCols_; } + + //- The number of elements in the block (m*n) + inline label size() const noexcept; - //- Return row/column sizes - inline labelPair sizes() const; + //- Return row/column sizes of the block + inline labelPair sizes() const noexcept; //- (i, j) const element access operator inline const cmptType& operator() diff --git a/src/OpenFOAM/matrices/MatrixBlock/MatrixBlockI.H b/src/OpenFOAM/matrices/MatrixBlock/MatrixBlockI.H index 2fc1a0b96e3136b050c267ad7e9f853ddcb047b9..83a1c10abdf046a2030ad28a8b638ee2d29903bb 100644 --- a/src/OpenFOAM/matrices/MatrixBlock/MatrixBlockI.H +++ b/src/OpenFOAM/matrices/MatrixBlock/MatrixBlockI.H @@ -87,42 +87,30 @@ Foam::MatrixBlock<MatrixType>::MatrixBlock // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class MatrixType> -inline Foam::label Foam::ConstMatrixBlock<MatrixType>::m() const +inline Foam::label Foam::ConstMatrixBlock<MatrixType>::size() const noexcept { - return mRows_; + return (mRows_ * nCols_); } template<class MatrixType> -inline Foam::label Foam::ConstMatrixBlock<MatrixType>::n() const +inline Foam::label Foam::MatrixBlock<MatrixType>::size() const noexcept { - return nCols_; + return (mRows_ * nCols_); } template<class MatrixType> -inline Foam::label Foam::MatrixBlock<MatrixType>::m() const -{ - return mRows_; -} - - -template<class MatrixType> -inline Foam::label Foam::MatrixBlock<MatrixType>::n() const -{ - return nCols_; -} - - -template<class MatrixType> -inline Foam::labelPair Foam::ConstMatrixBlock<MatrixType>::sizes() const +inline Foam::labelPair +Foam::ConstMatrixBlock<MatrixType>::sizes() const noexcept { return labelPair(mRows_, nCols_); } template<class MatrixType> -inline Foam::labelPair Foam::MatrixBlock<MatrixType>::sizes() const +inline Foam::labelPair +Foam::MatrixBlock<MatrixType>::sizes() const noexcept { return labelPair(mRows_, nCols_); } diff --git a/src/OpenFOAM/matrices/QRMatrix/QRMatrix.C b/src/OpenFOAM/matrices/QRMatrix/QRMatrix.C index b9a80150191d830433d8df2fb78d5936d7f76107..abf0d664e79f427ccdd5fb316d5f6cd0548a9d41 100644 --- a/src/OpenFOAM/matrices/QRMatrix/QRMatrix.C +++ b/src/OpenFOAM/matrices/QRMatrix/QRMatrix.C @@ -42,7 +42,7 @@ Foam::label Foam::QRMatrix<MatrixType>::calcShapeFactor } else if (mode_ == modes::ECONOMY) { - return min(A.m(), A.n()); + return Foam::min(A.m(), A.n()); } return 0; @@ -127,7 +127,7 @@ void Foam::QRMatrix<MatrixType>::decompose { const label n = AT.m(); const label m = AT.n(); - const label sz = min(m,n); + const label sz = Foam::min(m, n); // Initialise permutation vector, and column norm vector p_ = identity(n); diff --git a/src/OpenFOAM/matrices/QRMatrix/QRMatrix.H b/src/OpenFOAM/matrices/QRMatrix/QRMatrix.H index 1e6a8d2a0ddba271897aebd950fb2b3db4efb344..b70fc7ca669a61a415fa3e8824540157df375eae 100644 --- a/src/OpenFOAM/matrices/QRMatrix/QRMatrix.H +++ b/src/OpenFOAM/matrices/QRMatrix/QRMatrix.H @@ -154,6 +154,9 @@ class QRMatrix public: typedef typename MatrixType::cmptType cmptType; + typedef typename MatrixType::size_type size_type; + typedef typename MatrixType::value_type value_type; + typedef SquareMatrix<cmptType> SMatrix; typedef RectangularMatrix<cmptType> RMatrix; @@ -241,6 +244,13 @@ private: ) const; +public: + + // Generated Methods + + //- No default construct + QRMatrix() = delete; + //- No copy construct QRMatrix(const QRMatrix&) = delete; @@ -248,13 +258,8 @@ private: QRMatrix& operator=(const QRMatrix&) = delete; -public: - // Constructors - //- No default construct - QRMatrix() = delete; - //- Construct with a matrix and perform QR decomposition explicit QRMatrix ( @@ -360,6 +365,9 @@ public: SMatrix inv() const; }; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + namespace MatrixTools { diff --git a/src/OpenFOAM/matrices/QRMatrix/QRMatrixI.H b/src/OpenFOAM/matrices/QRMatrix/QRMatrixI.H index bf61a6b4e908908076f35a3eee039f40ed28c917..32d85a150364089f235763c26528bdba0aa474d8 100644 --- a/src/OpenFOAM/matrices/QRMatrix/QRMatrixI.H +++ b/src/OpenFOAM/matrices/QRMatrix/QRMatrixI.H @@ -32,7 +32,7 @@ template<class MatrixType> inline Foam::SquareMatrix<typename MatrixType::cmptType> Foam::QRMatrix<MatrixType>::P() const { - SquareMatrix<cmptType> P(p_.size(), Zero); + SquareMatrix<cmptType> P(p_.size(), Foam::zero{}); forAll(p_, jcol) { diff --git a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H index 179e5a1339cc3acc203e733c6d4c99185f8a28cc..ffe8ea74be64279c84acfae0c81f2bfd4a1c8fe6 100644 --- a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H +++ b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H @@ -87,7 +87,7 @@ public: ( const label m, const label n, - const Foam::zero + Foam::zero ); //- Construct given number of rows/columns @@ -108,7 +108,7 @@ public: //- Construct given number of rows/columns by using a label pair //- and initializing all elements to zero - inline RectangularMatrix(const labelPair& dims, const Foam::zero); + inline RectangularMatrix(const labelPair& dims, Foam::zero); //- Construct given number of rows/columns by using a label pair //- and initializing all elements to the given value @@ -138,7 +138,7 @@ public: inline void operator=(RectangularMatrix<Type>&& mat); //- Assign all elements to zero - inline void operator=(const Foam::zero); + inline void operator=(Foam::zero); //- Assign all elements to value inline void operator=(const Type& val); diff --git a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H index 3033c1dc4d2032e2eff6ae8d2fe718dbbe2911a4..b514e5d4a27bc3f20b0bb726fda96052aa783051 100644 --- a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H +++ b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H @@ -54,7 +54,7 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix ( const label m, const label n, - const Foam::zero + Foam::zero ) : Matrix<RectangularMatrix<Type>, Type>(m, n, Foam::zero{}) @@ -83,7 +83,9 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix : RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{}) { - for (label i = 0; i < min(dims.first(), dims.second()); ++i) + const label len = Foam::min(dims.first(), dims.second()); + + for (label i = 0; i < len; ++i) { this->operator()(i, i) = pTraits<Type>::one; } @@ -104,7 +106,7 @@ template<class Type> inline Foam::RectangularMatrix<Type>::RectangularMatrix ( const labelPair& dims, - const Foam::zero + Foam::zero ) : RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{}) @@ -182,7 +184,7 @@ inline void Foam::RectangularMatrix<Type>::operator= template<class Type> -inline void Foam::RectangularMatrix<Type>::operator=(const Foam::zero) +inline void Foam::RectangularMatrix<Type>::operator=(Foam::zero) { Matrix<RectangularMatrix<Type>, Type>::operator=(Foam::zero{}); } diff --git a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H index 8ccaeed3419d57951538460bc2383e6be54b4d6c..0ef3cd52a113002bd457eb6bd4caf4300b1c4d54 100644 --- a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H +++ b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H @@ -55,7 +55,6 @@ namespace Foam // Forward Declarations template<class Type> class RectangularMatrix; - /*---------------------------------------------------------------------------*\ Class SquareMatrix Declaration \*---------------------------------------------------------------------------*/ @@ -86,7 +85,7 @@ public: //- Construct for given size (rows == cols) //- initializing all elements to zero - inline SquareMatrix(const label n, const Foam::zero); + inline SquareMatrix(const label n, Foam::zero); //- Construct for given size (rows == cols) //- initializing all elements to the given value @@ -111,7 +110,7 @@ public: //- by using a labelPair (checked to be equal) //- and initializing all elements to zero // For constructor consistency with rectangular matrices - inline SquareMatrix(const labelPair& dims, const Foam::zero); + inline SquareMatrix(const labelPair& dims, Foam::zero); //- Construct given number of rows/columns //- by using a labelPair (checked to be equal) @@ -121,7 +120,7 @@ public: //- Construct given number of rows/columns (checked to be equal) //- initializing all elements to zero - inline SquareMatrix(const label m, const label n, const Foam::zero); + inline SquareMatrix(const label m, const label n, Foam::zero); //- Construct from const sub-matrix block template<class MatrixType> @@ -186,7 +185,7 @@ public: inline void operator=(SquareMatrix<Type>&& mat); //- Assign all elements to zero - inline void operator=(const Foam::zero); + inline void operator=(Foam::zero); //- Assign all elements to value inline void operator=(const Type& val); diff --git a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H index 28c8b15742a118670f71f23c152e4dbbe64f484a..8004330e98d18e2c04c349532061655b373a9e49 100644 --- a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H +++ b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H @@ -48,7 +48,7 @@ template<class Type> inline Foam::SquareMatrix<Type>::SquareMatrix ( const label n, - const Foam::zero + Foam::zero ) : Matrix<SquareMatrix<Type>, Type>(n, n, Foam::zero{}) @@ -118,7 +118,7 @@ template<class Type> inline Foam::SquareMatrix<Type>::SquareMatrix ( const labelPair& dims, - const Foam::zero + Foam::zero ) : Matrix<SquareMatrix<Type>, Type>(dims, Foam::zero{}) @@ -145,7 +145,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix ( const label m, const label n, - const Foam::zero + Foam::zero ) : Matrix<SquareMatrix<Type>, Type>(m, n, Foam::zero{}) @@ -305,7 +305,7 @@ inline void Foam::SquareMatrix<Type>::operator=(SquareMatrix<Type>&& mat) template<class Type> -inline void Foam::SquareMatrix<Type>::operator=(const Foam::zero) +inline void Foam::SquareMatrix<Type>::operator=(Foam::zero) { Matrix<SquareMatrix<Type>, Type>::operator=(Foam::zero{}); } diff --git a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C index be0457bfbf180151bc1f0a2e26ffad05f35b8c75..bf46edeb8a07a1023d548819ed4756a1ddfacac1 100644 --- a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C +++ b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C @@ -38,7 +38,7 @@ Foam::SymmetricSquareMatrix<Type> Foam::invDecomposed { const label n = matrix.n(); - SymmetricSquareMatrix<Type> inv(n, Zero); + SymmetricSquareMatrix<Type> inv(n, Foam::zero{}); for (label i = 0; i < n; ++i) { @@ -57,7 +57,7 @@ Foam::SymmetricSquareMatrix<Type> Foam::invDecomposed } } - SymmetricSquareMatrix<Type> result(n, Zero); + SymmetricSquareMatrix<Type> result(n, Foam::zero{}); for (label k = 0; k < n; ++k) { diff --git a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.H b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.H index 4475f12d49cafdaff102d352632d19a231e7524f..84924e5aca192613489535f94d73cc2cc2fcdc70 100644 --- a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.H +++ b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.H @@ -81,7 +81,7 @@ public: //- Construct for given size (rows == cols) //- initializing all elements to zero - inline SymmetricSquareMatrix(const label n, const Foam::zero); + inline SymmetricSquareMatrix(const label n, Foam::zero); //- Construct for given size (rows == cols) //- initializing all elements to the given value @@ -102,7 +102,7 @@ public: // Member Operators //- Assign all elements to zero - inline void operator=(const Foam::zero); + inline void operator=(Foam::zero); //- Assign all elements to value inline void operator=(const Type& val); diff --git a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrixI.H b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrixI.H index 008db20346cd2d27d26c8867a456c62471103172..3e14354cf449085b75f2e1149944a3df1c10148e 100644 --- a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrixI.H +++ b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrixI.H @@ -48,7 +48,7 @@ template<class Type> inline Foam::SymmetricSquareMatrix<Type>::SymmetricSquareMatrix ( const label n, - const Foam::zero + Foam::zero ) : Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Foam::zero{}) @@ -103,7 +103,7 @@ Foam::SymmetricSquareMatrix<Type>::clone() const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class Type> -inline void Foam::SymmetricSquareMatrix<Type>::operator=(const Foam::zero) +inline void Foam::SymmetricSquareMatrix<Type>::operator=(Foam::zero) { Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Foam::zero{}); } diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C index 693a33ff015abbcd62b409dffcbe4fbbde8a6b44..d5e1075bbde6806aaf7998ad975dba431eff5979 100644 --- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C +++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,6 +51,14 @@ Foam::simpleMatrix<Type>::simpleMatrix {} +template<class Type> +Foam::simpleMatrix<Type>::simpleMatrix(const label n, Foam::zero) +: + scalarSquareMatrix(n, Foam::zero{}), + source_(n, Foam::zero{}) +{} + + template<class Type> Foam::simpleMatrix<Type>::simpleMatrix ( diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H index f68304397c25e8309e8d22d43ad325e96f306fb9..460e2c941cc71010fec8d8a6cbef34e1f2a32da4 100644 --- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H +++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef simpleMatrix_H -#define simpleMatrix_H +#ifndef Foam_simpleMatrix_H +#define Foam_simpleMatrix_H #include "scalarMatrices.H" @@ -44,18 +45,9 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -template<class Type> -class simpleMatrix; - -template<class Type> -Ostream& operator<< -( - Ostream&, - const simpleMatrix<Type>& -); - +// Forward Declarations +template<class Type> class simpleMatrix; +template<class Type> Ostream& operator<<(Ostream&, const simpleMatrix<Type>&); /*---------------------------------------------------------------------------*\ Class simpleMatrix Declaration @@ -66,60 +58,55 @@ class simpleMatrix : public scalarSquareMatrix { - // Private data + // Private Data Field<Type> source_; - public: // Constructors //- Construct given size // Note: this does not initialise the coefficients or the source. - simpleMatrix(const label); + explicit simpleMatrix(const label n); //- Construct given size and initial values for coefficients and source - simpleMatrix(const label, const scalar, const Type&); + simpleMatrix(const label n, const scalar, const Type&); + + //- Construct given size, zero values for coefficients and source + simpleMatrix(const label n, Foam::zero); //- Construct from components simpleMatrix(const scalarSquareMatrix&, const Field<Type>&); - //- Construct from Istream - simpleMatrix(Istream&); + //- Copy construct + simpleMatrix(const simpleMatrix<Type>&) = default; - //- Construct as copy - simpleMatrix(const simpleMatrix<Type>&); + //- Construct from Istream + explicit simpleMatrix(Istream&); // Member Functions - // Access + //- Return access to the source + Field<Type>& source() noexcept { return source_; } - //- Return access to the source - Field<Type>& source() - { - return source_; - } - - //- Return const-access to the source - const Field<Type>& source() const - { - return source_; - } + //- Return const-access to the source + const Field<Type>& source() const noexcept { return source_; } //- Solve the matrix using Gaussian elimination with pivoting - // and return the solution + //- and return the solution Field<Type> solve() const; //- Solve the matrix using LU decomposition with pivoting - // and return the solution + //- and return the solution Field<Type> LUsolve() const; // Member Operators + //- Copy assignment void operator=(const simpleMatrix<Type>&); @@ -133,7 +120,9 @@ public: }; -// Global operators +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Global Operators template<class Type> simpleMatrix<Type> operator+ diff --git a/src/OpenFOAM/meshes/ijkMesh/IjkField.H b/src/OpenFOAM/meshes/ijkMesh/IjkField.H index 26a2ca348ddea8a260bed0ab6acfabb3ce0b6be9..f7e0b2844956ee8b4fb2518ee44b6d3cf2b42205 100644 --- a/src/OpenFOAM/meshes/ijkMesh/IjkField.H +++ b/src/OpenFOAM/meshes/ijkMesh/IjkField.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef IjkField_H -#define IjkField_H +#ifndef Foam_IjkField_H +#define Foam_IjkField_H #include "ijkAddressing.H" #include "Field.H" @@ -95,22 +95,22 @@ public: // Access //- Return i,j,k addressing - inline const ijkAddressing& ijk() const; + const ijkAddressing& ijk() const noexcept { return ijk_; } //- Return i,j,k addressing for modification - inline ijkAddressing& ijk(); + ijkAddressing& ijk() noexcept { return ijk_; } //- Return i,j,k addressing sizes - inline const labelVector& sizes() const; + const labelVector& sizes() const noexcept { return ijk_.sizes(); } //- Return i,j,k addressing sizes for modification - inline labelVector& sizes(); + labelVector& sizes() noexcept { return ijk_.sizes(); } //- The field size using Field<Type>::size; //- The addressing dimension in the given direction - inline const label& size(const vector::components cmpt) const; + inline label size(const vector::components cmpt) const; // Edit @@ -161,7 +161,7 @@ public: //- Value assignment inline void operator=(const Type& val); - inline void operator=(const Foam::zero); + inline void operator=(Foam::zero); }; diff --git a/src/OpenFOAM/meshes/ijkMesh/IjkFieldI.H b/src/OpenFOAM/meshes/ijkMesh/IjkFieldI.H index 67a6fcc5d4d03bd74c0ba303615b297a7b8df54f..45c9afade783bb514bd11defacf9f4ae465eac15 100644 --- a/src/OpenFOAM/meshes/ijkMesh/IjkFieldI.H +++ b/src/OpenFOAM/meshes/ijkMesh/IjkFieldI.H @@ -132,35 +132,7 @@ inline Foam::IjkField<Type>::IjkField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -inline const Foam::ijkAddressing& Foam::IjkField<Type>::ijk() const -{ - return ijk_; -} - - -template<class Type> -inline Foam::ijkAddressing& Foam::IjkField<Type>::ijk() -{ - return ijk_; -} - - -template<class Type> -inline const Foam::labelVector& Foam::IjkField<Type>::sizes() const -{ - return ijk_.sizes(); -} - - -template<class Type> -inline Foam::labelVector& Foam::IjkField<Type>::sizes() -{ - return ijk_.sizes(); -} - - -template<class Type> -inline const Foam::label& Foam::IjkField<Type>::size +inline Foam::label Foam::IjkField<Type>::size ( const vector::components cmpt ) const @@ -245,7 +217,7 @@ inline void Foam::IjkField<Type>::operator=(const Type& val) template<class Type> -inline void Foam::IjkField<Type>::operator=(const Foam::zero) +inline void Foam::IjkField<Type>::operator=(Foam::zero) { Field<Type>::operator=(Foam::zero{}); } diff --git a/src/OpenFOAM/meshes/ijkMesh/ijkAddressing.H b/src/OpenFOAM/meshes/ijkMesh/ijkAddressing.H index 1409d3b967d9e0a57b725bfc2d64bc8f14c1d443..cc221f3acfcd54b22652311e1e1bcf19e7545e0b 100644 --- a/src/OpenFOAM/meshes/ijkMesh/ijkAddressing.H +++ b/src/OpenFOAM/meshes/ijkMesh/ijkAddressing.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,19 +76,19 @@ public: // Access //- Addressing is considered empty if any component is zero - inline bool empty() const; + inline bool empty() const noexcept; //- The (i,j,k) addressing dimensions - inline const labelVector& sizes() const; + const labelVector& sizes() const noexcept { return sizes_; } //- Return the (i,j,k) dimensions for modification - inline labelVector& sizes(); + labelVector& sizes() noexcept { return sizes_; } //- Return the total i*j*k size - inline label size() const; + inline label size() const noexcept; //- The addressing dimension in the given direction - inline const label& size(const vector::components cmpt) const; + inline label size(const vector::components cmpt) const; //- Reset to (0,0,0) sizing inline void clear(); diff --git a/src/OpenFOAM/meshes/ijkMesh/ijkAddressingI.H b/src/OpenFOAM/meshes/ijkMesh/ijkAddressingI.H index 5f238e3584e28cbcfaf0b4eadbfb2bcc3f4d3ff1..28685cdefdc8d0a7ee5fc6ec4cefb24961c2cdb1 100644 --- a/src/OpenFOAM/meshes/ijkMesh/ijkAddressingI.H +++ b/src/OpenFOAM/meshes/ijkMesh/ijkAddressingI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,32 +60,20 @@ inline Foam::ijkAddressing::ijkAddressing // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline bool Foam::ijkAddressing::empty() const +inline bool Foam::ijkAddressing::empty() const noexcept { return (!sizes_.x() || !sizes_.y() || !sizes_.z()); } -inline const Foam::labelVector& Foam::ijkAddressing::sizes() const -{ - return sizes_; -} - - -inline Foam::labelVector& Foam::ijkAddressing::sizes() -{ - return sizes_; -} - - -inline Foam::label Foam::ijkAddressing::size() const +inline Foam::label Foam::ijkAddressing::size() const noexcept { // Could also use cmptProduct(sizes_); return (sizes_.x() * sizes_.y() * sizes_.z()); } -inline const Foam::label& Foam::ijkAddressing::size +inline Foam::label Foam::ijkAddressing::size ( const vector::components cmpt ) const @@ -96,7 +84,7 @@ inline const Foam::label& Foam::ijkAddressing::size inline void Foam::ijkAddressing::clear() { - sizes_ = Zero; + sizes_ = Foam::zero{}; } diff --git a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H index 2e62323e78c6cef0a40a4490042efbed1141a4f1..da045df48941f2d7858c5950f2b4ce01d38c9651 100644 --- a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H +++ b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -77,16 +77,10 @@ public: // Static Member Functions //- The number of rows - static direction m() noexcept - { - return Mrows; - } + static direction m() noexcept { return Mrows; } //- The number of columns - static direction n() noexcept - { - return Ncols; - } + static direction n() noexcept { return Ncols; } //- An identity matrix for square matrix-spaces inline static msType identity(); @@ -107,16 +101,10 @@ public: static const direction nCols = SubTensor::nCols; //- Return the number of rows in the block - static direction m() - { - return mRows; - } + static direction m() noexcept { return mRows; } //- Return the number of columns in the block - static direction n() - { - return nCols; - } + static direction n() noexcept { return nCols; } //- Construct for the given matrix inline ConstBlock(const msType& matrix); @@ -151,16 +139,10 @@ public: static const direction nCols = SubTensor::nCols; //- The number of rows in the block - static direction m() - { - return mRows; - } + static direction m() noexcept { return mRows; } //- The number of columns in the block - static direction n() - { - return nCols; - } + static direction n() noexcept { return nCols; } //- Construct for the given matrix inline Block(msType& matrix); @@ -209,7 +191,7 @@ public: // Constructors //- Construct initialized to zero - inline MatrixSpace(const Foam::zero); + inline MatrixSpace(Foam::zero); //- Construct as copy of a VectorSpace with the same size template<class Form2, class Cmpt2> @@ -289,18 +271,18 @@ public: //- (i, j) const element access operator inline const Cmpt& operator() ( - const direction& i, - const direction& j + const direction i, + const direction j ) const; //- (i, j) element access operator - inline Cmpt& operator()(const direction& i, const direction& j); + inline Cmpt& operator()(const direction i, const direction j); // Member Operators //- Assignment to zero - inline void operator=(const Foam::zero); + inline void operator=(Foam::zero); //- Assignment to a block of another matrix space template diff --git a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H index f9061dd9bf68aa2b28331b9b350e5cc76cbf7eb9..f1698368ed2e03eff328f0f099fd0b5b7103145c 100644 --- a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H +++ b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H @@ -32,10 +32,10 @@ License template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols> inline Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::MatrixSpace ( - const Foam::zero + Foam::zero ) : - MatrixSpace::vsType(Zero) + MatrixSpace::vsType(Foam::zero{}) {} @@ -213,8 +213,8 @@ Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::block() template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols> inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator() ( - const direction& i, - const direction& j + const direction i, + const direction j ) const { #ifdef FULLDEBUG @@ -233,8 +233,8 @@ inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator() template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols> inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator() ( - const direction& i, - const direction& j + const direction i, + const direction j ) { #ifdef FULLDEBUG @@ -318,10 +318,10 @@ operator()(const direction i, const direction j) template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols> inline void Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator= ( - const Foam::zero + Foam::zero ) { - MatrixSpace::vsType::operator=(Zero); + MatrixSpace::vsType::operator=(Foam::zero{}); } diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H index c3f7163c4b73b39447d26e75fe6da14fa8f1c16d..d9035c7250d64d74b2157d82c959253df42c2c87 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H @@ -92,6 +92,9 @@ public: //- Magnitude type typedef Cmpt magType; + //- The type to represent the size of a VectorSpace + typedef direction size_type; + // Static Constants diff --git a/src/functionObjects/field/DMD/DMDModels/derived/STDMD/STDMD.C b/src/functionObjects/field/DMD/DMDModels/derived/STDMD/STDMD.C index 5f503d8646f6f87bfc5d58c6e9cdd566e340c818..094a93d64d263995602bd829695ca258d925ee5e 100644 --- a/src/functionObjects/field/DMD/DMDModels/derived/STDMD/STDMD.C +++ b/src/functionObjects/field/DMD/DMDModels/derived/STDMD/STDMD.C @@ -173,8 +173,8 @@ void Foam::DMDModels::STDMD::compress() DiagonalMatrix<scalar> EVals(EM.EValsRe()); // Sort eigenvalues in descending order, and track indices - const auto descend = [&](scalar a, scalar b){ return a > b; }; - const List<label> permutation(EVals.sortPermutation(descend)); + const auto descend = [](scalar a, scalar b){ return a > b; }; + const labelList permutation(EVals.sortPermutation(descend)); EVals.applyPermutation(permutation); EVals.resize(EVals.size() - 1);