From bae31764dc352ce7a6cfd33b94c01ed892cbe333 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 10 May 2017 13:19:15 +0100 Subject: [PATCH] Changed crMatrix and crAddressing member naming --- src/foam/matrices/crMatrix/crAddressing.C | 77 ++-- src/foam/matrices/crMatrix/crAddressing.H | 31 +- src/foam/matrices/crMatrix/crMatrix.C | 12 +- src/foam/matrices/crMatrix/crMatrix.H | 8 +- .../processorSAMGInterface.C | 339 +++++++++--------- .../processorSAMGInterface.H | 13 +- 6 files changed, 249 insertions(+), 231 deletions(-) diff --git a/src/foam/matrices/crMatrix/crAddressing.C b/src/foam/matrices/crMatrix/crAddressing.C index 05c33839c..f7e2a81d8 100644 --- a/src/foam/matrices/crMatrix/crAddressing.C +++ b/src/foam/matrices/crMatrix/crAddressing.C @@ -36,28 +36,30 @@ Author // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::crAddressing::setRowCount(const labelList& count) +void Foam::crAddressing::setRowSizes(const labelList& rowSizes) { - if (count.size() != nRows_) + if (rowSizes.size() != nRows_) { - FatalErrorIn("void crAddressing::setRowCount(const labelList& count)") - << "Incorrect size of count: nRows =" << nRows_ - << " count = " << count.size() + FatalErrorIn + ( + "void crAddressing::setRowSizes(const labelList& rowSizes)" + ) << "Incorrect size of rowSizes: nRows =" << nRows_ + << " rowSizes = " << rowSizes.size() << abort(FatalError); } - // Accumulate count - row_[0] = 0; + // Accumulate rowSizes + rowStart_[0] = 0; - forAll (count, i) + forAll (rowSizes, i) { - row_[i + 1] = row_[i] + count[i]; + rowStart_[i + 1] = rowStart_[i] + rowSizes[i]; } // Resize and clear column array - col_.setSize(row_[nRows_]); - col_ = 0; + column_.setSize(rowStart_[nRows_]); + column_ = 0; } @@ -68,16 +70,16 @@ Foam::crAddressing::crAddressing ( const label nRows, const label nCols, - const labelList& count + const labelList& rowSizes ) : refCount(), nRows_(nRows), nCols_(nCols), - row_(nRows + 1), - col_(0) + rowStart_(nRows + 1), + column_(0) { - setRowCount(count); + setRowSizes(rowSizes); } @@ -93,8 +95,8 @@ Foam::crAddressing::crAddressing refCount(), nRows_(nRows), nCols_(nCols), - row_(row), - col_(col) + rowStart_(row), + column_(col) {} @@ -104,8 +106,8 @@ Foam::crAddressing::crAddressing(const crAddressing& a) refCount(), nRows_(a.nRows_), nCols_(a.nCols_), - row_(a.row_), - col_(a.col_) + rowStart_(a.rowStart_), + column_(a.column_) {} @@ -115,8 +117,8 @@ Foam::crAddressing::crAddressing(Istream& is) refCount(), nRows_(readLabel(is)), nCols_(readLabel(is)), - row_(is), - col_(is) + rowStart_(is), + column_(is) {} @@ -124,31 +126,34 @@ Foam::crAddressing::crAddressing(Istream& is) Foam::tmp Foam::crAddressing::T() const { - const labelList& myRow = row(); - const labelList& myCol = col(); + const labelList& myRow = rowStart(); + const labelList& myCol = column(); - labelList trCount(nCols(), 0); + labelList trRowSizes(nCols(), 0); // Count number of entries in a row for (label i = 0; i < nRows(); i++) { for (label ip = myRow[i]; ip < myRow[i + 1]; ip++) { - trCount[myCol[ip]]++; + trRowSizes[myCol[ip]]++; } } // Create transpose addressing - tmp ttranspose(new crAddressing(nCols(), nRows(), trCount)); + tmp ttranspose + ( + new crAddressing(nCols(), nRows(), trRowSizes) + ); crAddressing& transpose = ttranspose(); // Set coefficients - const labelList& trRow = transpose.row(); - labelList& trCol = transpose.col(); + const labelList& trRow = transpose.rowStart(); + labelList& trCol = transpose.column(); trCol = 0; - // Reset count to use as counter - trCount = 0; + // Reset rowSizes to use as counter + trRowSizes = 0; label j; @@ -158,9 +163,9 @@ Foam::tmp Foam::crAddressing::T() const { j = myCol[ip]; - trCol[trRow[j] + trCount[j]] = i; + trCol[trRow[j] + trRowSizes[j]] = i; - trCount[j]++; + trRowSizes[j]++; } } @@ -184,8 +189,8 @@ void Foam::crAddressing::operator=(const crAddressing& rhs) nRows_ = rhs.nRows_; nCols_ = rhs.nCols_; - row_ = rhs.row_; - col_ = rhs.col_; + rowStart_ = rhs.rowStart_; + column_ = rhs.column_; } @@ -194,8 +199,8 @@ void Foam::crAddressing::operator=(const crAddressing& rhs) Foam::Ostream& Foam::operator<<(Ostream& os, const crAddressing& a) { os << a.nRows_ << tab << a.nCols_ << nl - << a.row_ << nl - << a.col_ << endl; + << a.rowStart_ << nl + << a.column_ << endl; return os; } diff --git a/src/foam/matrices/crMatrix/crAddressing.H b/src/foam/matrices/crMatrix/crAddressing.H index a95c62d33..517e3d57d 100644 --- a/src/foam/matrices/crMatrix/crAddressing.H +++ b/src/foam/matrices/crMatrix/crAddressing.H @@ -64,15 +64,15 @@ class crAddressing //- Row array. // Provides start index for each row, dimensioned to nRows + 1 - labelList row_; + labelList rowStart_; - //- Column array - labelList col_; + //- Column index array + labelList column_; // Private Member Functions - //- Set row count - void setRowCount(const labelList& count); + //- Set row sizes + void setRowSizes(const labelList& count); public: @@ -84,7 +84,7 @@ public: ( const label nRows, const label nCols, - const labelList& count + const labelList& nEntries ); //- Construct from components @@ -92,8 +92,8 @@ public: ( const label nRows, const label nCols, - const labelList& row, - const labelList& col + const labelList& rowStart, + const labelList& column ); //- Construct as copy @@ -125,28 +125,28 @@ public: //- Return number of coefficients label nEntries() const { - return col_.size(); + return column_.size(); } //- Return row array - const labelList& row() const + const labelList& rowStart() const { - return row_; + return rowStart_; } //- Return column array - const labelList& col() const + const labelList& column() const { - return col_; + return column_; } // Edit //- Return column array - labelList& col() + labelList& column() { - return col_; + return column_; } @@ -160,6 +160,7 @@ public: void operator=(const crAddressing&); + // IOstream Operators friend Ostream& operator<<(Ostream&, const crAddressing&); diff --git a/src/foam/matrices/crMatrix/crMatrix.C b/src/foam/matrices/crMatrix/crMatrix.C index b26e3e4a9..942583999 100644 --- a/src/foam/matrices/crMatrix/crMatrix.C +++ b/src/foam/matrices/crMatrix/crMatrix.C @@ -109,8 +109,8 @@ Foam::tmp Foam::crMatrix::T() const { // My addressing const label myNRows = crAddr().nRows(); - const labelList& myRow = crAddr().row(); - const labelList& myCol = crAddr().col(); + const labelList& myRow = crAddr().rowStart(); + const labelList& myCol = crAddr().column(); const scalarField& myCoeffs = coeffs(); // Create transpose @@ -123,8 +123,8 @@ Foam::tmp Foam::crMatrix::T() const tCoeffs = 0; // Transpose addressing - const labelList& tRow = transpose.crAddr().row(); - const labelList& tCol = transpose.crAddr().col(); + const labelList& tRow = transpose.crAddr().rowStart(); + const labelList& tCol = transpose.crAddr().column(); // Set transpose coefficients @@ -153,8 +153,8 @@ Foam::tmp Foam::crMatrix::T() const // Calculate b += A*x void Foam::crMatrix::dotPlus(scalarField& b, const scalarField& x) const { - const labelList& row = crAddr_.row(); - const labelList& col = crAddr_.col(); + const labelList& row = crAddr_.rowStart(); + const labelList& col = crAddr_.column(); forAll (b, i) { diff --git a/src/foam/matrices/crMatrix/crMatrix.H b/src/foam/matrices/crMatrix/crMatrix.H index d63025810..449bb5233 100644 --- a/src/foam/matrices/crMatrix/crMatrix.H +++ b/src/foam/matrices/crMatrix/crMatrix.H @@ -83,8 +83,8 @@ public: ( const label nRows, const label nCols, - const labelList& row, - const labelList& col + const labelList& rowStart, + const labelList& column ); //- Construct as copy @@ -123,9 +123,9 @@ public: } //- Return column array to be set - labelList& col() + labelList& column() { - return crAddr_.col(); + return crAddr_.column(); } diff --git a/src/foam/matrices/lduMatrix/solvers/AMG/interfaces/SAMGInterfaces/processorSAMGInterface/processorSAMGInterface.C b/src/foam/matrices/lduMatrix/solvers/AMG/interfaces/SAMGInterfaces/processorSAMGInterface/processorSAMGInterface.C index 769e1e571..586c2200c 100644 --- a/src/foam/matrices/lduMatrix/solvers/AMG/interfaces/SAMGInterfaces/processorSAMGInterface/processorSAMGInterface.C +++ b/src/foam/matrices/lduMatrix/solvers/AMG/interfaces/SAMGInterfaces/processorSAMGInterface/processorSAMGInterface.C @@ -45,210 +45,215 @@ namespace Foam Foam::processorSAMGInterface::processorSAMGInterface ( const lduPrimitiveMesh& lduMesh, + const crMatrix& prolongation, const lduInterfacePtrsList& coarseInterfaces, const lduInterface& fineInterface, - const labelField& localRestrictAddressing, - const labelField& neighbourRestrictAddressing + const labelField& localRowLabel, + const labelField& neighbourRowLabel ) : - SAMGInterface(lduMesh), + SAMGInterface(lduMesh, prolongation), fineProcInterface_(refCast(fineInterface)), comm_(fineProcInterface_.comm()), tag_(fineProcInterface_.tag()) { Pout<< "Creating processor SAMG interface" << endl; - /* HJ, Code missing here - // Make a lookup table of entries for owner/neighbour - HashTable, label, Hash