Minor extendedLdu matrices consistency rewrite compared to ldu matrices
This commit is contained in:
parent
0ed1532938
commit
4507f15c8f
3 changed files with 71 additions and 166 deletions
|
@ -45,146 +45,73 @@ void Foam::extendedBlockLduMatrix<Type>::mapOffDiagCoeffs
|
||||||
// Get reference to faceMap in extended addressing
|
// Get reference to faceMap in extended addressing
|
||||||
const unallocLabelList& faceMap = extLduAddr_.faceMap();
|
const unallocLabelList& faceMap = extLduAddr_.faceMap();
|
||||||
|
|
||||||
// Avoid assuming it's upper if the matrix is symmetric
|
// Matrix is considered symmetric if the upper is allocated and lower
|
||||||
if (blockLdum.thereIsUpper())
|
// is not allocated. Allocating extended upper only.
|
||||||
|
extendedUpperPtr_ = new TypeCoeffField
|
||||||
|
(
|
||||||
|
extLduAddr_.extendedUpperAddr().size()
|
||||||
|
);
|
||||||
|
TypeCoeffField& extUpper = *extendedUpperPtr_;
|
||||||
|
|
||||||
|
// Get upper coeffs from underlying lduMatrix
|
||||||
|
const TypeCoeffField& upper = blockLdum.upper();
|
||||||
|
|
||||||
|
if (upper.activeType() == blockCoeffBase::SCALAR)
|
||||||
{
|
{
|
||||||
// Allocate extended upper only
|
// Helper type definition
|
||||||
extendedUpperPtr_ = new TypeCoeffField
|
typedef typename CoeffField<Type>::scalarTypeField activeType;
|
||||||
(
|
|
||||||
extLduAddr_.extendedUpperAddr().size()
|
|
||||||
);
|
|
||||||
TypeCoeffField& extUpper = *extendedUpperPtr_;
|
|
||||||
|
|
||||||
// Get upper coeffs from underlying lduMatrix
|
// Get references to fields
|
||||||
const TypeCoeffField& upper = blockLdum.upper();
|
const activeType& activeUpper = upper.asScalar();
|
||||||
|
activeType& activeExtUpper = extUpper.asScalar();
|
||||||
|
|
||||||
if (upper.activeType() == blockCoeffBase::SCALAR)
|
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
||||||
|
// positions
|
||||||
|
forAll (upper, faceI)
|
||||||
{
|
{
|
||||||
// Helper type definition
|
activeExtUpper[faceMap[faceI]] = activeUpper[faceI];
|
||||||
typedef typename CoeffField<Type>::scalarTypeField activeType;
|
|
||||||
|
|
||||||
// Get references to fields
|
|
||||||
const activeType& activeUpper = upper.asScalar();
|
|
||||||
activeType& activeExtUpper = extUpper.asScalar();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (upper, faceI)
|
|
||||||
{
|
|
||||||
activeExtUpper[faceMap[faceI]] = activeUpper[faceI];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (upper.activeType() == blockCoeffBase::LINEAR)
|
}
|
||||||
|
else if (upper.activeType() == blockCoeffBase::LINEAR)
|
||||||
|
{
|
||||||
|
// Helper type definition
|
||||||
|
typedef typename CoeffField<Type>::linearTypeField activeType;
|
||||||
|
|
||||||
|
// Get references to fields
|
||||||
|
const activeType& activeUpper = upper.asLinear();
|
||||||
|
activeType& activeExtUpper = extUpper.asLinear();
|
||||||
|
|
||||||
|
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
||||||
|
// positions
|
||||||
|
forAll (upper, faceI)
|
||||||
{
|
{
|
||||||
// Helper type definition
|
activeExtUpper[faceMap[faceI]] = activeUpper[faceI];
|
||||||
typedef typename CoeffField<Type>::linearTypeField activeType;
|
|
||||||
|
|
||||||
// Get references to fields
|
|
||||||
const activeType& activeUpper = upper.asLinear();
|
|
||||||
activeType& activeExtUpper = extUpper.asLinear();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (upper, faceI)
|
|
||||||
{
|
|
||||||
activeExtUpper[faceMap[faceI]] = activeUpper[faceI];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (upper.activeType() == blockCoeffBase::SQUARE)
|
}
|
||||||
{
|
else if (upper.activeType() == blockCoeffBase::SQUARE)
|
||||||
// Helper type definition
|
{
|
||||||
typedef typename CoeffField<Type>::squareTypeField activeType;
|
// Helper type definition
|
||||||
|
typedef typename CoeffField<Type>::squareTypeField activeType;
|
||||||
|
|
||||||
// Get references to fields
|
// Get references to fields
|
||||||
const activeType& activeUpper = upper.asSquare();
|
const activeType& activeUpper = upper.asSquare();
|
||||||
activeType& activeExtUpper = extUpper.asSquare();
|
activeType& activeExtUpper = extUpper.asSquare();
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
||||||
// positions
|
// positions
|
||||||
forAll (upper, faceI)
|
forAll (upper, faceI)
|
||||||
{
|
|
||||||
activeExtUpper[faceMap[faceI]] = activeUpper[faceI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
activeExtUpper[faceMap[faceI]] = activeUpper[faceI];
|
||||||
(
|
|
||||||
"extendedBlockLduMatrix(lduMatrix&, label, polyMesh&)"
|
|
||||||
) << "Problem between ordinary block matrix and extended"
|
|
||||||
<< " block matrix upper coeffs type morphing."
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Allocate extended lower only
|
FatalErrorIn
|
||||||
extendedLowerPtr_ = new TypeCoeffField
|
|
||||||
(
|
(
|
||||||
extLduAddr_.extendedLowerAddr().size()
|
"extendedBlockLduMatrix(lduMatrix&, label, polyMesh&)"
|
||||||
);
|
) << "Problem between ordinary block matrix and extended"
|
||||||
TypeCoeffField& extLower = *extendedLowerPtr_;
|
<< " block matrix upper coeffs type morphing."
|
||||||
|
<< abort(FatalError);
|
||||||
// Get lower coeffs from underlying lduMatrix
|
|
||||||
const TypeCoeffField& lower = blockLdum.lower();
|
|
||||||
|
|
||||||
if (lower.activeType() == blockCoeffBase::SCALAR)
|
|
||||||
{
|
|
||||||
// Helper type definition
|
|
||||||
typedef typename CoeffField<Type>::scalarTypeField activeType;
|
|
||||||
|
|
||||||
// Get references to fields
|
|
||||||
const activeType& activeLower = lower.asScalar();
|
|
||||||
activeType& activeExtLower = extLower.asScalar();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (lower, faceI)
|
|
||||||
{
|
|
||||||
activeExtLower[faceMap[faceI]] = activeLower[faceI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (lower.activeType() == blockCoeffBase::LINEAR)
|
|
||||||
{
|
|
||||||
// Helper type definition
|
|
||||||
typedef typename CoeffField<Type>::linearTypeField activeType;
|
|
||||||
|
|
||||||
// Get references to fields
|
|
||||||
const activeType& activeLower = lower.asLinear();
|
|
||||||
activeType& activeExtLower = extLower.asLinear();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (lower, faceI)
|
|
||||||
{
|
|
||||||
activeExtLower[faceMap[faceI]] = activeLower[faceI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (lower.activeType() == blockCoeffBase::SQUARE)
|
|
||||||
{
|
|
||||||
// Helper type definition
|
|
||||||
typedef typename CoeffField<Type>::squareTypeField activeType;
|
|
||||||
|
|
||||||
// Get references to fields
|
|
||||||
const activeType& activeLower = lower.asSquare();
|
|
||||||
activeType& activeExtLower = extLower.asSquare();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (lower, faceI)
|
|
||||||
{
|
|
||||||
activeExtLower[faceMap[faceI]] = activeLower[faceI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"extendedBlockLduMatrix(lduMatrix&, label, polyMesh&)"
|
|
||||||
) << "Problem between ordinary block matrix and extended"
|
|
||||||
<< " block matrix lower coeffs type morphing."
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -74,46 +74,23 @@ Foam::extendedLduMatrix::extendedLduMatrix
|
||||||
// Get reference to faceMap in extended addressing
|
// Get reference to faceMap in extended addressing
|
||||||
const unallocLabelList& faceMap = extLduAddr_.faceMap();
|
const unallocLabelList& faceMap = extLduAddr_.faceMap();
|
||||||
|
|
||||||
// Avoid assuming it's upper if the matrix is symmetric
|
// Matrix is considered symmetric if the upper is allocated and lower
|
||||||
if (ldum.hasUpper())
|
// is not allocated. Allocating extended upper only.
|
||||||
|
extendedUpperPtr_ = new scalarField
|
||||||
|
(
|
||||||
|
extLduAddr_.extendedUpperAddr().size(),
|
||||||
|
0.0
|
||||||
|
);
|
||||||
|
scalarField& extUpper = *extendedUpperPtr_;
|
||||||
|
|
||||||
|
// Get upper coeffs from underlying lduMatrix
|
||||||
|
const scalarField& upper = ldum.upper();
|
||||||
|
|
||||||
|
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
||||||
|
// positions
|
||||||
|
forAll (upper, faceI)
|
||||||
{
|
{
|
||||||
// Allocate extended upper only
|
extUpper[faceMap[faceI]] = upper[faceI];
|
||||||
extendedUpperPtr_ = new scalarField
|
|
||||||
(
|
|
||||||
extLduAddr_.extendedUpperAddr().size(),
|
|
||||||
0.0
|
|
||||||
);
|
|
||||||
scalarField& extUpper = *extendedUpperPtr_;
|
|
||||||
|
|
||||||
// Get upper coeffs from underlying lduMatrix
|
|
||||||
const scalarField& upper = ldum.upper();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (upper, faceI)
|
|
||||||
{
|
|
||||||
extUpper[faceMap[faceI]] = upper[faceI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Allocate extended lower only
|
|
||||||
extendedLowerPtr_ = new scalarField
|
|
||||||
(
|
|
||||||
extLduAddr_.extendedLowerAddr().size(),
|
|
||||||
0.0
|
|
||||||
);
|
|
||||||
scalarField& extLower = *extendedLowerPtr_;
|
|
||||||
|
|
||||||
// Get lower coeffs from underlying lduMatrix
|
|
||||||
const scalarField& lower = ldum.lower();
|
|
||||||
|
|
||||||
// Copy non-zero coeffs from basic lduMatrix into corresponding
|
|
||||||
// positions
|
|
||||||
forAll (lower, faceI)
|
|
||||||
{
|
|
||||||
extLower[faceMap[faceI]] = lower[faceI];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -49,8 +49,9 @@ namespace Foam
|
||||||
addasymMatrixConstructorToTable<ILUCp>
|
addasymMatrixConstructorToTable<ILUCp>
|
||||||
addILUCpPreconditionerAsymMatrixConstructorToTable_;
|
addILUCpPreconditionerAsymMatrixConstructorToTable_;
|
||||||
|
|
||||||
// Add to symmetric constructor table as well until we implement Choleskyp
|
// Add to symmetric constructor table as well. Cholesky with fill in would
|
||||||
// preconditioner. VV, 27/Jun/2015.
|
// yield the same sparseness pattern as the original matrix, hence it is not
|
||||||
|
// implemented. VV, 10/Sep/2015.
|
||||||
lduPreconditioner::
|
lduPreconditioner::
|
||||||
addsymMatrixConstructorToTable<ILUCp>
|
addsymMatrixConstructorToTable<ILUCp>
|
||||||
addILUCpPreconditionerSymMatrixConstructorToTable_;
|
addILUCpPreconditionerSymMatrixConstructorToTable_;
|
||||||
|
|
Reference in a new issue