Block matrix reorder clustering AMG

This commit is contained in:
Hrvoje Jasak 2017-05-30 14:33:23 +01:00
parent dfbe88d9fb
commit 2ffeda244c
7 changed files with 2000 additions and 1 deletions

View file

@ -718,7 +718,7 @@ BlockMatrixCoarsening = $(BlockAMG)/BlockMatrixCoarsening
$(BlockMatrixCoarsening)/BlockMatrixCoarsening/blockMatrixCoarsenings.C
$(BlockMatrixCoarsening)/BlockMatrixAgglomeration/blockMatrixAgglomerations.C
$(BlockMatrixCoarsening)/BlockMatrixClustering/blockMatrixClusterings.C
$(BlockMatrixCoarsening)/BlockSelectiveAMG/blockSelectiveAMGs.C
$(BlockMatrixCoarsening)/BlockMatrixReorderedClustering/blockMatrixReorderedClusterings.C
$(BlockMatrixCoarsening)/BlockMatrixSelection/blockMatrixSelections.C
BlockLduPrecons = matrices/blockLduMatrix/BlockLduPrecons

View file

@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View file

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View file

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View file

@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View file

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //