From 3b92eea748b013bd06640ad59126ecb06a157095 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Sun, 11 Oct 2015 12:41:19 +0100 Subject: [PATCH] Feature: linear solver update: ILUp and two-level AMG smoothers --- .../processor/processorFvPatchField.H | 19 +++++-- .../fvMesh/fvMeshSubset/fvMeshSubset.C | 2 +- src/foam/Make/files | 1 + .../GeometricField/GeometricBoundaryField.C | 30 +++++------ .../BlockAmg/coarseBlockAmgLevel.C | 3 +- .../BlockAmg/fineBlockAmgLevel.C | 3 +- .../BlockLduMatrixUpdateInterfaces.C | 43 ++++++++++------ .../BlockILUCpPrecon/BlockILUCpPrecon.H | 3 +- .../BlockLduPrecon/BlockLduPrecon.C | 31 ++---------- .../BlockLduPrecon/BlockLduPrecon.H | 9 +--- .../BlockILUSmoother/BlockILUSmoother.H | 4 +- .../BlockLduSmoother/BlockLduSmoother.C | 46 +++++++---------- .../BlockLduSmoother/BlockLduSmoother.H | 9 +--- .../BlockLduSolvers/blockVectorNSolvers.C | 4 ++ .../processorLduInterfaceTemplates.C | 4 +- .../lduInterfaceField/lduInterfaceField.H | 30 +++++++++-- .../matrices/lduMatrix/lduMatrix/lduMatrix.H | 18 ++++--- .../lduMatrix/lduMatrixPreconditioner.C | 32 +++--------- .../lduMatrix/lduMatrix/lduMatrixSmoother.C | 29 ++--------- .../lduMatrixUpdateMatrixInterfaces.C | 50 +++++++++++-------- .../matrices/lduMatrix/solvers/PBiCG/PBiCG.C | 10 ++-- src/foam/matrices/lduMatrix/solvers/PCG/PCG.C | 9 ++-- .../lduSolver/bicgSolver/bicgSolver.C | 6 ++- src/lduSolvers/lduSolver/cgSolver/cgSolver.C | 6 ++- .../lduSolver/gmresSolver/gmresSolver.C | 5 +- .../constant/polyMesh/boundary | 2 +- .../system/fvSolution | 3 +- .../system/fvSolution | 3 +- .../pUCoupledFoam/cavity/system/fvSolution | 3 +- 29 files changed, 200 insertions(+), 217 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H index 0bc66d4b8..37c7c9b7a 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H @@ -25,7 +25,17 @@ Class Foam::processorFvPatchField Description - Foam::processorFvPatchField + This boundary condition enables processor communication across patches. + + \heading Patch usage + + Example of the boundary condition specification: + \verbatim + myPatch + { + type processor; + } + \endverbatim SourceFiles processorFvPatchField.C @@ -45,7 +55,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class processorFvPatchField Declaration + Class processorFvPatchField Declaration \*---------------------------------------------------------------------------*/ template @@ -132,9 +142,8 @@ public: } - // Destructor - - ~processorFvPatchField(); + //- Destructor + ~processorFvPatchField(); // Member functions diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C index 74330e251..2ad349c64 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C @@ -910,7 +910,7 @@ void Foam::fvMeshSubset::setLargeCellSubset // 3: face coupled and used by one cell only (so should become normal, // non-coupled patch face) // - // Note that this is not really nessecary - but means we can size things + // Note that this is not really necessary - but means we can size things // correctly. Also makes handling coupled faces much easier. labelList nCellsUsingFace(oldFaces.size(), 0); diff --git a/src/foam/Make/files b/src/foam/Make/files index caaa327fe..012816086 100644 --- a/src/foam/Make/files +++ b/src/foam/Make/files @@ -711,6 +711,7 @@ matrices/blockLduMatrix/BlockLduPrecons/BlockILUCpPrecon/blockILUCpPrecons.C matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/blockLduSmoothers.C matrices/blockLduMatrix/BlockLduSmoothers/BlockGaussSeidelSmoother/blockGaussSeidelSmoothers.C matrices/blockLduMatrix/BlockLduSmoothers/BlockILUSmoother/blockILUSmoothers.C +matrices/blockLduMatrix/BlockLduSmoothers/BlockILUCpSmoother/blockILUCpSmoothers.C /* compile blockVectorNSolvers earlier to exploit parallelismn */ matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C diff --git a/src/foam/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/foam/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 418d24425..8909076bf 100644 --- a/src/foam/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/foam/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -287,20 +287,20 @@ evaluate() if ( - Pstream::defaultCommsType() == Pstream::blocking - || Pstream::defaultCommsType() == Pstream::nonBlocking + Pstream::defaultComms() == Pstream::blocking + || Pstream::defaultComms() == Pstream::nonBlocking ) { forAll(*this, patchi) { this->operator[](patchi).initEvaluate ( - static_cast(Pstream::defaultCommsType()) + Pstream::defaultComms() ); } // Block for any outstanding requests - if (Pstream::defaultCommsType() == Pstream::nonBlocking) + if (Pstream::defaultComms() == Pstream::nonBlocking) { IPstream::waitRequests(); OPstream::waitRequests(); @@ -310,11 +310,11 @@ evaluate() { this->operator[](patchi).evaluate ( - static_cast(Pstream::defaultCommsType()) + Pstream::defaultComms() ); } } - else if (Pstream::defaultCommsType() == Pstream::scheduled) + else if (Pstream::defaultComms() == Pstream::scheduled) { const lduSchedule& patchSchedule = bmesh_.mesh().globalData().patchSchedule(); @@ -356,8 +356,8 @@ evaluateCoupled() if ( - Pstream::defaultCommsType() == Pstream::blocking - || Pstream::defaultCommsType() == Pstream::nonBlocking + Pstream::defaultComms() == Pstream::blocking + || Pstream::defaultComms() == Pstream::nonBlocking ) { forAll(*this, patchi) @@ -366,16 +366,13 @@ evaluateCoupled() { this->operator[](patchi).initEvaluate ( - static_cast - ( - Pstream::defaultCommsType() - ) + Pstream::defaultComms() ); } } // Block for any outstanding requests - if (Pstream::defaultCommsType() == Pstream::nonBlocking) + if (Pstream::defaultComms() == Pstream::nonBlocking) { IPstream::waitRequests(); OPstream::waitRequests(); @@ -387,15 +384,12 @@ evaluateCoupled() { this->operator[](patchi).evaluate ( - static_cast - ( - Pstream::defaultCommsType() - ) + Pstream::defaultComms() ); } } } - else if (Pstream::defaultCommsType() == Pstream::scheduled) + else if (Pstream::defaultComms() == Pstream::scheduled) { const lduSchedule& patchSchedule = bmesh_.mesh().globalData().patchSchedule(); diff --git a/src/foam/matrices/blockLduMatrix/BlockAmg/coarseBlockAmgLevel.C b/src/foam/matrices/blockLduMatrix/BlockAmg/coarseBlockAmgLevel.C index c8d291ae9..2f7cd9d72 100644 --- a/src/foam/matrices/blockLduMatrix/BlockAmg/coarseBlockAmgLevel.C +++ b/src/foam/matrices/blockLduMatrix/BlockAmg/coarseBlockAmgLevel.C @@ -76,7 +76,8 @@ Foam::coarseBlockAmgLevel::coarseBlockAmgLevel BlockLduSmoother::New ( matrixPtr_, - dict + dict, + "coarseSmoother" ) ), Ax_() diff --git a/src/foam/matrices/blockLduMatrix/BlockAmg/fineBlockAmgLevel.C b/src/foam/matrices/blockLduMatrix/BlockAmg/fineBlockAmgLevel.C index 0b91ee881..14bfbc773 100644 --- a/src/foam/matrices/blockLduMatrix/BlockAmg/fineBlockAmgLevel.C +++ b/src/foam/matrices/blockLduMatrix/BlockAmg/fineBlockAmgLevel.C @@ -71,7 +71,8 @@ Foam::fineBlockAmgLevel::fineBlockAmgLevel BlockLduSmoother::New ( matrix, - dict + dict, + "fineSmoother" ) ), Ax_() diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/BlockLduMatrixUpdateInterfaces.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/BlockLduMatrixUpdateInterfaces.C index 089c4e76c..f80d2d1e6 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/BlockLduMatrixUpdateInterfaces.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/BlockLduMatrixUpdateInterfaces.C @@ -41,8 +41,8 @@ void Foam::BlockLduMatrix::initInterfaces { if ( - Pstream::defaultCommsType() == Pstream::blocking - || Pstream::defaultCommsType() == Pstream::nonBlocking + Pstream::defaultComms() == Pstream::blocking + || Pstream::defaultComms() == Pstream::nonBlocking ) { forAll (interfaces_, interfaceI) @@ -55,13 +55,13 @@ void Foam::BlockLduMatrix::initInterfaces result, *this, interfaceCoeffs[interfaceI], - static_cast(Pstream::defaultCommsType()), + Pstream::defaultComms(), switchToLhs ); } } } - else if (Pstream::defaultCommsType() == Pstream::scheduled) + else if (Pstream::defaultComms() == Pstream::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); @@ -107,18 +107,29 @@ void Foam::BlockLduMatrix::updateInterfaces const bool switchToLhs ) const { - if - ( - Pstream::defaultCommsType() == Pstream::blocking - || Pstream::defaultCommsType() == Pstream::nonBlocking - ) + if (Pstream::defaultComms() == Pstream::blocking) + { + forAll (interfaces_, interfaceI) + { + if (interfaces_.set(interfaceI)) + { + interfaces_[interfaceI].updateInterfaceMatrix + ( + psi, + result, + *this, + interfaceCoeffs[interfaceI], + Pstream::defaultComms(), + switchToLhs + ); + } + } + } + else if (Pstream::defaultComms() == Pstream::nonBlocking) { // Block until all sends/receives have been finished - if (Pstream::defaultCommsType() == Pstream::nonBlocking) - { - IPstream::waitRequests(); - OPstream::waitRequests(); - } + IPstream::waitRequests(); + OPstream::waitRequests(); forAll (interfaces_, interfaceI) { @@ -130,13 +141,13 @@ void Foam::BlockLduMatrix::updateInterfaces result, *this, interfaceCoeffs[interfaceI], - static_cast(Pstream::defaultCommsType()), + Pstream::defaultComms(), switchToLhs ); } } } - else if (Pstream::defaultCommsType() == Pstream::scheduled) + else if (Pstream::defaultComms() == Pstream::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); diff --git a/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockILUCpPrecon/BlockILUCpPrecon.H b/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockILUCpPrecon/BlockILUCpPrecon.H index f56a371f9..dc020ebbd 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockILUCpPrecon/BlockILUCpPrecon.H +++ b/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockILUCpPrecon/BlockILUCpPrecon.H @@ -127,7 +127,8 @@ class BlockILUCpPrecon const Field& b ) const; - //- Execute preconditioning with matrix transpose, decoupled version + //- Execute preconditioning with matrix transpose, + // decoupled version void decoupledPreconditionT ( Field& xT, diff --git a/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.C b/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.C index 350be88a3..4d92203a0 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.C @@ -35,16 +35,17 @@ template Foam::autoPtr > Foam::BlockLduPrecon::New ( const BlockLduMatrix& matrix, - const dictionary& dict + const dictionary& dict, + const word keyword ) { word preconName; - // handle primitive or dictionary entry - const entry& e = dict.lookupEntry("preconditioner", false, false); + // Handle primitive or dictionary entry + const entry& e = dict.lookupEntry(keyword, false, false); if (e.isDict()) { - e.dict().lookup("preconditioner") >> preconName; + e.dict().lookup(keyword) >> preconName; } else { @@ -99,26 +100,4 @@ Foam::autoPtr > Foam::BlockLduPrecon::New } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Foam::word Foam::BlockLduPrecon::getName(const dictionary& dict) -{ - word name; - - // handle primitive or dictionary entry - const entry& e = dict.lookupEntry("preconditioner", false, false); - if (e.isDict()) - { - e.dict().lookup("preconditioner") >> name; - } - else - { - e.stream() >> name; - } - - return name; -} - - // ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.H b/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.H index 50f396d79..48480fafd 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.H +++ b/src/foam/matrices/blockLduMatrix/BlockLduPrecons/BlockLduPrecon/BlockLduPrecon.H @@ -69,12 +69,6 @@ protected: const BlockLduMatrix& matrix_; - // Protected member functions - - //- Find the smoother name (directly or from a sub-dictionary) - static word getName(const dictionary&); - - public: //- Runtime type information @@ -114,7 +108,8 @@ public: static autoPtr > New ( const BlockLduMatrix& matrix, - const dictionary& dict + const dictionary& dict, + const word keyword = word("preconditioner") ); diff --git a/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockILUSmoother/BlockILUSmoother.H b/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockILUSmoother/BlockILUSmoother.H index 9e4bb7aa7..9ec7227b1 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockILUSmoother/BlockILUSmoother.H +++ b/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockILUSmoother/BlockILUSmoother.H @@ -25,7 +25,7 @@ Class BlockILUSmoother Description - Gauss-Seidel smoother + ILU smoother SourceFiles blockILUSmoothers.C @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class BlockILUSmoother Declaration + Class BlockILUSmoother Declaration \*---------------------------------------------------------------------------*/ template diff --git a/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.C b/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.C index 4f9cc1e00..7ee80d266 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.C @@ -40,13 +40,24 @@ template Foam::autoPtr > Foam::BlockLduSmoother::New ( const BlockLduMatrix& matrix, - const dictionary& dict + const dictionary& dict, + const word keyword ) { - word smootherName = getName(dict); + word smootherName; - // Not (yet?) needed: - // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null; + // Handle primitive or dictionary entry + const entry& e = dict.lookupEntry(keyword, false, false); + if (e.isDict()) + { + e.dict().lookup(keyword) >> smootherName; + } + else + { + e.stream() >> smootherName; + } + + const dictionary& controls = e.isDict() ? e.dict() : dictionary::null; typename dictionaryConstructorTable::iterator constructorIter = dictionaryConstructorTablePtr_->find(smootherName); @@ -58,7 +69,8 @@ Foam::autoPtr > Foam::BlockLduSmoother::New "autoPtr BlockLduSmoother::New\n" "(\n" " const BlockLduMatrix& matrix,\n" - " const dictionary& dict\n" + " const dictionary& dict,\n" + " const word keyword\n" ")", dict ) << "Unknown matrix smoother " << smootherName @@ -73,32 +85,10 @@ Foam::autoPtr > Foam::BlockLduSmoother::New constructorIter() ( matrix, - dict + controls ) ); } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Foam::word Foam::BlockLduSmoother::getName(const dictionary& dict) -{ - word name; - - // handle primitive or dictionary entry - const entry& e = dict.lookupEntry("smoother", false, false); - if (e.isDict()) - { - e.dict().lookup("smoother") >> name; - } - else - { - e.stream() >> name; - } - - return name; -} - - // ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.H b/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.H index 09737a02f..e966dfce4 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.H +++ b/src/foam/matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/BlockLduSmoother.H @@ -66,12 +66,6 @@ protected: const BlockLduMatrix& matrix_; - // Protected member functions - - //- Find the smoother name (directly or from a sub-dictionary) - static word getName(const dictionary&); - - public: //- Runtime type information @@ -111,7 +105,8 @@ public: static autoPtr > New ( const BlockLduMatrix& matrix, - const dictionary& dict + const dictionary& dict, + const word keyword = word("smoother") ); diff --git a/src/foam/matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C b/src/foam/matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C index 216bff2cc..e17f6e1e0 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C @@ -36,6 +36,7 @@ License #include "blockLduSmoothers.H" #include "blockGaussSeidelSmoothers.H" #include "BlockILUSmoother.H" +#include "BlockILUCpSmoother.H" #include "blockLduSolvers.H" #include "BlockDiagonalSolver.H" @@ -98,6 +99,9 @@ makeBlockSmoother(block##Type##Smoother, block##Type##GaussSeidelSmoother); \ typedef BlockILUSmoother block##Type##ILUSmoother; \ makeBlockSmoother(block##Type##Smoother, block##Type##ILUSmoother); \ \ +typedef BlockILUCpSmoother block##Type##ILUCpSmoother; \ +makeBlockSmoother(block##Type##Smoother, block##Type##ILUCpSmoother); \ + \ \ /* Solvers */ \ typedef BlockLduSolver block##Type##Solver; \ diff --git a/src/foam/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C b/src/foam/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C index 3426c7db1..8dad0f99d 100644 --- a/src/foam/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C +++ b/src/foam/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C @@ -128,7 +128,7 @@ void Foam::processorLduInterface::compressedSend const UList& f ) const { - if (sizeof(scalar) != sizeof(float) && Pstream::floatTransfer && f.size()) + if (sizeof(scalar) != sizeof(float) && f.size()) { static const label nCmpts = sizeof(Type)/sizeof(scalar); label nm1 = (f.size() - 1)*nCmpts; @@ -198,7 +198,7 @@ void Foam::processorLduInterface::compressedReceive UList& f ) const { - if (sizeof(scalar) != sizeof(float) && Pstream::floatTransfer && f.size()) + if (sizeof(scalar) != sizeof(float) && f.size()) { static const label nCmpts = sizeof(Type)/sizeof(scalar); label nm1 = (f.size() - 1)*nCmpts; diff --git a/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H b/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H index 2fb68951f..632b942fd 100644 --- a/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H +++ b/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H @@ -59,6 +59,10 @@ class lduInterfaceField //- Reference to the coupled patch this field is defined for const lduInterface& coupledInterface_; + //- Update index used so that updateInterfaceMatrix is called only once + // during the construction of the matrix + bool updatedMatrix_; + // Private Member Functions @@ -80,13 +84,13 @@ public: //- Construct given coupled patch lduInterfaceField(const lduInterface& patch) : - coupledInterface_(patch) + coupledInterface_(patch), + updatedMatrix_(false) {} - // Destructor - - virtual ~lduInterfaceField(); + //- Destructor + virtual ~lduInterfaceField(); // Member Functions @@ -108,6 +112,24 @@ public: // Coupled interface matrix update + //- Whether matrix has been updated + bool updatedMatrix() const + { + return updatedMatrix_; + } + + //- Whether matrix has been updated + bool& updatedMatrix() + { + return updatedMatrix_; + } + + //- Is all data available + virtual bool ready() const + { + return true; + } + //- Transform neighbour field virtual void transformCoupleField ( diff --git a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrix.H index 6a0034ac9..64054d161 100644 --- a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -165,6 +165,12 @@ public: return solverName_; } + //- Return access to solver name + word& solverName() + { + return solverName_; + } + //- Return initial residual scalar initialResidual() const { @@ -485,9 +491,6 @@ public: public: - //- Find the smoother name (directly or from a sub-dictionary) - static word getName(const dictionary&); - //- Runtime type information virtual const word& type() const = 0; @@ -553,7 +556,8 @@ public: const FieldField& coupleBouCoeffs, const FieldField& coupleIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const dictionary& dict + const dictionary& dict, + const word keyword = word("smoother") ); @@ -621,9 +625,6 @@ public: public: - //- Find the preconditioner name (directly or from a sub-dictionary) - static word getName(const dictionary&); - //- Runtime type information virtual const word& type() const = 0; @@ -693,7 +694,8 @@ public: const FieldField& coupleBouCoeffs, const FieldField& coupleIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const dictionary& dict + const dictionary& dict, + const word keyword = word("preconditioner") ); diff --git a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C index d98c6da28..f18c936db 100644 --- a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C +++ b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C @@ -36,28 +36,6 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::word Foam::lduMatrix::preconditioner::getName -( - const dictionary& dict -) -{ - word name; - - // handle primitive or dictionary entry - const entry& e = dict.lookupEntry("preconditioner", false, false); - if (e.isDict()) - { - e.dict().lookup("preconditioner") >> name; - } - else - { - e.stream() >> name; - } - - return name; -} - - Foam::autoPtr Foam::lduPreconditioner::New ( @@ -65,16 +43,17 @@ Foam::lduPreconditioner::New const FieldField& coupleBouCoeffs, const FieldField& coupleIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const dictionary& dict + const dictionary& dict, + const word keyword ) { word preconName; // handle primitive or dictionary entry - const entry& e = dict.lookupEntry("preconditioner", false, false); + const entry& e = dict.lookupEntry(keyword, false, false); if (e.isDict()) { - e.dict().lookup("preconditioner") >> preconName; + e.dict().lookup(keyword) >> preconName; } else { @@ -98,7 +77,8 @@ Foam::lduPreconditioner::New " const FieldField& coupleBouCoeffs,\n" " const FieldField& coupleIntCoeffs,\n" " const lduInterfaceFieldPtrsList& interfaces,\n" - " const dictionary& dict\n" + " const dictionary& dict,\n" + " const word keyword\n" ")", dict ) << "Unknown symmetric matrix preconditioner " diff --git a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C index eb96837c8..53f09ce8b 100644 --- a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C +++ b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C @@ -36,44 +36,23 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::word Foam::lduMatrix::smoother::getName -( - const dictionary& dict -) -{ - word name; - - // handle primitive or dictionary entry - const entry& e = dict.lookupEntry("smoother", false, false); - if (e.isDict()) - { - e.dict().lookup("smoother") >> name; - } - else - { - e.stream() >> name; - } - - return name; -} - - Foam::autoPtr Foam::lduMatrix::smoother::New ( const lduMatrix& matrix, const FieldField& coupleBouCoeffs, const FieldField& coupleIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const dictionary& dict + const dictionary& dict, + const word keyword ) { word smootherName; // Handle primitive or dictionary entry - const entry& e = dict.lookupEntry("smoother", false, false); + const entry& e = dict.lookupEntry(keyword, false, false); if (e.isDict()) { - e.dict().lookup("smoother") >> smootherName; + e.dict().lookup(keyword) >> smootherName; } else { diff --git a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C index 90afa8b84..ca3f218e2 100644 --- a/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C +++ b/src/foam/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C @@ -39,8 +39,8 @@ void Foam::lduMatrix::initMatrixInterfaces { if ( - Pstream::defaultCommsType() == Pstream::blocking - || Pstream::defaultCommsType() == Pstream::nonBlocking + Pstream::defaultComms() == Pstream::blocking + || Pstream::defaultComms() == Pstream::nonBlocking ) { forAll (interfaces, interfaceI) @@ -54,16 +54,13 @@ void Foam::lduMatrix::initMatrixInterfaces *this, coupleCoeffs[interfaceI], cmpt, - static_cast - ( - Pstream::defaultCommsType() - ), + Pstream::defaultComms(), switchToLhs ); } } } - else if (Pstream::defaultCommsType() == Pstream::scheduled) + else if (Pstream::defaultComms() == Pstream::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); @@ -111,18 +108,32 @@ void Foam::lduMatrix::updateMatrixInterfaces const bool switchToLhs ) const { - if - ( - Pstream::defaultCommsType() == Pstream::blocking - || Pstream::defaultCommsType() == Pstream::nonBlocking - ) + if (Pstream::defaultComms() == Pstream::blocking) { - // Block until all sends/receives have been finished - if (Pstream::defaultCommsType() == Pstream::nonBlocking) + forAll (interfaces, interfaceI) { - IPstream::waitRequests(); - OPstream::waitRequests(); + if (interfaces.set(interfaceI)) + { + interfaces[interfaceI].updateInterfaceMatrix + ( + psiif, + result, + *this, + coupleCoeffs[interfaceI], + cmpt, + Pstream::defaultComms(), + switchToLhs + ); + } } + } + else if (Pstream::defaultComms() == Pstream::nonBlocking) + { + // FOAM-3.1 implementation + + // Block until all sends/receives have been finished + IPstream::waitRequests(); + OPstream::waitRequests(); forAll (interfaces, interfaceI) { @@ -135,16 +146,13 @@ void Foam::lduMatrix::updateMatrixInterfaces *this, coupleCoeffs[interfaceI], cmpt, - static_cast - ( - Pstream::defaultCommsType() - ), + Pstream::defaultComms(), switchToLhs ); } } } - else if (Pstream::defaultCommsType() == Pstream::scheduled) + else if (Pstream::defaultComms() == Pstream::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); diff --git a/src/foam/matrices/lduMatrix/solvers/PBiCG/PBiCG.C b/src/foam/matrices/lduMatrix/solvers/PBiCG/PBiCG.C index c489dc816..b3f7f6447 100644 --- a/src/foam/matrices/lduMatrix/solvers/PBiCG/PBiCG.C +++ b/src/foam/matrices/lduMatrix/solvers/PBiCG/PBiCG.C @@ -70,12 +70,7 @@ Foam::lduSolverPerformance Foam::PBiCG::solve ) const { // --- Setup class containing solver performance data - lduSolverPerformance solverPerf - ( - lduMatrix::preconditioner::getName(dict()) + typeName, - fieldName() - ); - + lduSolverPerformance solverPerf(typeName, fieldName()); register label nCells = x.size(); @@ -134,6 +129,9 @@ Foam::lduSolverPerformance Foam::PBiCG::solve dict() ); + // Rename the solver pefformance to include precon name + solverPerf.solverName() = preconPtr->type() + typeName; + // Solver iteration do { diff --git a/src/foam/matrices/lduMatrix/solvers/PCG/PCG.C b/src/foam/matrices/lduMatrix/solvers/PCG/PCG.C index 33899037d..3214760d0 100644 --- a/src/foam/matrices/lduMatrix/solvers/PCG/PCG.C +++ b/src/foam/matrices/lduMatrix/solvers/PCG/PCG.C @@ -70,11 +70,7 @@ Foam::lduSolverPerformance Foam::PCG::solve ) const { // --- Setup class containing solver performance data - lduSolverPerformance solverPerf - ( - lduMatrix::preconditioner::getName(dict()) + typeName, - fieldName() - ); + lduSolverPerformance solverPerf(typeName, fieldName()); register label nCells = x.size(); @@ -124,6 +120,9 @@ Foam::lduSolverPerformance Foam::PCG::solve dict() ); + // Rename the solver pefformance to include precon name + solverPerf.solverName() = preconPtr->type() + typeName; + // Solver iteration do { diff --git a/src/lduSolvers/lduSolver/bicgSolver/bicgSolver.C b/src/lduSolvers/lduSolver/bicgSolver/bicgSolver.C index f69417c1e..7379e9822 100644 --- a/src/lduSolvers/lduSolver/bicgSolver/bicgSolver.C +++ b/src/lduSolvers/lduSolver/bicgSolver/bicgSolver.C @@ -89,7 +89,11 @@ Foam::lduSolverPerformance Foam::bicgSolver::solve ) const { // Prepare solver performance - lduSolverPerformance solverPerf(typeName, fieldName()); + lduSolverPerformance solverPerf + ( + preconPtr_->type() + typeName, + fieldName() + ); scalarField wA(x.size()); scalarField rA(x.size()); diff --git a/src/lduSolvers/lduSolver/cgSolver/cgSolver.C b/src/lduSolvers/lduSolver/cgSolver/cgSolver.C index 05c2afb61..b969964c2 100644 --- a/src/lduSolvers/lduSolver/cgSolver/cgSolver.C +++ b/src/lduSolvers/lduSolver/cgSolver/cgSolver.C @@ -89,7 +89,11 @@ Foam::lduSolverPerformance Foam::cgSolver::solve ) const { // Prepare solver performance - lduSolverPerformance solverPerf(typeName, fieldName()); + lduSolverPerformance solverPerf + ( + preconPtr_->type() + typeName, + fieldName() + ); scalarField wA(x.size()); scalarField rA(x.size()); diff --git a/src/lduSolvers/lduSolver/gmresSolver/gmresSolver.C b/src/lduSolvers/lduSolver/gmresSolver/gmresSolver.C index 813f7b2e6..f2c6be4bb 100644 --- a/src/lduSolvers/lduSolver/gmresSolver/gmresSolver.C +++ b/src/lduSolvers/lduSolver/gmresSolver/gmresSolver.C @@ -125,7 +125,10 @@ Foam::lduSolverPerformance Foam::gmresSolver::solve ) const { // Prepare solver performance - lduSolverPerformance solverPerf(typeName, fieldName()); + lduSolverPerformance solverPerf + ( + preconPtr_->type() + typeName, fieldName() + ); scalarField wA(x.size()); scalarField rA(x.size()); diff --git a/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/constant/polyMesh/boundary b/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/constant/polyMesh/boundary index e324e039d..8e9b6ebe9 100644 --- a/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/constant/polyMesh/boundary +++ b/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/constant/polyMesh/boundary @@ -3,7 +3,7 @@ | \\ / F ield | foam-extend: Open Source CFD | | \\ / O peration | Version: 3.2 | | \\ / A nd | Web: http://www.foam-extend.org | -| \\/ M anipulation | | +| \\/ M anipulation | For copyright notice see file Copyright | \*---------------------------------------------------------------------------*/ FoamFile { diff --git a/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/system/fvSolution b/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/system/fvSolution index f77d51ac7..56e39e0f2 100644 --- a/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/system/fvSolution +++ b/tutorials/incompressible/pUCoupledFoam/backwardFacingStepLaminar/system/fvSolution @@ -42,7 +42,8 @@ solvers minCoarseEqns 4; nMaxLevels 100; scale on; - smoother ILU; + coarseSmoother ILU; + fineSmoother ILU; minIter 0; maxIter 100; diff --git a/tutorials/incompressible/pUCoupledFoam/backwardFacingStepTurbulent/system/fvSolution b/tutorials/incompressible/pUCoupledFoam/backwardFacingStepTurbulent/system/fvSolution index 14c5c31c4..51f7d257a 100644 --- a/tutorials/incompressible/pUCoupledFoam/backwardFacingStepTurbulent/system/fvSolution +++ b/tutorials/incompressible/pUCoupledFoam/backwardFacingStepTurbulent/system/fvSolution @@ -42,7 +42,8 @@ solvers // minCoarseEqns 4; // nMaxLevels 100; // scale on; -// smoother ILU; +// fineSmoother ILU; +// coarseSmoother k ILU; // minIter 0; // maxIter 100; diff --git a/tutorials/incompressible/pUCoupledFoam/cavity/system/fvSolution b/tutorials/incompressible/pUCoupledFoam/cavity/system/fvSolution index 0527e39b8..d8402224f 100644 --- a/tutorials/incompressible/pUCoupledFoam/cavity/system/fvSolution +++ b/tutorials/incompressible/pUCoupledFoam/cavity/system/fvSolution @@ -42,7 +42,8 @@ solvers // minCoarseEqns 4; // nMaxLevels 10; // scale on; -// smoother ILU; +// fineSmoother ILU; +// coarseSmoother k ILU; // minIter 0; // maxIter 100;