AMG policy interface updates

This commit is contained in:
Hrvoje Jasak 2017-05-22 14:47:17 +01:00
parent 4313020814
commit c1d4310795
8 changed files with 210 additions and 144 deletions

View file

@ -53,8 +53,11 @@ Foam::autoPtr<Foam::amgPolicy> Foam::amgPolicy::New
(
const word& policyType,
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label nCoarseCells
const label minCoarseEqns
)
{
matrixConstructorTable::iterator constructorIter =
@ -68,8 +71,11 @@ Foam::autoPtr<Foam::amgPolicy> Foam::amgPolicy::New
"(\n"
" const word& policyType,\n"
" const lduMatrix& matrix,\n"
" const FieldField<Field, scalar>& bouCoeffs,\n"
" const FieldField<Field, scalar>& intCoeffs,\n"
" const lduInterfaceFieldPtrsList& interfaceFields,\n"
" const label groupSize\n"
" const label nCoarseCells\n"
" const label minCoarseEqns\n"
")"
) << "Unknown AMG policy " << policyType
<< endl << endl
@ -83,8 +89,11 @@ Foam::autoPtr<Foam::amgPolicy> Foam::amgPolicy::New
constructorIter()
(
matrix,
bouCoeffs,
intCoeffs,
interfaceFields,
groupSize,
nCoarseCells
minCoarseEqns
)
);
}

View file

@ -59,6 +59,18 @@ class amgPolicy
{
// Private Data
//- Matrix
const lduMatrix& matrix_;
//- Boundary coeffs
const FieldField<Field, scalar>& bouCoeffs_;
//- Internal coeffs
const FieldField<Field, scalar>& intCoeffs_;
//- Interface fields
const lduInterfaceFieldPtrsList& interfaceFields_;
//- Group size
label groupSize_;
@ -90,10 +102,20 @@ public:
matrix,
(
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
),
(matrix, groupSize, minCoarseEqns)
(
matrix,
bouCoeffs,
intCoeffs,
interfaceFields,
groupSize,
minCoarseEqns
)
);
@ -104,6 +126,9 @@ public:
(
const word& policyType,
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
);
@ -114,10 +139,18 @@ public:
//- Construct from components
amgPolicy
(
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
)
:
matrix_(matrix),
bouCoeffs_(bouCoeffs),
intCoeffs_(intCoeffs),
interfaceFields_(interfaceFields),
groupSize_(groupSize),
minCoarseEqns_(minCoarseEqns)
{}
@ -130,6 +163,33 @@ public:
// Member Functions
// Matrix access
//- Return reference to matrix
const lduMatrix& matrix() const
{
return matrix_;
}
//- Return reference to boundary coeffs
const FieldField<Field, scalar>& bouCoeffs() const
{
return bouCoeffs_;
}
//- Return reference to internal coeffs
const FieldField<Field, scalar>& intCoeffs() const
{
return intCoeffs_;
}
//- Return reference to interface fields
const lduInterfaceFieldPtrsList& interfaceFields() const
{
return interfaceFields_;
}
//- Return group size
label groupSize() const
{
@ -146,12 +206,7 @@ public:
virtual bool coarsen() const = 0;
//- Restrict matrix
virtual autoPtr<amgMatrix> restrictMatrix
(
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaces
) const = 0;
virtual autoPtr<amgMatrix> restrictMatrix() const = 0;
//- Restrict residual
virtual void restrictResidual

View file

@ -67,7 +67,7 @@ const Foam::debug::tolerancesSwitch Foam::clusterAmgPolicy::diagFactor_
void Foam::clusterAmgPolicy::calcChild()
{
if (matrix_.diagonal())
if (matrix().diagonal())
{
// Diag only matrix. Reset and return
child_ = 0;
@ -88,25 +88,25 @@ void Foam::clusterAmgPolicy::calcChild()
// Initialise child array
child_ = -1;
const label nRows = matrix_.lduAddr().size();
const label nRows = matrix().lduAddr().size();
// Get matrix addressing
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
const unallocLabelList& losortAddr = matrix_.lduAddr().losortAddr();
const unallocLabelList& lowerAddr = matrix().lduAddr().lowerAddr();
const unallocLabelList& upperAddr = matrix().lduAddr().upperAddr();
const unallocLabelList& losortAddr = matrix().lduAddr().losortAddr();
const unallocLabelList& ownerStartAddr =
matrix_.lduAddr().ownerStartAddr();
matrix().lduAddr().ownerStartAddr();
const unallocLabelList& losortStartAddr =
matrix_.lduAddr().losortStartAddr();
matrix().lduAddr().losortStartAddr();
// Calculate agglomeration
// Get magnitudes of matrix coefficients
const scalarField& diag = matrix_.diag();
const scalarField magDiag = mag(matrix_.diag());
const scalarField& diag = matrix().diag();
const scalarField magDiag = mag(matrix().diag());
// Calculate magnitude of strong positive connections
scalarField magUpper(upperAddr.size(), 0);
@ -120,9 +120,9 @@ void Foam::clusterAmgPolicy::calcChild()
// Note: negative connections are eliminated in max(...) below
// HJ, 30/Mar/2017
if (matrix_.hasUpper())
if (matrix().hasUpper())
{
const scalarField& upper = matrix_.upper();
const scalarField& upper = matrix().upper();
// Owner: upper triangle
forAll (lowerAddr, coeffI)
@ -134,9 +134,9 @@ void Foam::clusterAmgPolicy::calcChild()
}
}
if (matrix_.hasLower())
if (matrix().hasLower())
{
const scalarField& lower = matrix_.lower();
const scalarField& lower = matrix().lower();
// Neighbour: lower triangle
forAll (lowerAddr, coeffI)
@ -169,7 +169,7 @@ void Foam::clusterAmgPolicy::calcChild()
boolList zeroCluster(magDiag.size(), true);
if (matrix_.symmetric())
if (matrix().symmetric())
{
// Owner: upper triangle
forAll (lowerAddr, coeffI)
@ -189,7 +189,7 @@ void Foam::clusterAmgPolicy::calcChild()
}
}
}
else if (matrix_.asymmetric())
else if (matrix().asymmetric())
{
// Owner: upper triangle
forAll (lowerAddr, coeffI)
@ -495,15 +495,25 @@ void Foam::clusterAmgPolicy::calcChild()
Foam::clusterAmgPolicy::clusterAmgPolicy
(
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
)
:
amgPolicy(groupSize, minCoarseEqns),
matrix_(matrix),
amgPolicy
(
matrix,
bouCoeffs,
intCoeffs,
interfaceFields,
groupSize,
minCoarseEqns
),
minGroupSize_(groupSize),
maxGroupSize_(2*groupSize),
child_(matrix_.lduAddr().size()),
child_(matrix.lduAddr().size()),
nSolo_(0),
nCoarseEqns_(0),
coarsen_(false)
@ -534,12 +544,7 @@ Foam::clusterAmgPolicy::~clusterAmgPolicy()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
(
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields
) const
Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix() const
{
if (!coarsen_)
{
@ -564,20 +569,20 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
// 4) Agglomerate the diagonal by summing up the fine diagonal
// Get addressing
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
const unallocLabelList& upperAddr = matrix().lduAddr().upperAddr();
const unallocLabelList& lowerAddr = matrix().lduAddr().lowerAddr();
const label nFineCoeffs = upperAddr.size();
# ifdef FULLDEBUG
if (child_.size() != matrix_.lduAddr().size())
if (child_.size() != matrix().lduAddr().size())
{
FatalErrorIn
(
"autoPtr<amgMatrix> clusterAmgPolicy::restrictMatrix() const"
) << "Child array does not correspond to fine level. " << endl
<< " Child size: " << child_.size()
<< " number of equations: " << matrix_.lduAddr().size()
<< " number of equations: " << matrix().lduAddr().size()
<< abort(FatalError);
}
# endif
@ -752,24 +757,24 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
// Set the coarse interfaces and coefficients
lduInterfacePtrsList* coarseInterfacesPtr =
new lduInterfacePtrsList(interfaceFields.size());
new lduInterfacePtrsList(interfaceFields().size());
lduInterfacePtrsList& coarseInterfaces = *coarseInterfacesPtr;
// Set the coarse interfaceFields and coefficients
lduInterfaceFieldPtrsList* coarseInterfaceFieldsPtr =
new lduInterfaceFieldPtrsList(interfaceFields.size());
new lduInterfaceFieldPtrsList(interfaceFields().size());
lduInterfaceFieldPtrsList& coarseInterfaceFields =
*coarseInterfaceFieldsPtr;
FieldField<Field, scalar>* coarseBouCoeffsPtr =
new FieldField<Field, scalar>(interfaceFields.size());
new FieldField<Field, scalar>(interfaceFields().size());
FieldField<Field, scalar>& coarseBouCoeffs = *coarseBouCoeffsPtr;
FieldField<Field, scalar>* coarseIntCoeffsPtr =
new FieldField<Field, scalar>(interfaceFields.size());
new FieldField<Field, scalar>(interfaceFields().size());
FieldField<Field, scalar>& coarseIntCoeffs = *coarseIntCoeffsPtr;
labelListList coarseInterfaceAddr(interfaceFields.size());
labelListList coarseInterfaceAddr(interfaceFields().size());
// Add the coarse level
@ -784,11 +789,11 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
);
// Initialise transfer of restrict addressing on the interface
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
interfaceFields[intI].coupledInterface().initInternalFieldTransfer
interfaceFields()[intI].coupledInterface().initInternalFieldTransfer
(
Pstream::blocking,
child_
@ -798,14 +803,14 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
// Store neighbour child arrays to avoid tangled communications
// HJ, 1/Apr/2009
FieldField<Field, label> fineInterfaceAddr(interfaceFields.size());
FieldField<Field, label> fineInterfaceAddr(interfaceFields().size());
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
const lduInterface& fineInterface =
interfaceFields[intI].coupledInterface();
interfaceFields()[intI].coupledInterface();
fineInterfaceAddr.set
(
@ -823,12 +828,12 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
}
// Create AMG interfaces
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
const lduInterface& fineInterface =
interfaceFields[intI].coupledInterface();
interfaceFields()[intI].coupledInterface();
coarseInterfaces.set
(
@ -845,9 +850,9 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
}
}
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
const AMGInterface& coarseInterface =
refCast<const AMGInterface>(coarseInterfaces[intI]);
@ -858,7 +863,7 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
AMGInterfaceField::New
(
coarseInterface,
interfaceFields[intI]
interfaceFields()[intI]
).ptr()
);
@ -869,13 +874,13 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
coarseBouCoeffs.set
(
intI,
coarseInterface.agglomerateCoeffs(bouCoeffs[intI])
coarseInterface.agglomerateCoeffs(bouCoeffs()[intI])
);
coarseIntCoeffs.set
(
intI,
coarseInterface.agglomerateCoeffs(intCoeffs[intI])
coarseInterface.agglomerateCoeffs(intCoeffs()[intI])
);
coarseInterfaceAddr[intI] = coarseInterface.faceCells();
@ -887,7 +892,7 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
(
*coarseInterfacesPtr,
coarseInterfaceAddr,
matrix_.patchSchedule()
matrix().patchSchedule()
);
// Matrix restriction done!
@ -899,15 +904,15 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
// Coarse matrix diagonal initialised by restricting the
// finer mesh diagonal
scalarField& coarseDiag = coarseMatrix.diag();
restrictResidual(matrix_.diag(), coarseDiag);
restrictResidual(matrix().diag(), coarseDiag);
// Check if matrix is assymetric and if so agglomerate both upper and lower
// coefficients ...
if (matrix_.hasLower())
if (matrix().hasLower())
{
// Get off-diagonal matrix coefficients
const scalarField& fineUpper = matrix_.upper();
const scalarField& fineLower = matrix_.lower();
const scalarField& fineUpper = matrix().upper();
const scalarField& fineLower = matrix().lower();
// Coarse matrix upper coefficients
scalarField& coarseUpper = coarseMatrix.upper();
@ -943,7 +948,7 @@ Foam::autoPtr<Foam::amgMatrix> Foam::clusterAmgPolicy::restrictMatrix
else // ... Otherwise it is symmetric so agglomerate just the upper
{
// Get off-diagonal matrix coefficients
const scalarField& fineUpper = matrix_.upper();
const scalarField& fineUpper = matrix().upper();
// Coarse matrix upper coefficients
scalarField& coarseUpper = coarseMatrix.upper();

View file

@ -57,9 +57,6 @@ class clusterAmgPolicy
{
// Private Data
//- Reference to matrix
const lduMatrix& matrix_;
//- Min cluster size
const label minGroupSize_;
@ -112,6 +109,9 @@ public:
clusterAmgPolicy
(
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
);
@ -130,12 +130,7 @@ public:
}
//- Restrict matrix
virtual autoPtr<amgMatrix> restrictMatrix
(
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaces
) const;
virtual autoPtr<amgMatrix> restrictMatrix() const;
//- Restrict residual
virtual void restrictResidual

View file

@ -61,7 +61,7 @@ Foam::pamgPolicy::diagFactor_
void Foam::pamgPolicy::calcChild()
{
if (matrix_.diagonal())
if (matrix().diagonal())
{
// Diag only matrix. Reset and return
child_ = 0;
@ -77,13 +77,13 @@ void Foam::pamgPolicy::calcChild()
// neighbour. If all neighbours are grouped, add equation to best group
// Get addressing
const label nEqns = matrix_.lduAddr().size();
const label nEqns = matrix().lduAddr().size();
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
const unallocLabelList& upperAddr = matrix().lduAddr().upperAddr();
const unallocLabelList& lowerAddr = matrix().lduAddr().lowerAddr();
// Get off-diagonal matrix coefficients
const scalarField& upper = matrix_.upper();
const scalarField& upper = matrix().upper();
// For each equation calculate coeffs
labelList cols(upperAddr.size() + lowerAddr.size());
@ -140,17 +140,17 @@ void Foam::pamgPolicy::calcChild()
// Calculate agglomeration
// Get matrix coefficients
const scalarField& diag = matrix_.diag();
const scalarField& diag = matrix().diag();
scalarField magOffDiag;
if (matrix_.asymmetric())
if (matrix().asymmetric())
{
magOffDiag = Foam::max(mag(matrix_.upper()), mag(matrix_.lower()));
magOffDiag = Foam::max(mag(matrix().upper()), mag(matrix().lower()));
}
else if (matrix_.symmetric())
else if (matrix().symmetric())
{
magOffDiag = mag(matrix_.upper());
magOffDiag = mag(matrix().upper());
}
else
{
@ -333,13 +333,23 @@ void Foam::pamgPolicy::calcChild()
Foam::pamgPolicy::pamgPolicy
(
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
)
:
amgPolicy(groupSize, minCoarseEqns),
matrix_(matrix),
child_(),
amgPolicy
(
matrix,
bouCoeffs,
intCoeffs,
interfaceFields,
groupSize,
minCoarseEqns
),
child_(matrix.lduAddr().size()),
nSolo_(0),
nCoarseEqns_(0),
coarsen_(false)
@ -355,12 +365,7 @@ Foam::pamgPolicy::~pamgPolicy()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
(
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields
) const
Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix() const
{
if (!coarsen_)
{
@ -383,20 +388,20 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
// 4) Agglomerate the diagonal by summing up the fine diagonal
// Get addressing
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
const unallocLabelList& upperAddr = matrix().lduAddr().upperAddr();
const unallocLabelList& lowerAddr = matrix().lduAddr().lowerAddr();
label nFineCoeffs = upperAddr.size();
# ifdef FULLDEBUG
if (child_.size() != matrix_.lduAddr().size())
if (child_.size() != matrix().lduAddr().size())
{
FatalErrorIn
(
"autoPtr<amgMatrix> pamgPolicy::restrictMatrix() const"
) << "Child array does not correspond to fine level. " << endl
<< " Child size: " << child_.size()
<< " number of equations: " << matrix_.lduAddr().size()
<< " number of equations: " << matrix().lduAddr().size()
<< abort(FatalError);
}
# endif
@ -570,24 +575,24 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
// Set the coarse interfaces and coefficients
lduInterfacePtrsList* coarseInterfacesPtr =
new lduInterfacePtrsList(interfaceFields.size());
new lduInterfacePtrsList(interfaceFields().size());
lduInterfacePtrsList& coarseInterfaces = *coarseInterfacesPtr;
// Set the coarse interfaceFields and coefficients
lduInterfaceFieldPtrsList* coarseInterfaceFieldsPtr =
new lduInterfaceFieldPtrsList(interfaceFields.size());
new lduInterfaceFieldPtrsList(interfaceFields().size());
lduInterfaceFieldPtrsList& coarseInterfaceFields =
*coarseInterfaceFieldsPtr;
FieldField<Field, scalar>* coarseBouCoeffsPtr =
new FieldField<Field, scalar>(interfaceFields.size());
new FieldField<Field, scalar>(interfaceFields().size());
FieldField<Field, scalar>& coarseBouCoeffs = *coarseBouCoeffsPtr;
FieldField<Field, scalar>* coarseIntCoeffsPtr =
new FieldField<Field, scalar>(interfaceFields.size());
new FieldField<Field, scalar>(interfaceFields().size());
FieldField<Field, scalar>& coarseIntCoeffs = *coarseIntCoeffsPtr;
labelListList coarseInterfaceAddr(interfaceFields.size());
labelListList coarseInterfaceAddr(interfaceFields().size());
// Add the coarse level
@ -602,11 +607,11 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
);
// Initialise transfer of restrict addressing on the interface
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
interfaceFields[intI].coupledInterface().initInternalFieldTransfer
interfaceFields()[intI].coupledInterface().initInternalFieldTransfer
(
Pstream::blocking,
child_
@ -616,14 +621,14 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
// Store coefficients to avoid tangled communications
// HJ, 1/Apr/2009
FieldField<Field, label> fineInterfaceAddr(interfaceFields.size());
FieldField<Field, label> fineInterfaceAddr(interfaceFields().size());
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
const lduInterface& fineInterface =
interfaceFields[intI].coupledInterface();
interfaceFields()[intI].coupledInterface();
fineInterfaceAddr.set
(
@ -641,12 +646,12 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
}
// Create AMG interfaces
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
const lduInterface& fineInterface =
interfaceFields[intI].coupledInterface();
interfaceFields()[intI].coupledInterface();
coarseInterfaces.set
(
@ -663,9 +668,9 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
}
}
forAll (interfaceFields, intI)
forAll (interfaceFields(), intI)
{
if (interfaceFields.set(intI))
if (interfaceFields().set(intI))
{
const AMGInterface& coarseInterface =
refCast<const AMGInterface>(coarseInterfaces[intI]);
@ -676,7 +681,7 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
AMGInterfaceField::New
(
coarseInterface,
interfaceFields[intI]
interfaceFields()[intI]
).ptr()
);
@ -687,13 +692,13 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
coarseBouCoeffs.set
(
intI,
coarseInterface.agglomerateCoeffs(bouCoeffs[intI])
coarseInterface.agglomerateCoeffs(bouCoeffs()[intI])
);
coarseIntCoeffs.set
(
intI,
coarseInterface.agglomerateCoeffs(intCoeffs[intI])
coarseInterface.agglomerateCoeffs(intCoeffs()[intI])
);
coarseInterfaceAddr[intI] = coarseInterface.faceCells();
@ -705,7 +710,7 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
(
*coarseInterfacesPtr,
coarseInterfaceAddr,
matrix_.patchSchedule()
matrix().patchSchedule()
);
// Matrix restriction done!
@ -717,15 +722,15 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
// Coarse matrix diagonal initialised by restricting the
// finer mesh diagonal
scalarField& coarseDiag = coarseMatrix.diag();
restrictResidual(matrix_.diag(), coarseDiag);
restrictResidual(matrix().diag(), coarseDiag);
// Check if matrix is assymetric and if so agglomerate both upper and lower
// coefficients ...
if (matrix_.hasLower())
if (matrix().hasLower())
{
// Get off-diagonal matrix coefficients
const scalarField& fineUpper = matrix_.upper();
const scalarField& fineLower = matrix_.lower();
const scalarField& fineUpper = matrix().upper();
const scalarField& fineLower = matrix().lower();
// Coarse matrix upper coefficients
scalarField& coarseUpper = coarseMatrix.upper();
@ -761,7 +766,7 @@ Foam::autoPtr<Foam::amgMatrix> Foam::pamgPolicy::restrictMatrix
else // ... Otherwise it is symmetric so agglomerate just the upper
{
// Get off-diagonal matrix coefficients
const scalarField& fineUpper = matrix_.upper();
const scalarField& fineUpper = matrix().upper();
// Coarse matrix upper coefficients
scalarField& coarseUpper = coarseMatrix.upper();

View file

@ -57,9 +57,6 @@ class pamgPolicy
{
// Private Data
//- Reference to matrix
const lduMatrix& matrix_;
//- Child array: for each fine equation give coarse cluster index
labelField child_;
@ -103,6 +100,9 @@ public:
pamgPolicy
(
const lduMatrix& matrix,
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaceFields,
const label groupSize,
const label minCoarseEqns
);
@ -121,12 +121,7 @@ public:
}
//- Restrict matrix
virtual autoPtr<amgMatrix> restrictMatrix
(
const FieldField<Field, scalar>& bouCoeffs,
const FieldField<Field, scalar>& intCoeffs,
const lduInterfaceFieldPtrsList& interfaces
) const;
virtual autoPtr<amgMatrix> restrictMatrix() const;
//- Restrict residual
virtual void restrictResidual

View file

@ -60,6 +60,9 @@ Foam::coarseAmgLevel::coarseAmgLevel
(
policyType,
matrixPtr_->matrix(),
matrixPtr_->coupleBouCoeffs(),
matrixPtr_->coupleIntCoeffs(),
matrixPtr_->interfaceFields(),
groupSize,
minCoarseEqns
)
@ -338,12 +341,7 @@ Foam::autoPtr<Foam::amgLevel> Foam::coarseAmgLevel::makeNextLevel() const
(
new coarseAmgLevel
(
policyPtr_->restrictMatrix
(
matrixPtr_->coupleBouCoeffs(),
matrixPtr_->coupleIntCoeffs(),
matrixPtr_->interfaceFields()
),
policyPtr_->restrictMatrix(),
dict(),
policyPtr_->type(),
policyPtr_->groupSize(),

View file

@ -60,7 +60,16 @@ Foam::fineAmgLevel::fineAmgLevel
dict_(dict),
policyPtr_
(
amgPolicy::New(policyType, matrix_, groupSize, minCoarseEqns)
amgPolicy::New
(
policyType,
matrix_,
coupleBouCoeffs_,
coupleIntCoeffs_,
interfaceFields_,
groupSize,
minCoarseEqns
)
),
smootherPtr_
(
@ -298,12 +307,7 @@ Foam::autoPtr<Foam::amgLevel> Foam::fineAmgLevel::makeNextLevel() const
(
new coarseAmgLevel
(
policyPtr_->restrictMatrix
(
coupleBouCoeffs_,
coupleIntCoeffs_,
interfaceFields_
),
policyPtr_->restrictMatrix(),
dict(),
policyPtr_->type(),
policyPtr_->groupSize(),