From 19eb6fbc6c29bb2847e56e054f83455818dade61 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Tue, 14 Jun 2016 14:53:28 +0100 Subject: [PATCH] Legacy solver wrappers ICCG and BICCG removed Instead of ICCG use PCG with the DIC preconditioner Instead of BICCG use PBiCG with the DILU preconditioner --- etc/controlDict | 2 - src/OpenFOAM/Make/files | 2 - .../matrices/lduMatrix/solvers/BICCG/BICCG.C | 113 ---------------- .../matrices/lduMatrix/solvers/BICCG/BICCG.H | 127 ------------------ .../lduMatrix/solvers/GAMG/GAMGSolver.H | 19 ++- .../lduMatrix/solvers/GAMG/GAMGSolverSolve.C | 52 +++++-- .../matrices/lduMatrix/solvers/ICCG/ICCG.C | 111 --------------- .../matrices/lduMatrix/solvers/ICCG/ICCG.H | 126 ----------------- src/OpenFOAM/matrices/solution/solution.C | 57 +++----- 9 files changed, 74 insertions(+), 535 deletions(-) delete mode 100644 src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C delete mode 100644 src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H delete mode 100644 src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C delete mode 100644 src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H diff --git a/etc/controlDict b/etc/controlDict index 152f441961e..35dad2b9679 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -75,7 +75,6 @@ DebugSwitches Analytical 0; APIdiffCoefFunc 0; Ar 0; - BICCG 0; BirdCarreau 0; C10H22 0; C12H26 0; @@ -158,7 +157,6 @@ DebugSwitches HerschelBulkley 0; HrenyaSinclair 0; IC8H18 0; - ICCG 0; IDDESDelta 0; IDEA 0; IFstream 0; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index c264836fb3b..c975296d1d0 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -271,8 +271,6 @@ $(lduMatrix)/solvers/diagonalSolver/diagonalSolver.C $(lduMatrix)/solvers/smoothSolver/smoothSolver.C $(lduMatrix)/solvers/PCG/PCG.C $(lduMatrix)/solvers/PBiCG/PBiCG.C -$(lduMatrix)/solvers/ICCG/ICCG.C -$(lduMatrix)/solvers/BICCG/BICCG.C $(lduMatrix)/smoothers/GaussSeidel/GaussSeidelSmoother.C $(lduMatrix)/smoothers/symGaussSeidel/symGaussSeidelSmoother.C diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C deleted file mode 100644 index 4fa781ffb41..00000000000 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C +++ /dev/null @@ -1,113 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "BICCG.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(BICCG, 0); - - lduMatrix::solver::addasymMatrixConstructorToTable<BICCG> - addBICCGSymMatrixConstructorToTable_; -} - - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -Foam::dictionary Foam::BICCG::solverDict -( - const scalar tol, - const scalar relTol -) -{ - dictionary dict(IStringStream("solver PBiCG; preconditioner DILU;")()); - dict.add("tolerance", tol); - dict.add("relTol", relTol); - - return dict; -} - - -Foam::dictionary Foam::BICCG::solverDict -( - Istream& is -) -{ - scalar tol(readScalar(is)); - scalar relTol(readScalar(is)); - - return solverDict(tol, relTol); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::BICCG::BICCG -( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const dictionary& solverControls -) -: - PBiCG - ( - fieldName, - matrix, - interfaceBouCoeffs, - interfaceIntCoeffs, - interfaces, - solverControls - ) -{} - - -Foam::BICCG::BICCG -( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol -) -: - PBiCG - ( - fieldName, - matrix, - interfaceBouCoeffs, - interfaceIntCoeffs, - interfaces, - solverDict(tolerance, relTol) - ) -{} - -// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H deleted file mode 100644 index 68a792c3795..00000000000 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H +++ /dev/null @@ -1,127 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::BICCG - -Description - Diagonal incomplete LU preconditioned BiCG solver derived from the general - preconditioned BiCG solver PBiCG but with the choice of preconditioner - pre-selected. - -Deprecated - This solver is present for backward-compatibility and the PBiCG solver - should be used instead. (deprecated Apr 2008) - -SourceFiles - BICCG.C - -\*---------------------------------------------------------------------------*/ - -#ifndef BICCG_H -#define BICCG_H - -#include "PBiCG.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class BICCG Declaration -\*---------------------------------------------------------------------------*/ - -class BICCG -: - public PBiCG -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - BICCG(const BICCG&); - - //- Disallow default bitwise assignment - void operator=(const BICCG&); - -public: - - //- Return the dictionary constructed from the components. - // Needed for backward compatibility - static dictionary solverDict - ( - const scalar tol, - const scalar relTol - ); - - //- Return the dictionary constructed from the old-style data-stream. - // Needed for backward compatibility - static dictionary solverDict(Istream&); - - - //- Runtime type information - TypeName("BICCG"); - - - // Constructors - - //- Construct from matrix components and solver data stream - BICCG - ( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const dictionary& solverControls - ); - - - //- Construct from matrix components and tolerances - BICCG - ( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol = 0.0 - ); - - //- Destructor - virtual ~BICCG() - {} - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H index 9e220067d17..4a2990cc540 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H @@ -39,7 +39,7 @@ Description - Coarse matrix scaling: performed by correction scaling, using steepest descent optimisation. - Type of cycle: V-cycle with optional pre-smoothing. - - Coarsest-level matrix solved using ICCG or BICCG. + - Coarsest-level matrix solved using PCG or PBiCG. SourceFiles GAMGSolver.C @@ -234,7 +234,7 @@ class GAMGSolver ) const; //- Interpolate the correction after injected prolongation and - /// re-normalise + // re-normalise void interpolate ( scalarField& psi, @@ -292,6 +292,21 @@ class GAMGSolver const direction cmpt=0 ) const; + //- Create and return the dictionary to specify the PCG solver + // to solve the coarsest level + dictionary PCGsolverDict + ( + const scalar tol, + const scalar relTol + ) const; + + //- Create and return the dictionary to specify the PBiCG solver + // to solve the coarsest level + dictionary PBiCGsolverDict + ( + const scalar tol, + const scalar relTol + ) const; //- Solve the coarsest level with either an iterative or direct solver void solveCoarsestLevel diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C index 03a6d111074..fbd1b401798 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C @@ -24,8 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "GAMGSolver.H" -#include "ICCG.H" -#include "BICCG.H" +#include "PCG.H" +#include "PBiCG.H" #include "SubField.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -519,6 +519,34 @@ void Foam::GAMGSolver::initVcycle } +Foam::dictionary Foam::GAMGSolver::PCGsolverDict +( + const scalar tol, + const scalar relTol +) const +{ + dictionary dict(IStringStream("solver PCG; preconditioner DIC;")()); + dict.add("tolerance", tol); + dict.add("relTol", relTol); + + return dict; +} + + +Foam::dictionary Foam::GAMGSolver::PBiCGsolverDict +( + const scalar tol, + const scalar relTol +) const +{ + dictionary dict(IStringStream("solver PBiCG; preconditioner DILU;")()); + dict.add("tolerance", tol); + dict.add("relTol", relTol); + + return dict; +} + + void Foam::GAMGSolver::solveCoarsestLevel ( scalarField& coarsestCorrField, @@ -584,15 +612,14 @@ void Foam::GAMGSolver::solveCoarsestLevel // // if (allMatrix.asymmetric()) // { - // coarseSolverPerf = BICCG + // coarseSolverPerf = PBiCG // ( // "coarsestLevelCorr", // allMatrix, // procInterfaceLevelsBouCoeffs_[coarsestLevel], // procInterfaceLevelsIntCoeffs_[coarsestLevel], // procInterfaceLevels_[coarsestLevel], - // tolerance_, - // relTol_ + // PBiCGsolverDict(tolerance_, relTol_) // ).solve // ( // coarsestCorrField, @@ -601,15 +628,14 @@ void Foam::GAMGSolver::solveCoarsestLevel // } // else // { - // coarseSolverPerf = ICCG + // coarseSolverPerf = PCG // ( // "coarsestLevelCorr", // allMatrix, // procInterfaceLevelsBouCoeffs_[coarsestLevel], // procInterfaceLevelsIntCoeffs_[coarsestLevel], // procInterfaceLevels_[coarsestLevel], - // tolerance_, - // relTol_ + // PCGsolverDict(tolerance_, relTol_) // ).solve // ( // coarsestCorrField, @@ -647,15 +673,14 @@ void Foam::GAMGSolver::solveCoarsestLevel if (matrixLevels_[coarsestLevel].asymmetric()) { - coarseSolverPerf = BICCG + coarseSolverPerf = PBiCG ( "coarsestLevelCorr", matrixLevels_[coarsestLevel], interfaceLevelsBouCoeffs_[coarsestLevel], interfaceLevelsIntCoeffs_[coarsestLevel], interfaceLevels_[coarsestLevel], - tolerance_, - relTol_ + PBiCGsolverDict(tolerance_, relTol_) ).solve ( coarsestCorrField, @@ -664,15 +689,14 @@ void Foam::GAMGSolver::solveCoarsestLevel } else { - coarseSolverPerf = ICCG + coarseSolverPerf = PCG ( "coarsestLevelCorr", matrixLevels_[coarsestLevel], interfaceLevelsBouCoeffs_[coarsestLevel], interfaceLevelsIntCoeffs_[coarsestLevel], interfaceLevels_[coarsestLevel], - tolerance_, - relTol_ + PCGsolverDict(tolerance_, relTol_) ).solve ( coarsestCorrField, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C deleted file mode 100644 index 6ebd2725ecb..00000000000 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C +++ /dev/null @@ -1,111 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "ICCG.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(ICCG, 0); - - lduMatrix::solver::addsymMatrixConstructorToTable<ICCG> - addICCGSymMatrixConstructorToTable_; -} - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -Foam::dictionary Foam::ICCG::solverDict -( - const scalar tol, - const scalar relTol -) -{ - dictionary dict(IStringStream("solver PCG; preconditioner DIC;")()); - dict.add("tolerance", tol); - dict.add("relTol", relTol); - - return dict; -} - - -Foam::dictionary Foam::ICCG::solverDict -( - Istream& is -) -{ - scalar tol(readScalar(is)); - scalar relTol(readScalar(is)); - - return solverDict(tol, relTol); -} - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::ICCG::ICCG -( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const dictionary& solverControls -) -: - PCG - ( - fieldName, - matrix, - interfaceBouCoeffs, - interfaceIntCoeffs, - interfaces, - solverControls - ) -{} - - -Foam::ICCG::ICCG -( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol -) -: - PCG - ( - fieldName, - matrix, - interfaceBouCoeffs, - interfaceIntCoeffs, - interfaces, - solverDict(tolerance, relTol) - ) -{} - -// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H deleted file mode 100644 index f3cf016461d..00000000000 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H +++ /dev/null @@ -1,126 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::ICCG - -Description - Incomplete Cholesky preconditioned CG solver derived from the general - preconditioned CG solver PCG but with the choice of preconditioner - pre-selected. - -Deprecated - This solver is present for backward-compatibility and the PCG solver - should be used for preference. (deprecated Apr 2008) - -SourceFiles - ICCG.C - -\*---------------------------------------------------------------------------*/ - -#ifndef ICCG_H -#define ICCG_H - -#include "PCG.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class ICCG Declaration -\*---------------------------------------------------------------------------*/ - -class ICCG -: - public PCG -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - ICCG(const ICCG&); - - //- Disallow default bitwise assignment - void operator=(const ICCG&); - -public: - - //- Return the dictionary constructed from the components. - // Needed for backward compatibility - static dictionary solverDict - ( - const scalar tol, - const scalar relTol - ); - - //- Return the dictionary constructed from the old-style data-stream. - // Needed for backward compatibility - static dictionary solverDict(Istream&); - - - //- Runtime type information - TypeName("ICCG"); - - - // Constructors - - //- Construct from matrix components and solver data stream - ICCG - ( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const dictionary& solverControls - ); - - //- Construct from matrix components and tolerances - ICCG - ( - const word& fieldName, - const lduMatrix& matrix, - const FieldField<Field, scalar>& interfaceBouCoeffs, - const FieldField<Field, scalar>& interfaceIntCoeffs, - const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol = 0.0 - ); - - //- Destructor - virtual ~ICCG() - {} - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 72725c9e991..9a8c7f9aea1 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -26,11 +26,6 @@ License #include "solution.H" #include "Time.H" -// These are for old syntax compatibility: -#include "BICCG.H" -#include "ICCG.H" -#include "IStringStream.H" - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam @@ -185,48 +180,34 @@ Foam::label Foam::solution::upgradeSolverDict word name(is); dictionary subdict; - if (name == "BICCG") - { - // special treatment for very old syntax - subdict = BICCG::solverDict(is); - } - else if (name == "ICCG") - { - // special treatment for very old syntax - subdict = ICCG::solverDict(is); - } - else + subdict.add("solver", name); + subdict <<= dictionary(is); + + // preconditioner and smoother entries can be + // 1) primitiveEntry w/o settings, + // 2) or a dictionaryEntry. + // transform primitiveEntry with settings -> dictionaryEntry + forAll(subDictNames, dictI) { - subdict.add("solver", name); - subdict <<= dictionary(is); - - // preconditioner and smoother entries can be - // 1) primitiveEntry w/o settings, - // 2) or a dictionaryEntry. - // transform primitiveEntry with settings -> dictionaryEntry - forAll(subDictNames, dictI) + const word& dictName = subDictNames[dictI]; + entry* ePtr = subdict.lookupEntryPtr(dictName,false,false); + + if (ePtr && !ePtr->isDict()) { - const word& dictName = subDictNames[dictI]; - entry* ePtr = subdict.lookupEntryPtr(dictName,false,false); + Istream& is = ePtr->stream(); + is >> name; - if (ePtr && !ePtr->isDict()) + if (!is.eof()) { - Istream& is = ePtr->stream(); - is >> name; + dictionary newDict; + newDict.add(dictName, name); + newDict <<= dictionary(is); - if (!is.eof()) - { - dictionary newDict; - newDict.add(dictName, name); - newDict <<= dictionary(is); - - subdict.set(dictName, newDict); - } + subdict.set(dictName, newDict); } } } - // write out information to help people adjust to the new syntax if (verbose && Pstream::master()) { -- GitLab