Merge branch 'cachedBlockAmg' into development
This commit is contained in:
commit
0b00958d18
55 changed files with 450 additions and 3953 deletions
|
@ -718,9 +718,7 @@ $(BlockSAMGInterfaceFields)/GGIBlockSAMGInterfaceField/GGIBlockSAMGInterfaceFiel
|
|||
|
||||
BlockMatrixCoarsening = $(BlockAMG)/BlockMatrixCoarsening
|
||||
$(BlockMatrixCoarsening)/BlockMatrixCoarsening/blockMatrixCoarsenings.C
|
||||
$(BlockMatrixCoarsening)/BlockMatrixAgglomeration/blockMatrixAgglomerations.C
|
||||
$(BlockMatrixCoarsening)/BlockMatrixClustering/blockMatrixClusterings.C
|
||||
$(BlockMatrixCoarsening)/BlockMatrixReorderedClustering/blockMatrixReorderedClusterings.C
|
||||
$(BlockMatrixCoarsening)/BlockMatrixSelection/blockMatrixSelections.C
|
||||
|
||||
BlockLduPrecons = matrices/blockLduMatrix/BlockLduPrecons
|
||||
|
|
|
@ -107,6 +107,22 @@ void Foam::BlockAMGCycle<Type>::makeCoarseLevels(const label nMaxLevels)
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::BlockLduMatrix<Type>& Foam::BlockAMGCycle<Type>::coarseMatrix()
|
||||
{
|
||||
if (!coarseLevelPtr_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"BlockLduMatrix<Type>& BlockAMGCycle<Type>::coarseMatrix()"
|
||||
) << "Coarse level not available"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return coarseLevelPtr_->matrix();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockAMGCycle<Type>::fixedCycle
|
||||
(
|
||||
|
@ -193,7 +209,21 @@ void Foam::BlockAMGCycle<Type>::fixedCycle
|
|||
else
|
||||
{
|
||||
// Call direct solver
|
||||
levelPtr_->solve(x, b, 1e-9, 0);
|
||||
levelPtr_->solve(x, b, 1e-7, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockAMGCycle<Type>::initMatrix()
|
||||
{
|
||||
// If present, update coarse levels recursively
|
||||
if (coarseLevelPtr_)
|
||||
{
|
||||
// Update current level
|
||||
levelPtr_->initLevel(coarseLevelPtr_->levelPtr_);
|
||||
|
||||
coarseLevelPtr_->initMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,6 +143,9 @@ public:
|
|||
return nLevels_;
|
||||
}
|
||||
|
||||
//- Return coarse matrix
|
||||
BlockLduMatrix<Type>& coarseMatrix();
|
||||
|
||||
//- Calculate residual
|
||||
void residual
|
||||
(
|
||||
|
@ -166,6 +169,9 @@ public:
|
|||
const label nPostSweeps,
|
||||
const bool scale
|
||||
) const;
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
void initMatrix();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -86,6 +86,9 @@ public:
|
|||
|
||||
// Member Functions
|
||||
|
||||
//- Return reference to matrix
|
||||
virtual BlockLduMatrix<Type>& matrix() = 0;
|
||||
|
||||
//- Return reference to x
|
||||
virtual Field<Type>& x() = 0;
|
||||
|
||||
|
@ -144,6 +147,12 @@ public:
|
|||
|
||||
//- Create next level from current level
|
||||
virtual autoPtr<BlockAMGLevel> makeNextLevel() const = 0;
|
||||
|
||||
//- Re-initialise AMG level after matrix coefficient update
|
||||
virtual void initLevel
|
||||
(
|
||||
autoPtr<Foam::BlockAMGLevel<Type> >& coarseLevelPtr
|
||||
) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,212 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixAgglomeration
|
||||
|
||||
Description
|
||||
Agglomerative block matrix AMG coarsening
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2013-04-15
|
||||
|
||||
SourceFiles
|
||||
BlockMatrixAgglomeration.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BlockMatrixAgglomeration_H
|
||||
#define BlockMatrixAgglomeration_H
|
||||
|
||||
#include "BlockMatrixCoarsening.H"
|
||||
#include "BlockLduMatrix.H"
|
||||
#include "BlockCoeffNorm.H"
|
||||
#include "BlockCoeff.H"
|
||||
#include "tolerancesSwitch.H"
|
||||
#include "cpuTime.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockMatrixAgglomeration Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class BlockMatrixAgglomeration
|
||||
:
|
||||
public BlockMatrixCoarsening<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to matrix
|
||||
const BlockLduMatrix<Type>& matrix_;
|
||||
|
||||
//- Norm calculator
|
||||
autoPtr<BlockCoeffNorm<Type> > normPtr_;
|
||||
|
||||
//- Child array: for each fine equation give agglomeration cluster
|
||||
// index
|
||||
labelField agglomIndex_;
|
||||
|
||||
//- Group size
|
||||
label groupSize_;
|
||||
|
||||
//- Number of solo cells
|
||||
label nSolo_;
|
||||
|
||||
//- Number of coarse equations
|
||||
label nCoarseEqns_;
|
||||
|
||||
//- Can a coarse level be constructed?
|
||||
bool coarsen_;
|
||||
|
||||
cpuTime lTime_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
BlockMatrixAgglomeration(const BlockMatrixAgglomeration<Type>&);
|
||||
|
||||
// Disallow default bitwise assignment
|
||||
void operator=(const BlockMatrixAgglomeration<Type>&);
|
||||
|
||||
|
||||
//- Calculate agglomeration index (child)
|
||||
void calcAgglomeration();
|
||||
|
||||
//- Restrict CoeffField. Used for diag coefficient
|
||||
void restrictDiag
|
||||
(
|
||||
const CoeffField<Type>& Coeff,
|
||||
CoeffField<Type>& coarseCoeff
|
||||
) const;
|
||||
|
||||
//- Agglomerate coeffs, symmetric matrix
|
||||
template<class DiagType, class ULType>
|
||||
void agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
const Field<ULType>& activeFineUpperTranspose
|
||||
) const;
|
||||
|
||||
//- Agglomerate coeffs, assymmetric matrix
|
||||
template<class DiagType, class ULType>
|
||||
void agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
Field<ULType>& activeCoarseLower,
|
||||
const Field<ULType>& activeFineLower
|
||||
) const;
|
||||
|
||||
//- Restrict CoeffField, decoupled version. Used for diag coefficient
|
||||
void restrictDiagDecoupled
|
||||
(
|
||||
const CoeffField<Type>& Coeff,
|
||||
CoeffField<Type>& coarseCoeff
|
||||
) const;
|
||||
|
||||
// Private Static Data
|
||||
|
||||
//- Weighting factor
|
||||
static const debug::tolerancesSwitch weightFactor_;
|
||||
|
||||
//- Diagonal scaling factor
|
||||
static const debug::tolerancesSwitch diagFactor_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("AAMG");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix and group size
|
||||
BlockMatrixAgglomeration
|
||||
(
|
||||
const BlockLduMatrix<Type>& matrix,
|
||||
const dictionary& dict,
|
||||
const label groupSize,
|
||||
const label minCoarseEqns
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~BlockMatrixAgglomeration();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Can a coarse level be constructed?
|
||||
virtual bool coarsen() const
|
||||
{
|
||||
return coarsen_;
|
||||
}
|
||||
|
||||
//- Restrict matrix
|
||||
virtual autoPtr<BlockAMGLevel<Type> > restrictMatrix() const;
|
||||
|
||||
//- Restrict residual
|
||||
virtual void restrictResidual
|
||||
(
|
||||
const Field<Type>& res,
|
||||
Field<Type>& coarseRes
|
||||
) const;
|
||||
|
||||
//- Prolongate correction
|
||||
virtual void prolongateCorrection
|
||||
(
|
||||
Field<Type>& x,
|
||||
const Field<Type>& coarseX
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "BlockMatrixAgglomeration.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,43 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "blockMatrixAgglomerations.H"
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "coarseBlockAMGLevel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeBlockMatrixCoarsenings(blockMatrixAgglomeration);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,65 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixAgglomeration
|
||||
|
||||
Description
|
||||
Typedefs for block matrix AMG coarsening.
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2012-12-15
|
||||
|
||||
SourceFiles
|
||||
blockMatrixAgglomeration.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef blockMatrixAgglomerations_H
|
||||
#define blockMatrixAgglomerations_H
|
||||
|
||||
#include "scalarBlockMatrixAgglomeration.H"
|
||||
#include "tensorBlockMatrixAgglomeration.H"
|
||||
#include "BlockMatrixAgglomeration.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef BlockMatrixAgglomeration<scalar> blockMatrixAgglomerationScalar;
|
||||
typedef BlockMatrixAgglomeration<vector> blockMatrixAgglomerationVector;
|
||||
typedef BlockMatrixAgglomeration<tensor> blockMatrixAgglomerationTensor;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,86 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixAgglomeration
|
||||
|
||||
Description
|
||||
Specialisation of the BlockMatrixAgglomeration for scalars.
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2013-01-31
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef scalarBlockMatrixAgglomeration_H
|
||||
#define scalarBlockMatrixAgglomeration_H
|
||||
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "blockMatrixAgglomerations.H"
|
||||
#include "BlockMatrixAgglomeration.H"
|
||||
#include "BlockMatrixCoarsening.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "scalarBlockLduMatrix.H"
|
||||
#include "scalarBlockConstraint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockMatrixAgglomeration Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Disable restrict matrix: no square type
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<scalar> >
|
||||
BlockMatrixAgglomeration<scalar>::restrictMatrix() const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<scalar> > "
|
||||
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
|
||||
) << "Function not implemented for Type=scalar. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<scalar> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,83 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixAgglomeration
|
||||
|
||||
Description
|
||||
Specialisation of the BlockMatrixAgglomeration for tensors.
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2013-01-31
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tensorBlockMatrixAgglomeration_H
|
||||
#define tensorBlockMatrixAgglomeration_H
|
||||
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "blockMatrixAgglomerations.H"
|
||||
#include "BlockMatrixAgglomeration.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockMatrixAgglomeration Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Disable restrict matrix: no square type
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<tensor> >
|
||||
BlockMatrixAgglomeration<tensor>::restrictMatrix
|
||||
() const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<tensor> > "
|
||||
"BlockMatrixAgglomeration<Type>::"
|
||||
"restrictMatrix() const"
|
||||
) << "Function not implemented for Type=tensor. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<tensor> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -555,10 +555,8 @@ void Foam::BlockMatrixClustering<Type>::restrictDiag
|
|||
squareTypeField& activeCoarseCoeff = coarseCoeff.asSquare();
|
||||
const squareTypeField& activeCoeff = Coeff.asSquare();
|
||||
|
||||
forAll (coarseCoeff, i)
|
||||
{
|
||||
activeCoarseCoeff[i] = pTraits<squareType>::zero;
|
||||
}
|
||||
// Reset coefficients to zero
|
||||
activeCoarseCoeff = pTraits<squareType>::zero;
|
||||
|
||||
forAll (Coeff, i)
|
||||
{
|
||||
|
@ -577,10 +575,8 @@ void Foam::BlockMatrixClustering<Type>::restrictDiag
|
|||
linearTypeField& activeCoarseCoeff = coarseCoeff.asLinear();
|
||||
const linearTypeField& activeCoeff = Coeff.asLinear();
|
||||
|
||||
forAll (coarseCoeff, i)
|
||||
{
|
||||
activeCoarseCoeff[i] = pTraits<linearType>::zero;
|
||||
}
|
||||
// Reset coefficients to zero
|
||||
activeCoarseCoeff = pTraits<linearType>::zero;
|
||||
|
||||
forAll (Coeff, i)
|
||||
{
|
||||
|
@ -599,10 +595,8 @@ void Foam::BlockMatrixClustering<Type>::restrictDiag
|
|||
scalarTypeField& activeCoarseCoeff = coarseCoeff.asScalar();
|
||||
const scalarTypeField& activeCoeff = Coeff.asScalar();
|
||||
|
||||
forAll (coarseCoeff, i)
|
||||
{
|
||||
activeCoarseCoeff[i] = pTraits<scalarType>::zero;
|
||||
}
|
||||
// Reset coefficients to zero
|
||||
activeCoarseCoeff = pTraits<scalarType>::zero;
|
||||
|
||||
forAll (Coeff, i)
|
||||
{
|
||||
|
@ -624,7 +618,6 @@ template<class Type>
|
|||
template<class DiagType, class ULType>
|
||||
void Foam::BlockMatrixClustering<Type>::agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
|
@ -638,7 +631,10 @@ void Foam::BlockMatrixClustering<Type>::agglomerateCoeffs
|
|||
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
|
||||
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
|
||||
|
||||
forAll(coeffRestrictAddr, fineCoeffI)
|
||||
// Reset coefficients to zero. Cannot touch the diagonal
|
||||
activeCoarseUpper = pTraits<ULType>::zero;
|
||||
|
||||
forAll(coeffRestrictAddr_, fineCoeffI)
|
||||
{
|
||||
label rmUpperAddr = agglomIndex_[upperAddr[fineCoeffI]];
|
||||
label rmLowerAddr = agglomIndex_[lowerAddr[fineCoeffI]];
|
||||
|
@ -650,7 +646,7 @@ void Foam::BlockMatrixClustering<Type>::agglomerateCoeffs
|
|||
continue;
|
||||
}
|
||||
|
||||
label cCoeff = coeffRestrictAddr[fineCoeffI];
|
||||
label cCoeff = coeffRestrictAddr_[fineCoeffI];
|
||||
|
||||
if (cCoeff >= 0)
|
||||
{
|
||||
|
@ -673,7 +669,6 @@ template<class Type>
|
|||
template<class DiagType, class ULType>
|
||||
void Foam::BlockMatrixClustering<Type>::agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
|
@ -688,7 +683,11 @@ void Foam::BlockMatrixClustering<Type>::agglomerateCoeffs
|
|||
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
|
||||
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
|
||||
|
||||
forAll(coeffRestrictAddr, fineCoeffI)
|
||||
// Reset coefficients to zero. Cannot touch the diagonal
|
||||
activeCoarseUpper = pTraits<ULType>::zero;
|
||||
activeCoarseLower = pTraits<ULType>::zero;
|
||||
|
||||
forAll(coeffRestrictAddr_, fineCoeffI)
|
||||
{
|
||||
label rmUpperAddr = agglomIndex_[upperAddr[fineCoeffI]];
|
||||
label rmLowerAddr = agglomIndex_[lowerAddr[fineCoeffI]];
|
||||
|
@ -700,7 +699,7 @@ void Foam::BlockMatrixClustering<Type>::agglomerateCoeffs
|
|||
continue;
|
||||
}
|
||||
|
||||
label cCoeff = coeffRestrictAddr[fineCoeffI];
|
||||
label cCoeff = coeffRestrictAddr_[fineCoeffI];
|
||||
|
||||
if (cCoeff >= 0)
|
||||
{
|
||||
|
@ -739,10 +738,8 @@ void Foam::BlockMatrixClustering<Type>::restrictDiagDecoupled
|
|||
linearTypeField& activeCoarseCoeff = coarseCoeff.asLinear();
|
||||
const linearTypeField& activeCoeff = Coeff.asLinear();
|
||||
|
||||
forAll (coarseCoeff, i)
|
||||
{
|
||||
activeCoarseCoeff[i] = pTraits<linearType>::zero;
|
||||
}
|
||||
// Reset coefficients to zero
|
||||
activeCoarseCoeff = pTraits<linearType>::zero;
|
||||
|
||||
forAll (Coeff, i)
|
||||
{
|
||||
|
@ -761,10 +758,8 @@ void Foam::BlockMatrixClustering<Type>::restrictDiagDecoupled
|
|||
scalarTypeField& activeCoarseCoeff = coarseCoeff.asScalar();
|
||||
const scalarTypeField& activeCoeff = Coeff.asScalar();
|
||||
|
||||
forAll (coarseCoeff, i)
|
||||
{
|
||||
activeCoarseCoeff[i] = pTraits<scalarType>::zero;
|
||||
}
|
||||
// Reset coefficients to zero
|
||||
activeCoarseCoeff = pTraits<scalarType>::zero;
|
||||
|
||||
forAll (Coeff, i)
|
||||
{
|
||||
|
@ -800,6 +795,7 @@ Foam::BlockMatrixClustering<Type>::BlockMatrixClustering
|
|||
maxGroupSize_(readLabel(dict.lookup("maxGroupSize"))),
|
||||
normPtr_(BlockCoeffNorm<Type>::New(dict)),
|
||||
agglomIndex_(matrix_.lduAddr().size()),
|
||||
coeffRestrictAddr_(),
|
||||
groupSize_(groupSize),
|
||||
nSolo_(0),
|
||||
nCoarseEqns_(0),
|
||||
|
@ -850,8 +846,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
|
||||
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
|
||||
|
||||
const label nFineCoeffs = upperAddr.size();
|
||||
|
||||
# ifdef FULLDEBUG
|
||||
if (agglomIndex_.size() != matrix_.lduAddr().size())
|
||||
{
|
||||
|
@ -866,7 +860,8 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
}
|
||||
# endif
|
||||
|
||||
// Does the matrix have solo equations
|
||||
// If the matrix will be coarsened, create off-diagonal agglomeration
|
||||
// Does the matrix have solo equations
|
||||
bool soloEqns = nSolo_ > 0;
|
||||
|
||||
// Storage for block neighbours and coefficients
|
||||
|
@ -880,8 +875,10 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
// Setup initial packed storage for neighbours and coefficients
|
||||
labelList blockNbrsData(maxNnbrs*nCoarseEqns_);
|
||||
|
||||
const label nFineCoeffs = upperAddr.size();
|
||||
|
||||
// Create face-restriction addressing
|
||||
labelList coeffRestrictAddr(nFineCoeffs);
|
||||
coeffRestrictAddr_.setSize(nFineCoeffs);
|
||||
|
||||
// Initial neighbour array (not in upper-triangle order)
|
||||
labelList initCoarseNeighb(nFineCoeffs);
|
||||
|
@ -906,8 +903,8 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
{
|
||||
// For each fine coeff inside of a coarse cluster keep the address
|
||||
// of the cluster corresponding to the coeff in the
|
||||
// coeffRestrictAddr as a negative index
|
||||
coeffRestrictAddr[fineCoeffi] = -(rmUpperAddr + 1);
|
||||
// coeffRestrictAddr_ as a negative index
|
||||
coeffRestrictAddr_[fineCoeffi] = -(rmUpperAddr + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -932,7 +929,7 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
if (initCoarseNeighb[blockNbrsData[maxNnbrs*cOwn + i]] == cNei)
|
||||
{
|
||||
nbrFound = true;
|
||||
coeffRestrictAddr[fineCoeffi] =
|
||||
coeffRestrictAddr_[fineCoeffi] =
|
||||
blockNbrsData[maxNnbrs*cOwn + i];
|
||||
break;
|
||||
}
|
||||
|
@ -962,7 +959,7 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
blockNbrsData[maxNnbrs*cOwn + ccnCoeffs] = nCoarseCoeffs;
|
||||
initCoarseNeighb[nCoarseCoeffs] = cNei;
|
||||
coeffRestrictAddr[fineCoeffi] = nCoarseCoeffs;
|
||||
coeffRestrictAddr_[fineCoeffi] = nCoarseCoeffs;
|
||||
ccnCoeffs++;
|
||||
|
||||
// New coarse coeff created
|
||||
|
@ -995,7 +992,7 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
}
|
||||
}
|
||||
|
||||
forAll(coeffRestrictAddr, fineCoeffi)
|
||||
forAll(coeffRestrictAddr_, fineCoeffi)
|
||||
{
|
||||
label rmUpperAddr = agglomIndex_[upperAddr[fineCoeffi]];
|
||||
label rmLowerAddr = agglomIndex_[lowerAddr[fineCoeffi]];
|
||||
|
@ -1007,10 +1004,10 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
continue;
|
||||
}
|
||||
|
||||
if (coeffRestrictAddr[fineCoeffi] >= 0)
|
||||
if (coeffRestrictAddr_[fineCoeffi] >= 0)
|
||||
{
|
||||
coeffRestrictAddr[fineCoeffi] =
|
||||
coarseCoeffMap[coeffRestrictAddr[fineCoeffi]];
|
||||
coeffRestrictAddr_[fineCoeffi] =
|
||||
coarseCoeffMap[coeffRestrictAddr_[fineCoeffi]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1019,8 +1016,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
blockNbrsData.setSize(0);
|
||||
initCoarseNeighb.setSize(0);
|
||||
coarseCoeffMap.setSize(0);
|
||||
|
||||
|
||||
// Create coarse-level coupled interfaces
|
||||
|
||||
// Create coarse interfaces, addressing and coefficients
|
||||
|
@ -1028,8 +1023,7 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
const_cast<BlockLduMatrix<Type>& >(matrix_).interfaces().size();
|
||||
|
||||
const typename BlockLduInterfaceFieldPtrsList<Type>::Type&
|
||||
interfaceFields =
|
||||
const_cast<BlockLduMatrix<Type>&>(matrix_).interfaces();
|
||||
interfaceFields = matrix_.interfaces();
|
||||
|
||||
// Set the coarse interfaces and coefficients
|
||||
lduInterfacePtrsList coarseInterfaces(interfaceSize);
|
||||
|
@ -1046,7 +1040,7 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
nCoarseEqns_,
|
||||
coarseOwner,
|
||||
coarseNeighbour,
|
||||
Pstream::worldComm, //HJ, AMG Comm fineMesh.comm(),
|
||||
Pstream::worldComm,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
@ -1140,7 +1134,39 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
);
|
||||
BlockLduMatrix<Type>& coarseMatrix = coarseMatrixPtr();
|
||||
|
||||
// Build matrix coefficients
|
||||
this->updateMatrix(coarseMatrix);
|
||||
|
||||
// Create and return BlockAMGLevel
|
||||
return autoPtr<BlockAMGLevel<Type> >
|
||||
(
|
||||
new coarseBlockAMGLevel<Type>
|
||||
(
|
||||
coarseAddrPtr,
|
||||
coarseMatrixPtr,
|
||||
this->dict(),
|
||||
this->type(),
|
||||
this->groupSize(),
|
||||
this->minCoarseEqns()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockMatrixClustering<Type>::updateMatrix
|
||||
(
|
||||
BlockLduMatrix<Type>& coarseMatrix
|
||||
) const
|
||||
{
|
||||
// Get interfaces from fine matrix
|
||||
const typename BlockLduInterfaceFieldPtrsList<Type>::Type&
|
||||
interfaceFields = matrix_.interfaces();
|
||||
|
||||
// Get interfaces from coarse matrix
|
||||
lduInterfacePtrsList coarseInterfaces = coarseMatrix.mesh().interfaces();
|
||||
|
||||
// Get interfaces fields from coarse matrix
|
||||
typename BlockLduInterfaceFieldPtrsList<Type>::Type&
|
||||
coarseInterfaceFieldsTransfer = coarseMatrix.interfaces();
|
||||
|
||||
|
@ -1242,7 +1268,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
agglomerateCoeffs
|
||||
(
|
||||
coeffRestrictAddr,
|
||||
activeCoarseDiag,
|
||||
activeCoarseUpper,
|
||||
activeFineUpper,
|
||||
|
@ -1264,7 +1289,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
agglomerateCoeffs
|
||||
(
|
||||
coeffRestrictAddr,
|
||||
activeCoarseDiag,
|
||||
activeCoarseUpper,
|
||||
activeFineUpper,
|
||||
|
@ -1286,7 +1310,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
agglomerateCoeffs
|
||||
(
|
||||
coeffRestrictAddr,
|
||||
activeCoarseDiag,
|
||||
activeCoarseUpper,
|
||||
activeFineUpper,
|
||||
|
@ -1326,7 +1349,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
agglomerateCoeffs
|
||||
(
|
||||
coeffRestrictAddr,
|
||||
activeCoarseDiag,
|
||||
activeCoarseUpper,
|
||||
activeFineUpper,
|
||||
|
@ -1352,7 +1374,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
agglomerateCoeffs
|
||||
(
|
||||
coeffRestrictAddr,
|
||||
activeCoarseDiag,
|
||||
activeCoarseUpper,
|
||||
activeFineUpper,
|
||||
|
@ -1378,7 +1399,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
|
||||
agglomerateCoeffs
|
||||
(
|
||||
coeffRestrictAddr,
|
||||
activeCoarseDiag,
|
||||
activeCoarseUpper,
|
||||
activeFineUpper,
|
||||
|
@ -1396,20 +1416,6 @@ Foam::BlockMatrixClustering<Type>::restrictMatrix() const
|
|||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// Create and return BlockAMGLevel
|
||||
return autoPtr<BlockAMGLevel<Type> >
|
||||
(
|
||||
new coarseBlockAMGLevel<Type>
|
||||
(
|
||||
coarseAddrPtr,
|
||||
coarseMatrixPtr,
|
||||
this->dict(),
|
||||
this->type(),
|
||||
this->groupSize(),
|
||||
this->minCoarseEqns()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -76,7 +76,10 @@ class BlockMatrixClustering
|
|||
autoPtr<BlockCoeffNorm<Type> > normPtr_;
|
||||
|
||||
//- Child array: for each fine equation give a clustering index
|
||||
labelField agglomIndex_;
|
||||
labelList agglomIndex_;
|
||||
|
||||
//- Face-restriction addressing
|
||||
mutable labelList coeffRestrictAddr_;
|
||||
|
||||
//- Group size
|
||||
label groupSize_;
|
||||
|
@ -116,7 +119,6 @@ class BlockMatrixClustering
|
|||
template<class DiagType, class ULType>
|
||||
void agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
|
@ -127,7 +129,6 @@ class BlockMatrixClustering
|
|||
template<class DiagType, class ULType>
|
||||
void agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
|
@ -154,7 +155,7 @@ class BlockMatrixClustering
|
|||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cluster");
|
||||
TypeName("AAMG");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
@ -197,6 +198,9 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& coarseX
|
||||
) const;
|
||||
|
||||
//- Update coarse matrix using same coefficients
|
||||
virtual void updateMatrix(BlockLduMatrix<Type>& coarseMatrix) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -57,18 +57,18 @@ namespace Foam
|
|||
|
||||
// Disable restrict matrix: no square type
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<scalar> >
|
||||
BlockMatrixClustering<scalar>::restrictMatrix() const
|
||||
inline void
|
||||
BlockMatrixClustering<scalar>::updateMatrix
|
||||
(
|
||||
BlockLduMatrix<scalar>& coarseMatrix
|
||||
) const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<scalar> > "
|
||||
"BlockMatrixClustering<Type>::restrictMatrix() const"
|
||||
"BlockMatrixClustering<Type>::updateMatrix(...) const"
|
||||
) << "Function not implemented for Type=scalar. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<scalar> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,26 +49,23 @@ namespace Foam
|
|||
Class BlockMatrixClustering Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Disable restrict matrix: no square type
|
||||
// Disable updateMatrix matrix: no square type
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<tensor> >
|
||||
BlockMatrixClustering<tensor>::restrictMatrix
|
||||
() const
|
||||
inline void
|
||||
BlockMatrixClustering<tensor>::updateMatrix
|
||||
(
|
||||
BlockLduMatrix<tensor>& coarseMatrix
|
||||
) const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<tensor> > "
|
||||
"BlockMatrixClustering<Type>::"
|
||||
"restrictMatrix() const"
|
||||
"void BlockMatrixClustering<Type>::"
|
||||
"updateMatrix(...) const"
|
||||
) << "Function not implemented for Type=tensor. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<tensor> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
|
|
@ -172,8 +172,7 @@ public:
|
|||
virtual bool coarsen() const = 0;
|
||||
|
||||
//- Restrict matrix
|
||||
virtual autoPtr<BlockAMGLevel<Type> > restrictMatrix
|
||||
() const = 0;
|
||||
virtual autoPtr<BlockAMGLevel<Type> > restrictMatrix() const = 0;
|
||||
|
||||
//- Restrict residual
|
||||
virtual void restrictResidual
|
||||
|
@ -189,6 +188,8 @@ public:
|
|||
const Field<Type>& coarseX
|
||||
) const = 0;
|
||||
|
||||
//- Update coarse matrix using same coefficients
|
||||
virtual void updateMatrix(BlockLduMatrix<Type>& coarseMatrix) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -203,15 +204,15 @@ public:
|
|||
#endif
|
||||
|
||||
#define makeBlockMatrixCoarsening(BlockMatrixCoarseningType, typeBlockMatrixCoarseningType) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(typeBlockMatrixCoarseningType, 0); \
|
||||
\
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(typeBlockMatrixCoarseningType, 0); \
|
||||
\
|
||||
addToRunTimeSelectionTable(BlockMatrixCoarseningType, typeBlockMatrixCoarseningType, matrix);
|
||||
|
||||
#define makeBlockMatrixCoarsenings(blockAmgCoarseningType) \
|
||||
\
|
||||
makeBlockMatrixCoarsening(blockScalarMatrixCoarsening, blockAmgCoarseningType##Scalar); \
|
||||
makeBlockMatrixCoarsening(blockVectorMatrixCoarsening, blockAmgCoarseningType##Vector); \
|
||||
#define makeBlockMatrixCoarsenings(blockAmgCoarseningType) \
|
||||
\
|
||||
makeBlockMatrixCoarsening(blockScalarMatrixCoarsening, blockAmgCoarseningType##Scalar); \
|
||||
makeBlockMatrixCoarsening(blockVectorMatrixCoarsening, blockAmgCoarseningType##Vector); \
|
||||
makeBlockMatrixCoarsening(blockTensorMatrixCoarsening, blockAmgCoarseningType##Tensor);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,217 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixReorderedClustering
|
||||
|
||||
Description
|
||||
Block matrix AMG coarsening by Jasak clustering algorithm
|
||||
|
||||
Author
|
||||
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
||||
|
||||
SourceFiles
|
||||
BlockMatrixReorderedClustering.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BlockMatrixReorderedClustering_H
|
||||
#define BlockMatrixReorderedClustering_H
|
||||
|
||||
#include "BlockMatrixCoarsening.H"
|
||||
#include "BlockLduMatrix.H"
|
||||
#include "BlockCoeffNorm.H"
|
||||
#include "BlockCoeff.H"
|
||||
#include "tolerancesSwitch.H"
|
||||
#include "cpuTime.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockMatrixReorderedClustering Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class BlockMatrixReorderedClustering
|
||||
:
|
||||
public BlockMatrixCoarsening<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to matrix
|
||||
const BlockLduMatrix<Type>& matrix_;
|
||||
|
||||
//- Min group size
|
||||
const label minGroupSize_;
|
||||
|
||||
//- Max group size
|
||||
const label maxGroupSize_;
|
||||
|
||||
//- Reference to a templated norm calculator
|
||||
autoPtr<BlockCoeffNorm<Type> > normPtr_;
|
||||
|
||||
//- Child array: for each fine equation give a clustering index
|
||||
labelField agglomIndex_;
|
||||
|
||||
//- Group size
|
||||
label groupSize_;
|
||||
|
||||
//- Number of solo cells
|
||||
label nSolo_;
|
||||
|
||||
//- Number of coarse equations
|
||||
label nCoarseEqns_;
|
||||
|
||||
//- Can a coarse level be constructed?
|
||||
bool coarsen_;
|
||||
|
||||
cpuTime lTime_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
BlockMatrixReorderedClustering(const BlockMatrixReorderedClustering<Type>&);
|
||||
|
||||
// Disallow default bitwise assignment
|
||||
void operator=(const BlockMatrixReorderedClustering<Type>&);
|
||||
|
||||
|
||||
//- Calculate clustering index (child)
|
||||
void calcClustering();
|
||||
|
||||
//- Restrict CoeffField. Used for diag coefficient
|
||||
void restrictDiag
|
||||
(
|
||||
const CoeffField<Type>& Coeff,
|
||||
CoeffField<Type>& coarseCoeff
|
||||
) const;
|
||||
|
||||
//- Agglomerate coeffs, symmetric matrix
|
||||
template<class DiagType, class ULType>
|
||||
void agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
const Field<ULType>& activeFineUpperTranspose
|
||||
) const;
|
||||
|
||||
//- Agglomerate coeffs, assymmetric matrix
|
||||
template<class DiagType, class ULType>
|
||||
void agglomerateCoeffs
|
||||
(
|
||||
const labelList& coeffRestrictAddr,
|
||||
Field<DiagType>& activeCoarseDiag,
|
||||
Field<ULType>& activeCoarseUpper,
|
||||
const Field<ULType>& activeFineUpper,
|
||||
Field<ULType>& activeCoarseLower,
|
||||
const Field<ULType>& activeFineLower
|
||||
) const;
|
||||
|
||||
//- Restrict CoeffField, decoupled version. Used for diag coefficient
|
||||
void restrictDiagDecoupled
|
||||
(
|
||||
const CoeffField<Type>& Coeff,
|
||||
CoeffField<Type>& coarseCoeff
|
||||
) const;
|
||||
|
||||
// Private Static Data
|
||||
|
||||
//- Weighting factor
|
||||
static const debug::tolerancesSwitch weightFactor_;
|
||||
|
||||
//- Diagonal scaling factor
|
||||
static const debug::tolerancesSwitch diagFactor_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("reorderedCluster");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix and group size
|
||||
BlockMatrixReorderedClustering
|
||||
(
|
||||
const BlockLduMatrix<Type>& matrix,
|
||||
const dictionary& dict,
|
||||
const label groupSize,
|
||||
const label minCoarseEqns
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~BlockMatrixReorderedClustering();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Can a coarse level be constructed?
|
||||
virtual bool coarsen() const
|
||||
{
|
||||
return coarsen_;
|
||||
}
|
||||
|
||||
//- Restrict matrix
|
||||
virtual autoPtr<BlockAMGLevel<Type> > restrictMatrix() const;
|
||||
|
||||
//- Restrict residual
|
||||
virtual void restrictResidual
|
||||
(
|
||||
const Field<Type>& res,
|
||||
Field<Type>& coarseRes
|
||||
) const;
|
||||
|
||||
//- Prolongate correction
|
||||
virtual void prolongateCorrection
|
||||
(
|
||||
Field<Type>& x,
|
||||
const Field<Type>& coarseX
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "BlockMatrixReorderedClustering.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,43 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "blockMatrixReorderedClusterings.H"
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "coarseBlockAMGLevel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeBlockMatrixCoarsenings(blockMatrixReorderedClustering);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,65 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixReorderedClustering
|
||||
|
||||
Description
|
||||
Typedefs for block matrix AMG coarsening by Jasak clustering algorithm.
|
||||
|
||||
Author
|
||||
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
||||
|
||||
SourceFiles
|
||||
blockMatrixReorderedClustering.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef blockMatrixReorderedClusterings_H
|
||||
#define blockMatrixReorderedClusterings_H
|
||||
|
||||
#include "scalarBlockMatrixReorderedClustering.H"
|
||||
#include "tensorBlockMatrixReorderedClustering.H"
|
||||
#include "BlockMatrixReorderedClustering.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef BlockMatrixReorderedClustering<scalar> blockMatrixReorderedClusteringScalar;
|
||||
typedef BlockMatrixReorderedClustering<vector> blockMatrixReorderedClusteringVector;
|
||||
typedef BlockMatrixReorderedClustering<tensor> blockMatrixReorderedClusteringTensor;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,86 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixReorderedClustering
|
||||
|
||||
Description
|
||||
Specialisation of the BlockMatrixReorderedClustering for scalars.
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2013-01-31
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef scalarBlockMatrixReorderedClustering_H
|
||||
#define scalarBlockMatrixReorderedClustering_H
|
||||
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "blockMatrixReorderedClusterings.H"
|
||||
#include "BlockMatrixReorderedClustering.H"
|
||||
#include "BlockMatrixCoarsening.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "scalarBlockLduMatrix.H"
|
||||
#include "scalarBlockConstraint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockMatrixReorderedClustering Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Disable restrict matrix: no square type
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<scalar> >
|
||||
BlockMatrixReorderedClustering<scalar>::restrictMatrix() const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<scalar> > "
|
||||
"BlockMatrixReorderedClustering<Type>::restrictMatrix() const"
|
||||
) << "Function not implemented for Type=scalar. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<scalar> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,83 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 4.0
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
BlockMatrixReorderedClustering
|
||||
|
||||
Description
|
||||
Specialisation of the BlockMatrixReorderedClustering for tensors.
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2013-01-31
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tensorBlockMatrixReorderedClustering_H
|
||||
#define tensorBlockMatrixReorderedClustering_H
|
||||
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "blockMatrixReorderedClusterings.H"
|
||||
#include "BlockMatrixReorderedClustering.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockMatrixReorderedClustering Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Disable restrict matrix: no square type
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<tensor> >
|
||||
BlockMatrixReorderedClustering<tensor>::restrictMatrix
|
||||
() const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<tensor> > "
|
||||
"BlockMatrixReorderedClustering<Type>::"
|
||||
"restrictMatrix() const"
|
||||
) << "Function not implemented for Type=tensor. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<tensor> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -727,7 +727,6 @@ Foam::BlockMatrixSelection<Type>::restrictMatrix() const
|
|||
}
|
||||
|
||||
// Get references to restriction and prolongation matrix
|
||||
|
||||
const crMatrix& R = *Rptr_;
|
||||
const crMatrix& P = *Pptr_;
|
||||
|
||||
|
@ -989,8 +988,7 @@ Foam::BlockMatrixSelection<Type>::restrictMatrix() const
|
|||
nCoarseEqns_,
|
||||
coarseOwner,
|
||||
coarseNeighbour,
|
||||
// true
|
||||
false // DO NOT REUSE STORAGE! HJ, HERE
|
||||
false // DO NOT REUSE STORAGE!
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1110,12 +1108,77 @@ Foam::BlockMatrixSelection<Type>::restrictMatrix() const
|
|||
);
|
||||
BlockLduMatrix<Type>& coarseMatrix = coarseMatrixPtr();
|
||||
|
||||
// Build matrix coefficients
|
||||
this->updateMatrix(coarseMatrix);
|
||||
|
||||
// Create and return BlockAMGLevel
|
||||
return autoPtr<BlockAMGLevel<Type> >
|
||||
(
|
||||
new coarseBlockAMGLevel<Type>
|
||||
(
|
||||
coarseAddrPtr,
|
||||
coarseMatrixPtr,
|
||||
this->dict(),
|
||||
this->type(),
|
||||
0, // Group size is not used in SAMG
|
||||
this->minCoarseEqns()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockMatrixSelection<Type>::updateMatrix
|
||||
(
|
||||
BlockLduMatrix<Type>& coarseMatrix
|
||||
) const
|
||||
{
|
||||
// Get references to restriction and prolongation matrix
|
||||
const crMatrix& R = *Rptr_;
|
||||
const crMatrix& P = *Pptr_;
|
||||
|
||||
// Get connectivity
|
||||
const crAddressing& crR = R.crAddr();
|
||||
const crAddressing& crP = P.crAddr();
|
||||
|
||||
// Restriction addressing
|
||||
const labelList& rowR = crR.rowStart();
|
||||
const labelList& colR = crR.column();
|
||||
|
||||
// Matrix A addressing
|
||||
const unallocLabelList& rowA = matrix_.lduAddr().ownerStartAddr();
|
||||
const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
|
||||
|
||||
// Get interfaces from fine matrix
|
||||
const typename BlockLduInterfaceFieldPtrsList<Type>::Type&
|
||||
interfaceFields = matrix_.interfaces();
|
||||
|
||||
// Addressing for lower triangle loop
|
||||
const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
|
||||
const unallocLabelList& losortAddr = matrix_.lduAddr().losortAddr();
|
||||
const unallocLabelList& losortStart = matrix_.lduAddr().losortStartAddr();
|
||||
|
||||
// Prolongation addressing
|
||||
const labelList& rowP = crP.rowStart();
|
||||
const labelList& colP = crP.column();
|
||||
|
||||
// In order to avoid searching for the off-diagonal coefficient,
|
||||
// a mark array is used for each row's assembly.
|
||||
// Mark records the index of the off-diagonal coefficient in the row
|
||||
// for each neighbour entry. It is reset after completing each row of the
|
||||
// coarse matrix.
|
||||
// HJ, 28/Apr/2017
|
||||
labelList coeffLabel(nCoarseEqns_, -1);
|
||||
|
||||
typedef CoeffField<Type> TypeCoeffField;
|
||||
|
||||
TypeCoeffField& coarseUpper = coarseMatrix.upper();
|
||||
TypeCoeffField& coarseDiag = coarseMatrix.diag();
|
||||
TypeCoeffField& coarseLower = coarseMatrix.lower();
|
||||
|
||||
// Get the coarse interfaces and coefficients
|
||||
lduInterfacePtrsList coarseInterfaces = coarseMatrix.mesh().interfaces();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GET COEFFICIENTS
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -1413,20 +1476,6 @@ Foam::BlockMatrixSelection<Type>::restrictMatrix() const
|
|||
) << "Matrix diagonal of scalar or linear type not implemented"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Create and return BlockAMGLevel
|
||||
return autoPtr<BlockAMGLevel<Type> >
|
||||
(
|
||||
new coarseBlockAMGLevel<Type>
|
||||
(
|
||||
coarseAddrPtr,
|
||||
coarseMatrixPtr,
|
||||
this->dict(),
|
||||
this->type(),
|
||||
0, // Group size is not used in SAMG
|
||||
this->minCoarseEqns()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -185,6 +185,9 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& coarseX
|
||||
) const;
|
||||
|
||||
//- Update coarse matrix using same coefficients
|
||||
virtual void updateMatrix(BlockLduMatrix<Type>& coarseMatrix) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,18 +49,17 @@ namespace Foam
|
|||
// Disable restrict matrix
|
||||
// HJ: remove inline in refactoring
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<scalar> >
|
||||
BlockMatrixSelection<scalar>::restrictMatrix() const
|
||||
inline void BlockMatrixSelection<scalar>::updateMatrix
|
||||
(
|
||||
BlockLduMatrix<scalar>& coarseMatrix
|
||||
) const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<scalar> > "
|
||||
"BlockMatrixSelection<Type>::restrictMatrix() const"
|
||||
"BlockMatrixSelection<Type>::updateMatrix(...) const"
|
||||
) << "Function not implemented for Type=scalar. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<scalar> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,19 +49,18 @@ namespace Foam
|
|||
// Disable restrict matrix: no square type
|
||||
// HJ: remove inline in refactoring
|
||||
template<>
|
||||
inline autoPtr<BlockAMGLevel<tensor> >
|
||||
BlockMatrixSelection<tensor>::restrictMatrix() const
|
||||
inline void BlockMatrixSelection<tensor>::updateMatrix
|
||||
(
|
||||
BlockLduMatrix<tensor>& coarseMatrix
|
||||
) const
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"autoPtr<BlockAMGLevel<tensor> > "
|
||||
"BlockMatrixSelection<Type>::"
|
||||
"restrictMatrix() const"
|
||||
"updateMatrix(...) const"
|
||||
) << "Function not implemented for Type=tensor. " << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return to keep compiler happy
|
||||
return autoPtr<BlockAMGLevel<tensor> >(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -104,6 +104,13 @@ Foam::coarseBlockAMGLevel<Type>::~coarseBlockAMGLevel()
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::BlockLduMatrix<Type>& Foam::coarseBlockAMGLevel<Type>::matrix()
|
||||
{
|
||||
return matrixPtr_();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Field<Type>& Foam::coarseBlockAMGLevel<Type>::x()
|
||||
{
|
||||
|
@ -334,4 +341,23 @@ Foam::coarseBlockAMGLevel<Type>::makeNextLevel() const
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::coarseBlockAMGLevel<Type>::initLevel
|
||||
(
|
||||
autoPtr<Foam::BlockAMGLevel<Type> >& coarseLevelPtr
|
||||
)
|
||||
{
|
||||
// Update matrix by repeating coarsening
|
||||
|
||||
// Update smoother for new matrix
|
||||
smootherPtr_->initMatrix();
|
||||
|
||||
// Update coarse matrix if it exists
|
||||
if (coarseLevelPtr.valid())
|
||||
{
|
||||
coarseningPtr_->updateMatrix(coarseLevelPtr->matrix());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -125,6 +125,9 @@ public:
|
|||
return dict_;
|
||||
}
|
||||
|
||||
//- Return reference to matrix
|
||||
virtual BlockLduMatrix<Type>& matrix();
|
||||
|
||||
//- Return reference to x
|
||||
virtual Field<Type>& x();
|
||||
|
||||
|
@ -184,6 +187,13 @@ public:
|
|||
|
||||
//- Create next level from current level
|
||||
virtual autoPtr<BlockAMGLevel<Type> > makeNextLevel() const;
|
||||
|
||||
//- Re-initialise AMG level after matrix coefficient update
|
||||
// and update matrix coefficients on coarse level using same coarsening
|
||||
virtual void initLevel
|
||||
(
|
||||
autoPtr<Foam::BlockAMGLevel<Type> >& coarseLevelPtr
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -81,11 +81,23 @@ Foam::fineBlockAMGLevel<Type>::fineBlockAMGLevel
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::BlockLduMatrix<Type>& Foam::fineBlockAMGLevel<Type>::matrix()
|
||||
{
|
||||
FatalErrorIn("Field<Type>& Foam::fineBlockAMGLevel<Type>::matrix()")
|
||||
<< "Access to matrix is not available on fine level."
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return
|
||||
return const_cast<BlockLduMatrix<Type>&>(matrix_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Field<Type>& Foam::fineBlockAMGLevel<Type>::x()
|
||||
{
|
||||
FatalErrorIn("Field<Type>& Foam::fineBlockAMGLevel<Type>::x()")
|
||||
<< "x is not available."
|
||||
<< "x is not available on fine level."
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return
|
||||
|
@ -97,7 +109,7 @@ template<class Type>
|
|||
Foam::Field<Type>& Foam::fineBlockAMGLevel<Type>::b()
|
||||
{
|
||||
FatalErrorIn("Field<Type>& Foam::fineBlockAMGLevel<Type>::b()")
|
||||
<< "b is not available."
|
||||
<< "b is not available on fine level."
|
||||
<< abort(FatalError);
|
||||
|
||||
// Dummy return
|
||||
|
@ -279,4 +291,23 @@ Foam::fineBlockAMGLevel<Type>::makeNextLevel() const
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::fineBlockAMGLevel<Type>::initLevel
|
||||
(
|
||||
autoPtr<Foam::BlockAMGLevel<Type> >& coarseLevelPtr
|
||||
)
|
||||
{
|
||||
// Fine matrix has been updated externally
|
||||
|
||||
// Update smoother for new matrix
|
||||
smootherPtr_->initMatrix();
|
||||
|
||||
// Update coarse matrix if it exists
|
||||
if (coarseLevelPtr.valid())
|
||||
{
|
||||
coarseningPtr_->updateMatrix(coarseLevelPtr->matrix());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -125,6 +125,9 @@ public:
|
|||
return dict_;
|
||||
}
|
||||
|
||||
//- Return reference to matrix
|
||||
virtual BlockLduMatrix<Type>& matrix();
|
||||
|
||||
//- Return reference to x
|
||||
virtual Field<Type>& x();
|
||||
|
||||
|
@ -183,6 +186,13 @@ public:
|
|||
|
||||
//- Create next level from current level
|
||||
virtual autoPtr<BlockAMGLevel<Type> > makeNextLevel() const;
|
||||
|
||||
//- Re-initialise AMG level after matrix coefficient update
|
||||
// and update matrix coefficients on coarse level using same coarsening
|
||||
virtual void initLevel
|
||||
(
|
||||
autoPtr<Foam::BlockAMGLevel<Type> >& coarseLevelPtr
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ Foam::BlockLduMatrix<Type>::BlockLduMatrix(const lduMesh& ldu)
|
|||
coupleUpper_.set(i, new CoeffField<Type>(addr.patchAddr(i).size()));
|
||||
coupleLower_.set(i, new CoeffField<Type>(addr.patchAddr(i).size()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -141,4 +141,11 @@ void Foam::BlockAMGPrecon<Type>::precondition
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockAMGPrecon<Type>::initMatrix()
|
||||
{
|
||||
amgPtr_->initMatrix();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -25,7 +25,7 @@ Class
|
|||
BlockAMGPrecon
|
||||
|
||||
Description
|
||||
AMG preconditioning
|
||||
Algebraic Multigrid preconditioning for block matrices
|
||||
|
||||
Author
|
||||
Klas Jareteg, 2012-12-13
|
||||
|
@ -55,7 +55,7 @@ template<class Type>
|
|||
class BlockAMGCycle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockAMGPrecon Declaration
|
||||
Class BlockAMGPrecon Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
|
@ -141,6 +141,9 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
) const;
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -914,7 +914,7 @@ Foam::BlockCholeskyPrecon<Type>::BlockCholeskyPrecon
|
|||
BlockLduPrecon<Type>(matrix),
|
||||
preconDiag_(matrix.diag())
|
||||
{
|
||||
calcPreconDiag();
|
||||
this->calcPreconDiag();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1301,4 +1301,13 @@ void Foam::BlockCholeskyPrecon<Type>::preconditionT
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockCholeskyPrecon<Type>::initMatrix()
|
||||
{
|
||||
preconDiag_ = this->matrix_.diag();
|
||||
|
||||
this->calcPreconDiag();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -25,7 +25,7 @@ Class
|
|||
BlockCholeskyPrecon
|
||||
|
||||
Description
|
||||
Incomplete Cholesky preconditioning with no fill-in.
|
||||
Incomplete Cholesky preconditioning with no fill-in for block matrices.
|
||||
|
||||
Author
|
||||
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
||||
|
@ -215,6 +215,9 @@ public:
|
|||
Field<Type>& xT,
|
||||
const Field<Type>& bT
|
||||
) const;
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -107,6 +107,10 @@ public:
|
|||
{
|
||||
return precondition(xT, bT);
|
||||
}
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -946,4 +946,14 @@ void Foam::BlockGaussSeidelPrecon<Type>::preconditionT
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockGaussSeidelPrecon<Type>::initMatrix()
|
||||
{
|
||||
invDiag_.clear();
|
||||
LUDiag_.clear();
|
||||
|
||||
this->calcInvDiag();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -172,6 +172,9 @@ public:
|
|||
Field<Type>& xT,
|
||||
const Field<Type>& bT
|
||||
) const;
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -840,4 +840,17 @@ void Foam::BlockILUCpPrecon<Type>::preconditionT
|
|||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::BlockILUCpPrecon<Type>::initMatrix()
|
||||
{
|
||||
// Clear extended matrix
|
||||
extBlockMatrix_.extendedLower().clear();
|
||||
extBlockMatrix_.extendedLower().clear();
|
||||
|
||||
preconDiag_ = this->matrix_.diag();
|
||||
|
||||
this->calcFactorization();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -168,6 +168,9 @@ public:
|
|||
Field<Type>& xT,
|
||||
const Field<Type>& bT
|
||||
) const;
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -140,6 +140,9 @@ public:
|
|||
"(Field<Type>& xT, const Field<Type>& bT) const"
|
||||
);
|
||||
}
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -109,6 +109,10 @@ public:
|
|||
{
|
||||
precondition(xT, bT);
|
||||
}
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -111,6 +111,12 @@ public:
|
|||
gs_.precondition(x, b);
|
||||
}
|
||||
}
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
gs_.initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -127,6 +127,12 @@ public:
|
|||
x += xCorr_;
|
||||
}
|
||||
}
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
precon_.initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -133,6 +133,12 @@ public:
|
|||
x += xCorr_;
|
||||
}
|
||||
}
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
precon_.initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -125,6 +125,9 @@ public:
|
|||
const Field<Type>& b,
|
||||
const label nSweeps
|
||||
) const = 0;
|
||||
|
||||
//- Re-initialise preconditioner after matrix coefficient update
|
||||
virtual void initMatrix() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Foam
|
|||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BlockAMGSolver Declaration
|
||||
Class BlockAMGSolver Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
|
@ -93,10 +93,9 @@ public:
|
|||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~BlockAMGSolver()
|
||||
{}
|
||||
//- Destructor
|
||||
virtual ~BlockAMGSolver()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
@ -107,6 +106,13 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
Info<< "REINITIALISE AMG" << endl;
|
||||
amg_.initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -102,6 +102,12 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
preconPtr_->initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -88,10 +88,9 @@ public:
|
|||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~BlockCGSolver()
|
||||
{}
|
||||
//- Destructor
|
||||
virtual ~BlockCGSolver()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
@ -102,6 +101,12 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
preconPtr_->initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -98,6 +98,10 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -115,6 +115,12 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
preconPtr_->initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -107,6 +107,12 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
gs_.initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -105,6 +105,13 @@ public:
|
|||
Field<Type>& x,
|
||||
const Field<Type>& b
|
||||
);
|
||||
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{
|
||||
ilu_.initMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -208,6 +208,9 @@ public:
|
|||
TypeField& x,
|
||||
const TypeField& b
|
||||
) = 0;
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -95,10 +95,9 @@ public:
|
|||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~SegregatedSolver()
|
||||
{}
|
||||
//- Destructor
|
||||
virtual ~SegregatedSolver()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
@ -110,6 +109,9 @@ public:
|
|||
const Field<Type>& b
|
||||
);
|
||||
|
||||
//- Re-initialise solver after matrix coefficient update
|
||||
virtual void initMatrix()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -50,9 +50,7 @@ License
|
|||
#include "blockAMGSolvers.H"
|
||||
#include "blockAMGPrecons.H"
|
||||
#include "blockMatrixCoarsenings.H"
|
||||
#include "blockMatrixAgglomerations.H"
|
||||
#include "blockMatrixClusterings.H"
|
||||
#include "blockMatrixReorderedClusterings.H"
|
||||
#include "blockMatrixSelections.H"
|
||||
#include "blockCoeffNorms.H"
|
||||
#include "blockCoeffTwoNorms.H"
|
||||
|
@ -153,15 +151,9 @@ typedef BlockMatrixCoarsening<type > block##Type##MatrixCoarsening; \
|
|||
defineNamedTemplateTypeNameAndDebug(block##Type##MatrixCoarsening, 0); \
|
||||
defineTemplateRunTimeSelectionTable(block##Type##MatrixCoarsening, matrix); \
|
||||
\
|
||||
typedef BlockMatrixAgglomeration<type > block##Type##MatrixAgglomeration; \
|
||||
makeBlockMatrixCoarsening(block##Type##MatrixCoarsening, block##Type##MatrixAgglomeration); \
|
||||
\
|
||||
typedef BlockMatrixClustering<type > block##Type##MatrixClustering; \
|
||||
makeBlockMatrixCoarsening(block##Type##MatrixCoarsening, block##Type##MatrixClustering); \
|
||||
\
|
||||
typedef BlockMatrixReorderedClustering<type > block##Type##MatrixReorderedClustering; \
|
||||
makeBlockMatrixCoarsening(block##Type##MatrixCoarsening, block##Type##MatrixReorderedClustering); \
|
||||
\
|
||||
typedef BlockMatrixSelection<type > block##Type##MatrixSelection; \
|
||||
makeBlockMatrixCoarsening(block##Type##MatrixCoarsening, block##Type##MatrixSelection); \
|
||||
\
|
||||
|
|
Reference in a new issue