diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..f667ed655e635c2c19b58d0c8adde570766b9e96 --- /dev/null +++ b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files @@ -0,0 +1,3 @@ +foamUpgradeFvSolution.C + +EXE = $(FOAM_APPBIN)/foamUpgradeFvSolution diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/options b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C b/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C new file mode 100644 index 0000000000000000000000000000000000000000..d9e1402a34721a4b3b80b8c8b1e074dfcc881beb --- /dev/null +++ b/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + foamUpgradeFvSolution + +Description + Simple tool to upgrade the syntax of system/fvSolution::solvers + +Usage + + - foamUpgradeFvSolution [OPTION] + + @param -test \n + Suppress writing the updated fvSolution file + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "IOdictionary.H" +#include "solution.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + argList::validOptions.insert("test", ""); + +# include "setRootCase.H" +# include "createTime.H" + + IOdictionary solutionDict + ( + IOobject + ( + "fvSolution", + runTime.system(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + label nChanged = 0; + entry* e = solutionDict.lookupEntryPtr("solvers", false, false); + if (e && e->isDict()) + { + nChanged = solution::upgradeSolverDict(e->dict(), true); + } + + Info<< nChanged << " solver settings changed" << nl << endl; + if (nChanged) + { + if (args.options().found("test")) + { + Info<< "-test option: no changes made" << nl << endl; + } + else + { + mv + ( + solutionDict.objectPath(), + solutionDict.objectPath() + ".old" + ); + + solutionDict.regIOobject::write(); + + Info<< "Backup to " << (solutionDict.objectPath() + ".old") << nl + << "Write to " << solutionDict.objectPath() << nl << endl; + } + } + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 33fcda639db8e0bc5d10ac7118e27cece792139e..6a6a09ab92da785cecfddc4d153021bbf2a80db0 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -259,7 +259,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ), ( fieldName, @@ -267,7 +267,7 @@ public: interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); @@ -282,7 +282,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ), ( fieldName, @@ -290,7 +290,7 @@ public: interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); @@ -304,7 +304,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); // Selectors @@ -317,7 +317,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); @@ -359,7 +359,7 @@ public: //- Read and reset the solver parameters from the given stream - virtual void read(Istream& solverData); + virtual void read(const dictionary&); virtual solverPerformance solve ( @@ -467,7 +467,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& smootherData + const dictionary& solverControls ); @@ -531,6 +531,9 @@ 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; @@ -544,9 +547,9 @@ public: symMatrix, ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ), - (sol, preconditionerData) + (sol, solverControls) ); declareRunTimeSelectionTable @@ -556,9 +559,9 @@ public: asymMatrix, ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ), - (sol, preconditionerData) + (sol, solverControls) ); @@ -579,7 +582,7 @@ public: static autoPtr<preconditioner> New ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ); @@ -593,7 +596,7 @@ public: //- Read and reset the preconditioner parameters // from the given stream - virtual void read(Istream& preconditionerData) + virtual void read(const dictionary&) {} //- Return wA the preconditioned form of residual rA diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C index 82f9a19ac20c59a3a5e4c303cb0f0a5cb7144c33..cb4a645df1c4f30ab96bf174bdb87d8c3025ebf1 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C @@ -37,29 +37,66 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +Foam::word +Foam::lduMatrix::preconditioner::getName +( + const dictionary& solverControls +) +{ + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("preconditioner", false, false); + if (e.isDict()) + { + e.dict().lookup("preconditioner") >> name; + } + else + { + e.stream() >> name; + } + + return name; +} + + Foam::autoPtr<Foam::lduMatrix::preconditioner> Foam::lduMatrix::preconditioner::New ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ) { - word preconditionerName(preconditionerData); + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("preconditioner", false, false); + if (e.isDict()) + { + e.dict().lookup("preconditioner") >> name; + } + else + { + e.stream() >> name; + } + + const dictionary& controls = e.isDict() ? e.dict() : dictionary::null; if (sol.matrix().symmetric()) { symMatrixConstructorTable::iterator constructorIter = - symMatrixConstructorTablePtr_->find(preconditionerName); + symMatrixConstructorTablePtr_->find(name); if (constructorIter == symMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::preconditioner::New(const solver&, Istream&)", - preconditionerData + "lduMatrix::preconditioner::New" + "(const solver&, const dictionary&)", + controls ) << "Unknown symmetric matrix preconditioner " - << preconditionerName << endl << endl - << "Valid symmetric matrix preconditioners are :" << endl + << name << nl << nl + << "Valid symmetric matrix preconditioners :" << endl << symMatrixConstructorTablePtr_->toc() << exit(FatalIOError); } @@ -69,24 +106,25 @@ Foam::lduMatrix::preconditioner::New constructorIter() ( sol, - preconditionerData + controls ) ); } else if (sol.matrix().asymmetric()) { asymMatrixConstructorTable::iterator constructorIter = - asymMatrixConstructorTablePtr_->find(preconditionerName); + asymMatrixConstructorTablePtr_->find(name); if (constructorIter == asymMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::preconditioner::New(const solver&, Istream&)", - preconditionerData + "lduMatrix::preconditioner::New" + "(const solver&, const dictionary&)", + controls ) << "Unknown asymmetric matrix preconditioner " - << preconditionerName << endl << endl - << "Valid asymmetric matrix preconditioners are :" << endl + << name << nl << nl + << "Valid asymmetric matrix preconditioners :" << endl << asymMatrixConstructorTablePtr_->toc() << exit(FatalIOError); } @@ -96,7 +134,7 @@ Foam::lduMatrix::preconditioner::New constructorIter() ( sol, - preconditionerData + controls ) ); } @@ -104,9 +142,10 @@ Foam::lduMatrix::preconditioner::New { FatalIOErrorIn ( - "lduMatrix::preconditioner::New(const solver&, Istream&)", - preconditionerData - ) << "cannot preconditione incomplete matrix, " + "lduMatrix::preconditioner::New" + "(const solver&, const dictionary&)", + controls + ) << "cannot solve incomplete matrix, " "no diagonal or off-diagonal coefficient" << exit(FatalIOError); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C index 7554e4085c0e83e493b62f80f9f9ef904e8b867a..e9aa429683b5a5ca010024912da7b04827b7ec37 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C @@ -34,7 +34,6 @@ namespace Foam defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix); } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New @@ -44,23 +43,37 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& smootherData + const dictionary& solverControls ) { - word smootherName(smootherData); + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("smoother", false, false); + if (e.isDict()) + { + e.dict().lookup("smoother") >> name; + } + else + { + e.stream() >> name; + } + + // not (yet?) needed: + // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null; if (matrix.symmetric()) { symMatrixConstructorTable::iterator constructorIter = - symMatrixConstructorTablePtr_->find(smootherName); + symMatrixConstructorTablePtr_->find(name); if (constructorIter == symMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::smoother::New", smootherData - ) << "Unknown symmetric matrix smoother " << smootherName - << endl << endl + "lduMatrix::smoother::New", solverControls + ) << "Unknown symmetric matrix smoother " + << name << nl << nl << "Valid symmetric matrix smoothers are :" << endl << symMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -81,15 +94,15 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New else if (matrix.asymmetric()) { asymMatrixConstructorTable::iterator constructorIter = - asymMatrixConstructorTablePtr_->find(smootherName); + asymMatrixConstructorTablePtr_->find(name); if (constructorIter == asymMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::smoother::New", smootherData - ) << "Unknown asymmetric matrix smoother " << smootherName - << endl << endl + "lduMatrix::smoother::New", solverControls + ) << "Unknown asymmetric matrix smoother " + << name << nl << nl << "Valid asymmetric matrix smoothers are :" << endl << asymMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -111,8 +124,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New { FatalIOErrorIn ( - "lduMatrix::smoother::New", smootherData - ) << "cannot solve incomplete matrix, no off-diagonal coefficients" + "lduMatrix::smoother::New", solverControls + ) << "cannot solve incomplete matrix, " + "no diagonal or off-diagonal coefficient" << exit(FatalIOError); return autoPtr<lduMatrix::smoother>(NULL); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 19fd2435a08ecad0afb0b37a487888042ce719eb..4b3b8d97a97f343addee636ffe05f6676e668256 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C @@ -45,10 +45,10 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) { - word solverName(solverData); + word name(solverControls.lookup("solver")); if (matrix.diagonal()) { @@ -61,22 +61,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } else if (matrix.symmetric()) { symMatrixConstructorTable::iterator constructorIter = - symMatrixConstructorTablePtr_->find(solverName); + symMatrixConstructorTablePtr_->find(name); if (constructorIter == symMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::solver::New", solverData - ) << "Unknown symmetric matrix solver " << solverName - << endl << endl + "lduMatrix::solver::New", solverControls + ) << "Unknown symmetric matrix solver " << name << nl << nl << "Valid symmetric matrix solvers are :" << endl << symMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -91,22 +90,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } else if (matrix.asymmetric()) { asymMatrixConstructorTable::iterator constructorIter = - asymMatrixConstructorTablePtr_->find(solverName); + asymMatrixConstructorTablePtr_->find(name); if (constructorIter == asymMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::solver::New", solverData - ) << "Unknown asymmetric matrix solver " << solverName - << endl << endl + "lduMatrix::solver::New", solverControls + ) << "Unknown asymmetric matrix solver " << name << nl << nl << "Valid asymmetric matrix solvers are :" << endl << asymMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -121,7 +119,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } @@ -129,7 +127,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New { FatalIOErrorIn ( - "lduMatrix::solver::New", solverData + "lduMatrix::solver::New", solverControls ) << "cannot solve incomplete matrix, " "no diagonal or off-diagonal coefficient" << exit(FatalIOError); @@ -148,7 +146,7 @@ Foam::lduMatrix::solver::solver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : fieldName_(fieldName), @@ -156,12 +154,7 @@ Foam::lduMatrix::solver::solver interfaceBouCoeffs_(interfaceBouCoeffs), interfaceIntCoeffs_(interfaceIntCoeffs), interfaces_(interfaces), - - controlDict_(solverData), - - maxIter_(1000), - tolerance_(1e-6), - relTol_(0) + controlDict_(solverControls) { readControls(); } @@ -171,16 +164,15 @@ Foam::lduMatrix::solver::solver void Foam::lduMatrix::solver::readControls() { - controlDict_.readIfPresent("maxIter", maxIter_); - controlDict_.readIfPresent("tolerance", tolerance_); - controlDict_.readIfPresent("relTol", relTol_); + maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000); + tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6); + relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0); } -void Foam::lduMatrix::solver::read(Istream& solverData) +void Foam::lduMatrix::solver::read(const dictionary& solverControls) { - word solverName(solverData); - solverData >> controlDict_; + controlDict_ = solverControls; readControls(); } diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C index 449a992cbe8a9cc0a895635cadbc4caf4cb09fa2..03141b88a610b75abf6ff5e63dd994200eb25bcd 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C @@ -43,7 +43,7 @@ namespace Foam Foam::DICPreconditioner::DICPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H index aa1367a76177a9d3e0137e72f84ddf81155c14e8..61feee478eb4a50bfc291eb09ea480f3b2f69fa6 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H @@ -67,11 +67,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls DICPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C index 782283879350641090620fcbbbe02c8f3cca1b4e..f8778b0406ac539323cf29e9eb8be5777da89fb9 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C @@ -43,7 +43,7 @@ namespace Foam Foam::DILUPreconditioner::DILUPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H index 8e9776e5cbebe48f78332a9b28b5776b0b3ae1fd..aaaba8918fb98be87951e5062bbe56e3bc4e7a5c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H @@ -67,11 +67,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls DILUPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); @@ -94,8 +94,7 @@ public: const direction cmpt=0 ) const; - //- Return wT the transpose-matrix preconditioned form of - // residual rT. + //- Return wT the transpose-matrix preconditioned form of residual rT. virtual void preconditionT ( scalarField& wT, diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C index 8f38f29b047c18122b1311e49326626901188ed0..31574f1718d07bb5ea6e38ba99aeb570b44b6d66 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C @@ -43,7 +43,7 @@ namespace Foam Foam::FDICPreconditioner::FDICPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), @@ -164,7 +164,7 @@ void Foam::FDICPreconditioner::precondition __builtin_prefetch (&uPtr[face+96],0,0); __builtin_prefetch (&lPtr[face+96],0,0); __builtin_prefetch (&rDuUpperPtr[face+96],0,0); - __builtin_prefetch (&wAPtr[uPtr[face+32]],0,1); + __builtin_prefetch (&wAPtr[uPtr[face+32]],0,1); __builtin_prefetch (&wAPtr[lPtr[face+32]],0,1); #endif diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H index 6312b8171f91772d9b4ccd51676faf3bdb23cc7c..53e0caac0f06720766dfbf5de794034e12736324 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H @@ -80,11 +80,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls FDICPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C index cfd2f4513ef64ee6dc58a999459006f520f15e91..3433168e2085618f5c70d49c740458fd79414209 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C @@ -45,7 +45,7 @@ namespace Foam Foam::GAMGPreconditioner::GAMGPreconditioner ( const lduMatrix::solver& sol, - Istream& preconditionerData + const dictionary& solverControls ) : GAMGSolver @@ -55,7 +55,7 @@ Foam::GAMGPreconditioner::GAMGPreconditioner sol.interfaceBouCoeffs(), sol.interfaceIntCoeffs(), sol.interfaces(), - preconditionerData + solverControls ), lduMatrix::preconditioner(sol), nVcycles_(2) @@ -75,13 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner() void Foam::GAMGPreconditioner::readControls() { GAMGSolver::readControls(); - controlDict_.readIfPresent("nVcycles", nVcycles_); -} - - -void Foam::GAMGPreconditioner::read(Istream& solverData) -{ - GAMGSolver::read(solverData); + nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2); } diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H index 1e9bfae843aa186b1c448241a1222d2f345136a2..82ca63580b131a45fc2abc2716f367a0b194bcdd 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H @@ -55,17 +55,14 @@ class GAMGPreconditioner public GAMGSolver, public lduMatrix::preconditioner { - // Private data +protected: + // Protected data //- Number of V-cycles to perform label nVcycles_; - - // Private member functions - - //- Read control parameters from the control dictionary - void readControls(); - + //- Read the control parameters from the controlDict_ + virtual void readControls(); public: @@ -75,11 +72,11 @@ public: // Constructors - //- Construct for given solver and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls GAMGPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControls ); @@ -90,9 +87,6 @@ public: // Member Functions - //- Read and reset the preconditioner parameters from the given stream - virtual void read(Istream& preconditionerData); - //- Return wA the preconditioned form of residual rA virtual void precondition ( diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C index 3bce37a2c77e1beb2efd83aa04da4e09c6af480d..04da54f1c46488e83202969217e7f14590639abc 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C @@ -47,7 +47,7 @@ namespace Foam Foam::diagonalPreconditioner::diagonalPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), @@ -77,10 +77,6 @@ Foam::diagonalPreconditioner::diagonalPreconditioner // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::diagonalPreconditioner::read(Istream&) -{} - - void Foam::diagonalPreconditioner::precondition ( scalarField& wA, diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H index cc6f8f82b3406e3ab02d7ae476d66b211fc45279..3a0bcb4b2be92acfca8ec15d4e365ed77790e2c6 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H @@ -56,7 +56,7 @@ class diagonalPreconditioner { // Private data - //- The reciprocal diagonal + //- The reciprocal diagonal scalarField rD; @@ -77,11 +77,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls diagonalPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); @@ -93,9 +93,6 @@ public: // Member Functions - //- Read and reset the preconditioner parameters from the given stream - virtual void read(Istream& preconditionerData); - //- Return wA the preconditioned form of residual rA virtual void precondition ( @@ -104,8 +101,7 @@ public: const direction cmpt=0 ) const; - //- Return wT the transpose-matrix preconditioned form of - // residual rT. + //- Return wT the transpose-matrix preconditioned form of residual rT. virtual void preconditionT ( scalarField& wT, @@ -113,7 +109,7 @@ public: const direction cmpt=0 ) const { - return(precondition(wT, rT, cmpt)); + return precondition(wT, rT, cmpt); } }; diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C index 00d1129b5bc306ad4809f17fcc04f3a07ad56d43..1f4fe2b4a4f8a3921f4ea6624ef92e87de7f3a2f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C @@ -47,7 +47,7 @@ namespace Foam Foam::noPreconditioner::noPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol) @@ -56,10 +56,6 @@ Foam::noPreconditioner::noPreconditioner // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::noPreconditioner::read(Istream&) -{} - - void Foam::noPreconditioner::precondition ( scalarField& wA, diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H index bedab173213546b84416ac4159db82eb2c2ed615..9668f217fcac66e8e2441b8cff7c09eabef4744c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H @@ -68,11 +68,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls noPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); @@ -84,9 +84,6 @@ public: // Member Functions - //- Read and reset the preconditioner parameters from the given stream - virtual void read(Istream& preconditionerData); - //- Return wA the preconditioned form of residual rA virtual void precondition ( @@ -95,8 +92,7 @@ public: const direction cmpt=0 ) const; - //- Return wT the transpose-matrix preconditioned form of - // residual rT. + //- Return wT the transpose-matrix preconditioned form of residual rT. virtual void preconditionT ( scalarField& wT, @@ -104,7 +100,7 @@ public: const direction cmpt=0 ) const { - return(precondition(wT, rT, cmpt)); + return precondition(wT, rT, cmpt); } }; diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H index 5a59ac98b369393c51f11acda6ba95dde24c8b4f..11346a51d1e0f5a5b84edf67366199f2042fbb09 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H @@ -27,8 +27,10 @@ Class Description Simplified diagonal-based incomplete Cholesky smoother for symmetric - matrices. In order to improve efficiency the residual is evaluated after - every nSweeps sweeps. + matrices. + + To improve efficiency, the residual is evaluated after every nSweeps + sweeps. SourceFiles DICSmoother.C diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H index 55312c0ef5125d3b2f21f5723eb4419664a115a0..12a9c9c173b66edc3c3f8e60515c8b23cd55fc04 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H @@ -26,9 +26,9 @@ Class Foam::DICGaussSeidelSmoother Description - Combined DIC/GaussSeidel smoother for symmetric - matrices in which DIC smoothing is followed by GaussSeidel to ensure that - any "spikes" created by the DIC sweeps are smoothed-out. + Combined DIC/GaussSeidel smoother for symmetric matrices in which DIC + smoothing is followed by GaussSeidel to ensure that any "spikes" created + by the DIC sweeps are smoothed-out. SourceFiles DICGaussSeidelSmoother.C @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class DICGaussSeidelSmoother Declaration + Class DICGaussSeidelSmoother Declaration \*---------------------------------------------------------------------------*/ class DICGaussSeidelSmoother @@ -57,6 +57,7 @@ class DICGaussSeidelSmoother // Private data DICSmoother dicSmoother_; + GaussSeidelSmoother gsSmoother_; diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H index f95bd91972a822bbde86f65e754760e9eb20e9e1..a8218973dd2e3a04ab63e2b614b2db776ab0922c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H @@ -27,8 +27,9 @@ Class Description Simplified diagonal-based incomplete LU smoother for asymmetric matrices. - In order to improve efficiency the residual is evaluated after every - nSweeps sweeps. + + To improve efficiency, the residual is evaluated after every nSweeps + sweeps. SourceFiles DILUSmoother.C @@ -46,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class DILUSmoother Declaration + Class DILUSmoother Declaration \*---------------------------------------------------------------------------*/ class DILUSmoother diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H index 6783280f05183cfad176a79274bbc4ea15758f40..6523e259c25a6c118dcb71b7910243271396bf24 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H @@ -26,9 +26,9 @@ Class Foam::DILUGaussSeidelSmoother Description - Combined DILU/GaussSeidel smoother for asymmetric - matrices in which DILU smoothing is followed by GaussSeidel to ensure that - any "spikes" created by the DILU sweeps are smoothed-out. + Combined DILU/GaussSeidel smoother for asymmetric matrices in which + DILU smoothing is followed by GaussSeidel to ensure that any "spikes" + created by the DILU sweeps are smoothed-out. SourceFiles DILUGaussSeidelSmoother.C @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class DILUGaussSeidelSmoother Declaration + Class DILUGaussSeidelSmoother Declaration \*---------------------------------------------------------------------------*/ class DILUGaussSeidelSmoother @@ -57,6 +57,7 @@ class DILUGaussSeidelSmoother // Private data DILUSmoother diluSmoother_; + GaussSeidelSmoother gsSmoother_; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C index 7772f7c6a3ced7c9c00daab57545792a4f2967e3..e88b873f9f4ab407096b2bc596c3ee4f5575d3ca 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C @@ -37,36 +37,31 @@ namespace Foam } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -Foam::IStringStream Foam::BICCG::solverDataStream +Foam::dictionary Foam::BICCG::solverDict ( - const scalar tolerance, + const scalar tol, const scalar relTol -) const +) { - return IStringStream - ( - "{ preconditioner DILU;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + dictionary dict(IStringStream("solver PBiCG; preconditioner DILU;")()); + dict.add("tolerance", tol); + dict.add("relTol", relTol); + + return dict; } -Foam::IStringStream Foam::BICCG::solverDataStream +Foam::dictionary Foam::BICCG::solverDict ( - const word& solverName, - Istream& solverData -) const + Istream& is +) { - scalar tolerance(readScalar(solverData)); - scalar relTol(readScalar(solverData)); + scalar tol(readScalar(is)); + scalar relTol(readScalar(is)); - return IStringStream - ( - solverName + "{ preconditioner DILU;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + return solverDict(tol, relTol); } @@ -79,8 +74,7 @@ Foam::BICCG::BICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol + const dictionary& solverControls ) : PBiCG @@ -90,7 +84,7 @@ Foam::BICCG::BICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(tolerance, relTol)() + solverControls ) {} @@ -102,7 +96,8 @@ Foam::BICCG::BICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol ) : PBiCG @@ -112,18 +107,8 @@ Foam::BICCG::BICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(word::null, solverData)() + solverDict(tolerance, relTol) ) {} - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::BICCG::read(Istream& solverData) -{ - word solverName(solverData); - PBiCG::read(solverDataStream(solverName, solverData)()); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H index c6c140345ce4a6cc94f6a0a92583fdda30f2931a..f3058a9b67dfa96015e93bf9dc715351b8273188 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H @@ -32,7 +32,7 @@ Description Deprecated This solver is present for backward-compatibility and the PBiCG solver - should be used for preference. + should be used instead. SourceFiles BICCG.C @@ -65,24 +65,20 @@ class BICCG //- Disallow default bitwise assignment void operator=(const BICCG&); - //- Return the dictionary data-stream constructed from the components. - // Needed for backward compatibility - IStringStream solverDataStream - ( - const scalar tolerance, - const scalar relTol - ) const; +public: - //- Return the dictionary data-stream constructed from the old-style - // data-stream. Needed for backward compatibility - IStringStream solverDataStream - ( - const word& solverName, - Istream& solverData - ) const; + //- 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&); -public: //- Runtime type information TypeName("BICCG"); @@ -90,7 +86,7 @@ public: // Constructors - //- Construct from matrix components and tolerances + //- Construct from matrix components and solver data stream BICCG ( const word& fieldName, @@ -98,11 +94,11 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol = 0.0 + const dictionary& solverControls ); - //- Construct from matrix components and solver data stream + + //- Construct from matrix components and tolerances BICCG ( const word& fieldName, @@ -110,20 +106,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol = 0.0 ); - // Destructor virtual ~BICCG() {} - - // Member Functions - - //- Read and reset the solver parameters from the given stream - void read(Istream& solverData); }; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C index f8a29ba2413738a3820aae190206287e74c314c8..ef838342e8d2f9d6199a4751e4ffe91db60b2c2a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C @@ -49,7 +49,7 @@ Foam::GAMGSolver::GAMGSolver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -59,7 +59,7 @@ Foam::GAMGSolver::GAMGSolver interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ), // Default values for all controls @@ -112,7 +112,7 @@ Foam::GAMGSolver::GAMGSolver "const FieldField<Field, scalar>& interfaceBouCoeffs," "const FieldField<Field, scalar>& interfaceIntCoeffs," "const lduInterfaceFieldPtrsList& interfaces," - "Istream& solverData" + "const dictionary& solverControls" ")" ) << "No coarse levels created, either matrix too small for GAMG" " or nCellsInCoarsestLevel too large.\n" @@ -154,6 +154,7 @@ void Foam::GAMGSolver::readControls() { lduMatrix::solver::readControls(); + // we could also consider supplying defaults here too controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_); controlDict_.readIfPresent("nPreSweeps", nPreSweeps_); controlDict_.readIfPresent("nPostSweeps", nPostSweeps_); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H index 8c4596c888979d6642583d2e66b6599db59955fe..6cbef1f5092bd8ef361fd8ca7d2e4785e2a6a198 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H @@ -212,7 +212,7 @@ public: // Constructors - //- Construct from lduMatrix + //- Construct from lduMatrix and solver controls GAMGSolver ( const word& fieldName, @@ -220,7 +220,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C index 431f2f179f01756a5484f9a13147398ce4ff7d37..e7e2a6339180035768c107e0b29ceb612d7c2f41 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C @@ -374,7 +374,7 @@ void Foam::GAMGSolver::initVcycle interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_, - controlDict_.lookup("smoother") + controlDict_ ) ); @@ -408,7 +408,7 @@ void Foam::GAMGSolver::initVcycle interfaceLevelsBouCoeffs_[leveli], interfaceLevelsIntCoeffs_[leveli], interfaceLevels_[leveli], - controlDict_.lookup("smoother") + controlDict_ ) ); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C index dbd4ae16d083f2561a49f4a4d5ba4492bd4f40d4..97a03b4f0d1a49afd1c1306c1e675ae7c4a87911 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C @@ -36,40 +36,33 @@ namespace Foam addICCGSymMatrixConstructorToTable_; } +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -Foam::IStringStream Foam::ICCG::solverDataStream +Foam::dictionary Foam::ICCG::solverDict ( - const scalar tolerance, + const scalar tol, const scalar relTol -) const +) { - return IStringStream - ( - "{ preconditioner DIC;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + dictionary dict(IStringStream("solver PCG; preconditioner DIC;")()); + dict.add("tolerance", tol); + dict.add("relTol", relTol); + + return dict; } -Foam::IStringStream Foam::ICCG::solverDataStream +Foam::dictionary Foam::ICCG::solverDict ( - const word& solverName, - Istream& solverData -) const + Istream& is +) { - scalar tolerance(readScalar(solverData)); - scalar relTol(readScalar(solverData)); + scalar tol(readScalar(is)); + scalar relTol(readScalar(is)); - return IStringStream - ( - solverName + "{ preconditioner DIC;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + return solverDict(tol, relTol); } - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::ICCG::ICCG @@ -79,8 +72,7 @@ Foam::ICCG::ICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol + const dictionary& solverControls ) : PCG @@ -90,7 +82,7 @@ Foam::ICCG::ICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(tolerance, relTol)() + solverControls ) {} @@ -102,7 +94,8 @@ Foam::ICCG::ICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol ) : PCG @@ -112,18 +105,8 @@ Foam::ICCG::ICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(word::null, solverData)() + solverDict(tolerance, relTol) ) {} - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::ICCG::read(Istream& solverData) -{ - word solverName(solverData); - PCG::read(solverDataStream(solverName, solverData)()); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H index c8f124f87ce35303a90562d242e3fc1f454928ea..850c3f47753698a7be22fc354c38ddbf9707fe27 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H @@ -65,24 +65,20 @@ class ICCG //- Disallow default bitwise assignment void operator=(const ICCG&); - //- Return the dictionary data-stream constructed from the components. +public: + + //- Return the dictionary constructed from the components. // Needed for backward compatibility - IStringStream solverDataStream + static dictionary solverDict ( - const scalar tolerance, + const scalar tol, const scalar relTol - ) const; - - //- Return the dictionary data-stream constructed from the old-style - // data-stream. Needed for backward compatibility - IStringStream solverDataStream - ( - const word& solverName, - Istream& solverData - ) const; + ); + //- Return the dictionary constructed from the old-style data-stream. + // Needed for backward compatibility + static dictionary solverDict(Istream&); -public: //- Runtime type information TypeName("ICCG"); @@ -90,7 +86,7 @@ public: // Constructors - //- Construct from matrix components and tolerances + //- Construct from matrix components and solver data stream ICCG ( const word& fieldName, @@ -98,11 +94,10 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol = 0.0 + const dictionary& solverControls ); - //- Construct from matrix components and solver data stream + //- Construct from matrix components and tolerances ICCG ( const word& fieldName, @@ -110,20 +105,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol = 0.0 ); - // Destructor virtual ~ICCG() {} - - // Member Functions - - //- Read and reset the solver parameters from the given stream - void read(Istream& solverData); }; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C index 9100ae5777b8815e5d39bb20d09019bf4be7d761..af4137f689634bb1810e67bb75ad31e4dd02585d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C @@ -46,7 +46,7 @@ Foam::PBiCG::PBiCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -56,7 +56,7 @@ Foam::PBiCG::PBiCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) {} @@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve const direction cmpt ) const { - word preconditionerName(controlDict_.lookup("preconditioner")); - // --- Setup class containing solver performance data lduMatrix::solverPerformance solverPerf ( - preconditionerName + typeName, + lduMatrix::preconditioner::getName(controlDict_) + typeName, fieldName_ ); @@ -128,7 +126,7 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve lduMatrix::preconditioner::New ( *this, - controlDict_.lookup("preconditioner") + controlDict_ ); // --- Solver iteration diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H index 07adf0c8e41add0e7b559cadaedcebc61f16a000..6ba96fe9692a1697034398e4bca08ad15b90f236 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H @@ -77,7 +77,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C index a21eeaca15ceda3cf18d2272418e1fd88a3d57ff..ad0ae5a08120b90b6e335416bd5727763843da66 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C @@ -46,7 +46,7 @@ Foam::PCG::PCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -56,7 +56,7 @@ Foam::PCG::PCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) {} @@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve const direction cmpt ) const { - word preconditionerName(controlDict_.lookup("preconditioner")); - // --- Setup class containing solver performance data lduMatrix::solverPerformance solverPerf ( - preconditionerName + typeName, + lduMatrix::preconditioner::getName(controlDict_) + typeName, fieldName_ ); @@ -119,7 +117,7 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve lduMatrix::preconditioner::New ( *this, - controlDict_.lookup("preconditioner") + controlDict_ ); // --- Solver iteration diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H index 6627bd45b1e3dbb3ef3aee245533dcb734c74a18..4e0b5b4e2811b30582a18c4a28ea100c17a78275 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H @@ -27,7 +27,7 @@ Class Description Preconditioned conjugate gradient solver for symmetric lduMatrices - using a run-time selectable preconditiioner. + using a run-time selectable preconditioner. SourceFiles PCG.C @@ -69,7 +69,7 @@ public: // Constructors - //- Construct from matrix components and solver data stream + //- Construct from matrix components and solver controls PCG ( const word& fieldName, @@ -77,7 +77,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C index 583a2008e3d5f4e26dbb855fd1d245cbe633f433..3255ca896ae1402fa508b46f021ef797188be5c5 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C @@ -43,7 +43,7 @@ Foam::diagonalSolver::diagonalSolver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -53,19 +53,13 @@ Foam::diagonalSolver::diagonalSolver interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) {} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Foam::diagonalSolver::read(Istream& solverData) -{ - word solverName(solverData); -} - - Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve ( scalarField& psi, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H index 573f4cc233e2d3ea70d0b7654c613309ffce9126..b4ac77631262dea96216f3d95bfbbdb78008836f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H @@ -68,7 +68,7 @@ public: // Constructors - //- Construct from matrix + //- Construct from matrix and solver controls diagonalSolver ( const word& fieldName, @@ -76,14 +76,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); // Member Functions //- Read and reset the solver parameters from the given stream - void read(Istream& solverData); + void read(const dictionary&) + {} //- Solve the matrix with this solver lduMatrix::solverPerformance solve diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C index 6b7c1cbcc3c66d9c9c33f9c1361f76433ca0602f..503e376bd28991ad8cfd5e9091aa6c8ee841567d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C @@ -49,7 +49,7 @@ Foam::smoothSolver::smoothSolver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -59,9 +59,8 @@ Foam::smoothSolver::smoothSolver interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData - ), - nSweeps_(1) + solverControls + ) { readControls(); } @@ -72,7 +71,7 @@ Foam::smoothSolver::smoothSolver void Foam::smoothSolver::readControls() { lduMatrix::solver::readControls(); - controlDict_.readIfPresent("nSweeps", nSweeps_); + nSweeps_ = controlDict_.lookupOrDefault<label>("nSweeps", 1); } @@ -96,7 +95,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_, - controlDict_.lookup("smoother") + controlDict_ ); smootherPtr->smooth @@ -144,7 +143,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_, - controlDict_.lookup("smoother") + controlDict_ ); // Smoothing loop diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H index 3d5687a8a93d81172d7b14448546618db1d27ed8..15ddf7bf3b2750b25c07f27d7f3eb537bed4f4b7 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H @@ -66,7 +66,6 @@ protected: //- Read the control parameters from the controlDict_ virtual void readControls(); - public: //- Runtime type information @@ -75,7 +74,7 @@ public: // Constructors - //- Construct from matrix components and solver data stream + //- Construct from matrix components and solver controls smoothSolver ( const word& fieldName, @@ -83,10 +82,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); + // Destructor + + virtual ~smoothSolver() + {} + // Member Functions //- Solve the matrix with this solver diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 5429a20e8177fe8365fbdff1ebbcc9df2a5f1aee..f988cc2305d99ba3a8c85d9f70cc59240592060b 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -27,9 +27,12 @@ License #include "solution.H" #include "Time.H" +// these two are for old syntax compatibility: +#include "BICCG.H" +#include "ICCG.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -int Foam::solution::debug(Foam::debug::debugSwitch("solution", false)); +int Foam::solution::debug(::Foam::debug::debugSwitch("solution", 0)); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -55,6 +58,83 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::label Foam::solution::upgradeSolverDict +( + dictionary& dict, + const bool verbose +) +{ + label nChanged = 0; + + // backward compatibility: + // recast primitive entries into dictionary entries + forAllIter(dictionary, dict, iter) + { + if (!iter().isDict()) + { + Istream& is = iter().stream(); + 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 can be a primitiveEntry w/o settings, + // or a dictionaryEntry. + // transform primitiveEntry with settings -> dictionaryEntry + entry* precond = subdict.lookupEntryPtr + ( + "preconditioner", + false, + false + ); + + if (precond && !precond->isDict()) + { + Istream& is = precond->stream(); + is >> name; + + if (!is.eof()) + { + dictionary precondDict; + precondDict.add("preconditioner", name); + precondDict <<= dictionary(is); + + subdict.set("preconditioner", precondDict); + } + } + } + + // write out information to help people adjust to the new syntax + if (verbose) + { + Info<< "// using new solver syntax:\n" + << iter().keyword() << subdict << endl; + } + + // overwrite with dictionary entry + dict.set(iter().keyword(), subdict); + + nChanged++; + } + } + + return nChanged; +} + + bool Foam::solution::read() { if (regIOobject::read()) @@ -69,6 +149,7 @@ bool Foam::solution::read() if (dict.found("solvers")) { solvers_ = dict.subDict("solvers"); + upgradeSolverDict(solvers_); } return true; @@ -97,7 +178,7 @@ bool Foam::solution::relax(const word& name) const { if (debug) { - Info<< "Lookup relax for " << name << endl; + Info<< "Find relax for " << name << endl; } return relaxationFactors_.found(name); @@ -127,7 +208,7 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const } -Foam::ITstream& Foam::solution::solver(const word& name) const +const Foam::dictionary& Foam::solution::solver(const word& name) const { if (debug) { @@ -135,7 +216,7 @@ Foam::ITstream& Foam::solution::solver(const word& name) const << "Lookup solver for " << name << endl; } - return solvers_.lookup(name); + return solvers_.subDict(name); } diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 3d455fdecc31e8f8ee3d18e80a394082e2d2877f..3db89d9fc15b8f73f69854fe71937599a43dc31a 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class solution Declaration + Class solution Declaration \*---------------------------------------------------------------------------*/ class solution @@ -59,7 +59,6 @@ class solution //- Dictionary of solver parameters for all the fields dictionary solvers_; - // Private Member Functions //- Disallow default bitwise copy construct and assignment @@ -69,6 +68,11 @@ class solution public: + //- Update from older solver controls syntax + // Usually verbose, since we want to know about the changes + // Returns the number of settings changed + static label upgradeSolverDict(dictionary& dict, const bool verbose=true); + //- Debug switch static int debug; @@ -84,7 +88,7 @@ public: // Access //- Return the selected sub-dictionary of solvers if the "select" - // keyword is given othewise return the complete dictionary + // keyword is given, otherwise return the complete dictionary const dictionary& solutionDict() const; //- Return true if the relaxation factor is given for the field @@ -93,13 +97,11 @@ public: //- Return the relaxation factor for the given field scalar relaxationFactor(const word& name) const; - //- Return the dictionary of solver parameters for the given field + //- Return the solver controls dictionary for the given field const dictionary& solverDict(const word& name) const; - //- Return the stream of solver parameters for the given field - // @deprecated Backward compatibility only - should use solverDict - ITstream& solver(const word& name) const; - + //- Return the solver controls dictionary for the given field + const dictionary& solver(const word& name) const; // Read diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index b8698eb17738d2e5e39adfd6ac0eaa3568356a15..20f36d23497a426acc3a4ab196fc587396a2b844 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -336,8 +336,8 @@ Foam::fvMatrix<Type>::fvMatrix { if (debug) { - Info<< "fvMatrix<Type>(GeometricField<Type, fvPatchField, volMesh>&," - " Istream&) : " + Info<< "fvMatrix<Type>" + "(GeometricField<Type, fvPatchField, volMesh>&, Istream&) : " "constructing fvMatrix<Type> for field " << psi_.name() << endl; } @@ -1257,7 +1257,7 @@ template<class Type> Foam::lduMatrix::solverPerformance Foam::solve ( fvMatrix<Type>& fvm, - Istream& solverControls + const dictionary& solverControls ) { return fvm.solve(solverControls); @@ -1267,7 +1267,7 @@ template<class Type> Foam::lduMatrix::solverPerformance Foam::solve ( const tmp<fvMatrix<Type> >& tfvm, - Istream& solverControls + const dictionary& solverControls ) { lduMatrix::solverPerformance solverPerf = diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index b7663db50f658d41783e1657f2ee401e134daa10..2df42847a20b3039158571066faada6ea23a7f8c 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -220,8 +220,8 @@ public: // Member functions //- Solve returning the solution statistics. - // Solver controls read from Istream - lduMatrix::solverPerformance solve(Istream&); + // Use the given solver controls + lduMatrix::solverPerformance solve(const dictionary&); //- Solve returning the solution statistics. // Solver controls read from fvSolution @@ -359,16 +359,16 @@ public: ); //- Construct and return the solver - // Solver controls read from Istream - autoPtr<fvSolver> solver(Istream&); + // Use the given solver controls + autoPtr<fvSolver> solver(const dictionary&); //- Construct and return the solver // Solver controls read from fvSolution autoPtr<fvSolver> solver(); //- Solve returning the solution statistics. - // Solver controls read from Istream - lduMatrix::solverPerformance solve(Istream&); + // Use the given solver controls + lduMatrix::solverPerformance solve(const dictionary&); //- Solve returning the solution statistics. // Solver controls read from fvSolution @@ -518,16 +518,20 @@ void checkMethod //- Solve returning the solution statistics given convergence tolerance -// Solver controls read Istream +// Use the given solver controls template<class Type> -lduMatrix::solverPerformance solve(fvMatrix<Type>&, Istream&); +lduMatrix::solverPerformance solve(fvMatrix<Type>&, const dictionary&); //- Solve returning the solution statistics given convergence tolerance, // deleting temporary matrix after solution. -// Solver controls read Istream +// Use the given solver controls template<class Type> -lduMatrix::solverPerformance solve(const tmp<fvMatrix<Type> >&, Istream&); +lduMatrix::solverPerformance solve +( + const tmp<fvMatrix<Type> >&, + const dictionary& +); //- Solve returning the solution statistics given convergence tolerance diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 37e3fd8391b344a14c2f53af7a9d04f9ead6e7fd..53183114724c7dfdebb4893f81d799b34c7ed76e 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -53,12 +53,12 @@ void Foam::fvMatrix<Type>::setComponentReference template<class Type> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve ( - Istream& solverControls + const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<Type>::solve(Istream& solverControls) : " + Info<< "fvMatrix<Type>::solve(const dictionary& solverControls) : " "solving fvMatrix<Type>" << endl; } @@ -108,7 +108,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve internalCoeffs_.component(cmpt) ); - lduInterfaceFieldPtrsList interfaces = + lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces(); // Use the initMatrixInterfaces and updateMatrixInterfaces to correct @@ -142,7 +142,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve bouCoeffsCmpt, intCoeffsCmpt, interfaces, - solverControls.rewind() + solverControls )->solve(psiCmpt, sourceCmpt, cmpt); solverPerf.print(); @@ -170,20 +170,20 @@ template<class Type> Foam::autoPtr<typename Foam::fvMatrix<Type>::fvSolver> Foam::fvMatrix<Type>::solver() { - return solver(psi_.mesh().solver(psi_.name())); + return solver(psi_.mesh().solverDict(psi_.name())); } template<class Type> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve() { - return solve(psi_.mesh().solver(psi_.name())); + return solve(psi_.mesh().solverDict(psi_.name())); } template<class Type> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve() { - return solve(psi_.mesh().solver(psi_.name())); + return solve(psi_.mesh().solverDict(psi_.name())); } diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C index ad952b3e78f9b5bf52bc926b0b5982fc87a46c20..be97ac403a6db65de1d258881022e0a54b8a3735 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C @@ -45,7 +45,7 @@ void Foam::fvMatrix<Foam::scalar>::setComponentReference internalCoeffs_[patchi][facei] += diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]; - boundaryCoeffs_[patchi][facei] += + boundaryCoeffs_[patchi][facei] += diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]] *value; } @@ -57,12 +57,12 @@ template<> Foam::autoPtr<Foam::fvMatrix<Foam::scalar>::fvSolver> Foam::fvMatrix<Foam::scalar>::solver ( - Istream& solverControls + const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<scalar>::solver(Istream& solverControls) : " + Info<< "fvMatrix<scalar>::solver(const dictionary& solverControls) : " "solver for fvMatrix<scalar>" << endl; } @@ -96,7 +96,7 @@ Foam::fvMatrix<Foam::scalar>::solver template<> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve ( - Istream& solverControls + const dictionary& solverControls ) { scalarField saveDiag = fvMat_.diag(); @@ -105,8 +105,10 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve scalarField totalSource = fvMat_.source(); fvMat_.addBoundarySource(totalSource, false); + // assign new solver controls solver_->read(solverControls); - lduMatrix::solverPerformance solverPerf = + + lduMatrix::solverPerformance solverPerf = solver_->solve(fvMat_.psi().internalField(), totalSource); solverPerf.print(); @@ -122,12 +124,12 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve template<> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve ( - Istream& solverControls + const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<scalar>::solve(Istream& solverControls) : " + Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : " "solving fvMatrix<scalar>" << endl; } diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H index ff22889d49c2e17bbd7cb746c01f7e8632652cbb..19ec0abb2e84a5d32107098758ef4b3f61db3ad5 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H @@ -23,9 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA InClass - Foam::fvScalarMatrix + Foam::fvMatrix Description + A scalar instance of fvMatrix SourceFiles fvScalarMatrix.C @@ -56,13 +57,22 @@ void fvMatrix<scalar>::setComponentReference ); template<> -autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver(Istream&); +autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver +( + const dictionary& +); template<> -lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve(Istream&); +lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve +( + const dictionary& +); template<> -lduMatrix::solverPerformance fvMatrix<scalar>::solve(Istream&); +lduMatrix::solverPerformance fvMatrix<scalar>::solve +( + const dictionary& +); template<> tmp<scalarField> fvMatrix<scalar>::residual() const; diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 1dc8e8d1f6c6d84eafbfc529189378f7eed8ea3f..47ef5eb98fd05bdb4e5d1b280ab52224b5d5171a 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -142,8 +142,8 @@ void Foam::MULES::implicitSolve { const fvMesh& mesh = psi.mesh(); - dictionary MULESSolver(mesh.solver(psi.name())); - const dictionary& MULEScontrols = MULESSolver.subDict("MULESImplicit"); + const dictionary& MULEScontrols = + mesh.solverDict(psi.name()).subDict("MULESImplicit"); label maxIter ( diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C index ba8498bba0524cf072e90856f37b28d2f1b5c356..88a15a4f233b7b72d4ee92eb31e81eea3bd7ad03 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C @@ -55,7 +55,7 @@ namespace Foam Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H index 2232dd2e63286894aa5f66c93c6fc485369365c8..3af3d843947cfc038d017568307fb111742f1867 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H @@ -93,8 +93,8 @@ public: //- Construct from polyMesh and data stream displacementSBRStressFvMotionSolver ( - const polyMesh& mesh, - Istream& msData + const polyMesh&, + Istream& msDataUnused ); diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H index 57ba2978bbb1c8323445c0d68b3a15c0ce2abdae..d9d2bfd7edb746c4aa91de6f6203a9c20e5f098d 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H @@ -107,9 +107,10 @@ public: // Constructors + //- Construct from polyMesh and data stream displacementComponentLaplacianFvMotionSolver ( - const polyMesh& mesh, + const polyMesh&, Istream& msData ); diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C index dae6656380bb2acdf3039f3666c1b7af82baa87c..e7907295e42f7d57a6f2dd9d83a017e48cad28b4 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C @@ -58,7 +58,7 @@ Foam::displacementInterpolationFvMotionSolver:: displacementInterpolationFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H index 04f3eda5cc15f8e8535afb040da2afc4c864310f..b490634b3ece28efe89b345998e13c434fd03ced 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H @@ -115,10 +115,11 @@ public: // Constructors + //- Construct from polyMesh and data stream displacementInterpolationFvMotionSolver ( - const polyMesh& mesh, - Istream& msData + const polyMesh&, + Istream& msDataUnused ); diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 02e5f3b5eb157256d3b75ddda605b581dafc37f9..78c1b41355fe52c2238e8da791b2f07ede03d701 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -53,7 +53,7 @@ namespace Foam Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H index 47570239ba72b7547e11f1f3b68345813982f501..d9fc9e5758bcd650f25bc2eab655cbc5d0df0311 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H @@ -101,8 +101,8 @@ public: //- Construct from polyMesh and data stream displacementLaplacianFvMotionSolver ( - const polyMesh& mesh, - Istream& msData + const polyMesh&, + Istream& msDataUnused ); diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H index 223d7ed115280e67d375e5841e872283791dceff..9537b7576ec8387bd045d9c893430f428bb0659d 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H @@ -93,9 +93,10 @@ public: // Constructors + //- Construct from polyMesh and data stream (provides component) velocityComponentLaplacianFvMotionSolver ( - const polyMesh& mesh, + const polyMesh&, Istream& msData ); diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C index 50a06de548608f435997ff9a21ace84d93aa6ae0..d6cbf1cc18b95a2c323418bed21cedf4de85884a 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C @@ -50,7 +50,7 @@ namespace Foam Foam::velocityLaplacianFvMotionSolver::velocityLaplacianFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H index 2699e95d32fb2d56a62c82900d819bda5117f4af..c4d51123b1ec0b25d66dcca8e234043cd2996c34 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H @@ -88,7 +88,11 @@ public: // Constructors //- Construct from polyMesh and data stream - velocityLaplacianFvMotionSolver(const polyMesh& mesh, Istream& msData); + velocityLaplacianFvMotionSolver + ( + const polyMesh&, + Istream& msDataUnused + ); // Destructor