Bugfix: minor clean-up
This commit is contained in:
parent
c814ad6052
commit
159422eba7
2 changed files with 63 additions and 30 deletions
|
@ -80,6 +80,7 @@ void Foam::ILU0::calcPreconDiag()
|
|||
// Note: change of the sign compared to main loop below
|
||||
// This is because lower = -intCoeffs
|
||||
// HJ and VV, 19/Jun/2017
|
||||
// Note: sign fixed by HJ, 19/Jun/2017
|
||||
preconDiag_[fc[coeffI]] +=
|
||||
bouCoeffs[coeffI]*intCoeffs[coeffI]/
|
||||
preconDiag_[fc[coeffI]];
|
||||
|
@ -217,15 +218,15 @@ void Foam::ILU0::precondition
|
|||
const scalarField& upper = matrix_.upper();
|
||||
const scalarField& lower = matrix_.lower();
|
||||
|
||||
label losortCoeff;
|
||||
label losortIndex;
|
||||
|
||||
forAll (lower, coeffI)
|
||||
{
|
||||
losortCoeff = losortAddr[coeffI];
|
||||
losortIndex = losortAddr[coeffI];
|
||||
|
||||
x[upperAddr[losortCoeff]] -=
|
||||
preconDiag_[upperAddr[losortCoeff]]*
|
||||
lower[losortCoeff]*x[lowerAddr[losortCoeff]];
|
||||
x[upperAddr[losortIndex]] -=
|
||||
preconDiag_[upperAddr[losortIndex]]*
|
||||
lower[losortIndex]*x[lowerAddr[losortIndex]];
|
||||
}
|
||||
|
||||
forAllReverse (upper, coeffI)
|
||||
|
@ -234,6 +235,38 @@ void Foam::ILU0::precondition
|
|||
preconDiag_[lowerAddr[coeffI]]*
|
||||
upper[coeffI]*x[upperAddr[coeffI]];
|
||||
}
|
||||
/*
|
||||
// Parallel preconditioning
|
||||
// HJ, 19/Jun/2017
|
||||
|
||||
scalarField xCorr(x.size(), 0);
|
||||
|
||||
// Coupled boundary update
|
||||
{
|
||||
matrix_.initMatrixInterfaces
|
||||
(
|
||||
coupleBouCoeffs_,
|
||||
interfaces_,
|
||||
x,
|
||||
xCorr, // put result into xCorr
|
||||
cmpt,
|
||||
false
|
||||
);
|
||||
|
||||
matrix_.updateMatrixInterfaces
|
||||
(
|
||||
coupleBouCoeffs_,
|
||||
interfaces_,
|
||||
x,
|
||||
xCorr, // put result into xCorr
|
||||
cmpt,
|
||||
false
|
||||
);
|
||||
|
||||
// Multiply with inverse diag to precondition
|
||||
x += xCorr*preconDiag_;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,7 +324,7 @@ void Foam::ILU0::preconditionT
|
|||
const scalarField& upper = matrix_.upper();
|
||||
const scalarField& lower = matrix_.lower();
|
||||
|
||||
label losortCoeff;
|
||||
label losortIndex;
|
||||
|
||||
forAll (lower, coeffI)
|
||||
{
|
||||
|
@ -303,12 +336,12 @@ void Foam::ILU0::preconditionT
|
|||
|
||||
forAllReverse (upper, coeffI)
|
||||
{
|
||||
losortCoeff = losortAddr[coeffI];
|
||||
losortIndex = losortAddr[coeffI];
|
||||
|
||||
// Transpose multiplication. HJ, 19/Jan/2009
|
||||
x[lowerAddr[losortCoeff]] -=
|
||||
preconDiag_[lowerAddr[losortCoeff]]*
|
||||
lower[losortCoeff]*x[upperAddr[losortCoeff]];
|
||||
x[lowerAddr[losortIndex]] -=
|
||||
preconDiag_[lowerAddr[losortIndex]]*
|
||||
lower[losortIndex]*x[upperAddr[losortIndex]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,13 +125,13 @@ void Foam::ILUC0::calcFactorization()
|
|||
)
|
||||
{
|
||||
// Get losort coefficient for this face
|
||||
const register label losortCoeff = lsrPtr[faceLsrI];
|
||||
const register label losortIndex = lsrPtr[faceLsrI];
|
||||
|
||||
// Get corresponding row index for upper (i label)
|
||||
const label i = lPtr[losortCoeff];
|
||||
const label i = lPtr[losortIndex];
|
||||
|
||||
// Update diagonal
|
||||
zDiag_ -= lowerPtr[losortCoeff]*upperPtr[losortCoeff];
|
||||
zDiag_ -= lowerPtr[losortIndex]*upperPtr[losortIndex];
|
||||
|
||||
// Get end of row for cell i
|
||||
const register label fEndRowi = ownStartPtr[i + 1];
|
||||
|
@ -140,14 +140,14 @@ void Foam::ILUC0::calcFactorization()
|
|||
// existence of certain upper coeffs)
|
||||
for
|
||||
(
|
||||
// Diagonal is already updated (losortCoeff + 1 = start)
|
||||
register label faceI = losortCoeff + 1;
|
||||
// Diagonal is already updated (losortIndex + 1 = start)
|
||||
register label faceI = losortIndex + 1;
|
||||
faceI < fEndRowi;
|
||||
++faceI
|
||||
)
|
||||
{
|
||||
zPtr[uPtr[faceI]] -= lowerPtr[losortCoeff]*upperPtr[faceI];
|
||||
wPtr[uPtr[faceI]] -= upperPtr[losortCoeff]*lowerPtr[faceI];
|
||||
zPtr[uPtr[faceI]] -= lowerPtr[losortIndex]*upperPtr[faceI];
|
||||
wPtr[uPtr[faceI]] -= upperPtr[losortIndex]*lowerPtr[faceI];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,17 +182,17 @@ void Foam::ILUC0::calcFactorization()
|
|||
)
|
||||
{
|
||||
// Get losort coefficient for this face
|
||||
const register label losortCoeff = lsrPtr[faceLsrI];
|
||||
const register label losortIndex = lsrPtr[faceLsrI];
|
||||
|
||||
// Get corresponding row index for upper (i label)
|
||||
const label i = lPtr[losortCoeff];
|
||||
const label i = lPtr[losortIndex];
|
||||
|
||||
// Get end of row for cell i
|
||||
const register label fEndRowi = ownStartPtr[i + 1];
|
||||
|
||||
for
|
||||
(
|
||||
register label faceI = losortCoeff + 1;
|
||||
register label faceI = losortIndex + 1;
|
||||
faceI < fEndRowi;
|
||||
++faceI
|
||||
)
|
||||
|
@ -297,18 +297,18 @@ void Foam::ILUC0::precondition
|
|||
// Initialize x field
|
||||
x = b;
|
||||
|
||||
register label losortCoeffI;
|
||||
register label losortIndexI;
|
||||
register label rowI;
|
||||
|
||||
// Forward substitution loop
|
||||
forAll (preconLower_, coeffI)
|
||||
{
|
||||
// Get current losortCoeff to ensure row by row access
|
||||
losortCoeffI = losortAddr[coeffI];
|
||||
// Get current losortIndex to ensure row by row access
|
||||
losortIndexI = losortAddr[coeffI];
|
||||
|
||||
// Subtract already updated lower part from the solution
|
||||
x[upperAddr[losortCoeffI]] -=
|
||||
preconLower_[losortCoeffI]*x[lowerAddr[losortCoeffI]];
|
||||
x[upperAddr[losortIndexI]] -=
|
||||
preconLower_[losortIndexI]*x[lowerAddr[losortIndexI]];
|
||||
}
|
||||
|
||||
// Solve Ux = b with back substitution. U is chosen to be upper
|
||||
|
@ -373,21 +373,21 @@ void Foam::ILUC0::preconditionT
|
|||
x[i] = b[i]*preconDiag_[i];
|
||||
}
|
||||
|
||||
register label losortCoeffI;
|
||||
register label losortIndexI;
|
||||
register label rowI;
|
||||
|
||||
// Forward substitution loop
|
||||
forAll (preconUpper_, coeffI)
|
||||
{
|
||||
// Get current losortCoeff to ensure row by row access
|
||||
losortCoeffI = losortAddr[coeffI];
|
||||
// Get current losortIndex to ensure row by row access
|
||||
losortIndexI = losortAddr[coeffI];
|
||||
|
||||
// Get row index
|
||||
rowI = upperAddr[losortCoeffI];
|
||||
rowI = upperAddr[losortIndexI];
|
||||
|
||||
// Subtract already updated lower (upper transpose) part from the
|
||||
// solution
|
||||
x[rowI] -= preconUpper_[losortCoeffI]*x[lowerAddr[losortCoeffI]]*
|
||||
x[rowI] -= preconUpper_[losortIndexI]*x[lowerAddr[losortIndexI]]*
|
||||
preconDiag_[rowI];
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue