mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add size_type to Matrix and VectorSpace
- easier to create type-specific looping in templated code STYLE: pass 'direction' and 'label' by value instead of reference COMP: qualify Foam::min() in dense matrix classes
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
Test-IjkField.C
|
||||
Test-IjkField.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IjkField
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-DiagonalMatrix.C
|
||||
Test-DiagonalMatrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-DiagonalMatrix
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-EigenMatrix.C
|
||||
Test-EigenMatrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-EigenMatrix
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-Matrix.C
|
||||
Test-Matrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-Matrix
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-QRMatrix.C
|
||||
Test-QRMatrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-QRMatrix
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-RectangularMatrix.C
|
||||
Test-RectangularMatrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-RectangularMatrix
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SquareMatrix.C
|
||||
Test-SquareMatrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SquareMatrix
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SymmetricSquareMatrix.C
|
||||
Test-SymmetricSquareMatrix.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SymmetricSquareMatrix
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -200,6 +200,12 @@ class EigenMatrix
|
||||
|
||||
public:
|
||||
|
||||
// Typedefs
|
||||
|
||||
//- The value type the Matrix contains
|
||||
typedef cmptType value_type;
|
||||
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- No default construct
|
||||
|
||||
@ -30,11 +30,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::LLTMatrix<Type>::LLTMatrix()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::LLTMatrix<Type>::LLTMatrix(const SquareMatrix<Type>& mat)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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,12 +105,26 @@ class Matrix
|
||||
|
||||
public:
|
||||
|
||||
// Typedefs
|
||||
|
||||
//- Matrix type
|
||||
typedef Matrix<Form, Type> mType;
|
||||
|
||||
//- Component type
|
||||
//- 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);
|
||||
|
||||
@ -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_);
|
||||
}
|
||||
|
||||
@ -83,8 +83,18 @@ class ConstMatrixBlock
|
||||
|
||||
public:
|
||||
|
||||
// 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
|
||||
|
||||
//- Construct block for matrix, size and location
|
||||
@ -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_; }
|
||||
|
||||
//- Return row/column sizes
|
||||
inline labelPair sizes() const;
|
||||
//- The number of elements in the block (m*n)
|
||||
inline label size() const noexcept;
|
||||
|
||||
//- Return row/column sizes of the block
|
||||
inline labelPair sizes() const noexcept;
|
||||
|
||||
//- (i, j) const element access operator
|
||||
inline const cmptType& operator()
|
||||
@ -153,8 +166,17 @@ class MatrixBlock
|
||||
|
||||
public:
|
||||
|
||||
// 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_; }
|
||||
|
||||
//- Return row/column sizes
|
||||
inline labelPair sizes() const;
|
||||
//- The number of elements in the block (m*n)
|
||||
inline label size() const noexcept;
|
||||
|
||||
//- Return row/column sizes of the block
|
||||
inline labelPair sizes() const noexcept;
|
||||
|
||||
//- (i, j) const element access operator
|
||||
inline const cmptType& operator()
|
||||
|
||||
@ -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_);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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{});
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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{});
|
||||
}
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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{});
|
||||
}
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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()
|
||||
{
|
||||
return source_;
|
||||
}
|
||||
Field<Type>& source() noexcept { return source_; }
|
||||
|
||||
//- Return const-access to the source
|
||||
const Field<Type>& source() const
|
||||
{
|
||||
return 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+
|
||||
|
||||
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -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{});
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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{};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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{});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user