From a13f97d59dae349690f7751bc9f84d6568cb0a35 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 2 Dec 2008 15:55:51 +0100 Subject: [PATCH 01/61] timeSelector - handle cases with missing constant/ or 0/ directories --- applications/test/findTimes/findTimes.C | 10 +++- src/OpenFOAM/db/Time/timeSelector.C | 65 ++++++++++++++++--------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/applications/test/findTimes/findTimes.C b/applications/test/findTimes/findTimes.C index db22507b4f..2b59609006 100644 --- a/applications/test/findTimes/findTimes.C +++ b/applications/test/findTimes/findTimes.C @@ -28,6 +28,7 @@ Description #include "argList.H" #include "Time.H" +#include "timeSelector.H" using namespace Foam; @@ -36,13 +37,18 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::noParallel(); + Foam::timeSelector::addOptions(); # include "setRootCase.H" # include "createTime.H" - Info<< runTime.times() << endl; + Info<< "Times found:" << runTime.times() << endl; - Info << "End\n" << endl; + instantList timeDirs = Foam::timeSelector::select0(runTime, args); + + Info<< "Times selected:" << timeDirs << endl; + Info<< "\nEnd\n" << endl; return 0; } diff --git a/src/OpenFOAM/db/Time/timeSelector.C b/src/OpenFOAM/db/Time/timeSelector.C index cfb2354d79..002a0b5beb 100644 --- a/src/OpenFOAM/db/Time/timeSelector.C +++ b/src/OpenFOAM/db/Time/timeSelector.C @@ -56,22 +56,12 @@ Foam::List Foam::timeSelector::selected(const List& Times) const { List lst(Times.size(), false); - // check ranges - forAll(Times, i) + // check ranges, avoid false positive on constant/ + forAll(Times, timeI) { - if (selected(Times[i])) + if (Times[timeI].name() != "constant" && selected(Times[timeI])) { - lst[i] = true; - } - } - - // avoid false positive on "constant" - forAll(Times, i) - { - if (Times[i].name() == "constant") - { - lst[i] = false; - break; + lst[timeI] = true; } } @@ -85,15 +75,15 @@ Foam::List Foam::timeSelector::selected(const List& Times) const int nearestIndex = -1; scalar nearestDiff = Foam::GREAT; - forAll(Times, timeIndex) + forAll(Times, timeI) { - if (Times[timeIndex].name() == "constant") continue; + if (Times[timeI].name() == "constant") continue; - scalar diff = fabs(Times[timeIndex].value() - target); + scalar diff = fabs(Times[timeI].value() - target); if (diff < nearestDiff) { nearestDiff = diff; - nearestIndex = timeIndex; + nearestIndex = timeI; } } @@ -156,6 +146,27 @@ Foam::List Foam::timeSelector::select { List selectTimes(timeDirs.size(), true); + // determine locations of constant/ and 0/ directories + label constantIdx = -1; + label zeroIdx = -1; + + forAll(timeDirs, timeI) + { + if (timeDirs[timeI].name() == "constant") + { + constantIdx = timeI; + } + else if (timeDirs[timeI].value() == 0) + { + zeroIdx = timeI; + } + + if (constantIdx >= 0 && zeroIdx >= 0) + { + break; + } + } + if (args.options().found("time")) { selectTimes = timeSelector @@ -166,25 +177,31 @@ Foam::List Foam::timeSelector::select else if (args.options().found("latestTime")) { selectTimes = false; + const label latestIdx = timeDirs.size() - 1; // avoid false match on constant/ or 0/ - if (timeDirs.size() > 2) + if (latestIdx != constantIdx && latestIdx != zeroIdx) { - selectTimes[timeDirs.size() - 1] = true; + selectTimes[latestIdx] = true; } } - if (timeDirs.size() > 1) + // special treatment for constant/ + if (constantIdx >= 0) { - selectTimes[0] = args.options().found("constant"); + selectTimes[constantIdx] = args.options().found("constant"); + } + // special treatment for 0/ + if (zeroIdx >= 0) + { if (args.options().found("noZero")) { - selectTimes[1] = false; + selectTimes[zeroIdx] = false; } else if (argList::validOptions.found("zeroTime")) { - selectTimes[1] = args.options().found("zeroTime"); + selectTimes[zeroIdx] = args.options().found("zeroTime"); } } From 4f1bb8345f2e8d738164f4d8b67824bef1849320 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 8 Dec 2008 17:22:01 +0100 Subject: [PATCH 02/61] lduMatrix now takes a dictionary instead of an Istream for the solver controls - can now use dictionary substitutions and regular expressions in system/fvSolution - foamUpgradeFvSolution application to convert system/fvSolution (with -test option) motion solver syntax left as-is. --- .../foamUpgradeFvSolution/Make/files | 3 + .../foamUpgradeFvSolution/Make/options | 0 .../foamUpgradeFvSolution.C | 104 ++++++++++++++++++ .../matrices/lduMatrix/lduMatrix/lduMatrix.H | 31 +++--- .../lduMatrix/lduMatrixPreconditioner.C | 73 +++++++++--- .../lduMatrix/lduMatrix/lduMatrixSmoother.C | 40 ++++--- .../lduMatrix/lduMatrix/lduMatrixSolver.C | 46 ++++---- .../DICPreconditioner/DICPreconditioner.C | 2 +- .../DICPreconditioner/DICPreconditioner.H | 6 +- .../DILUPreconditioner/DILUPreconditioner.C | 2 +- .../DILUPreconditioner/DILUPreconditioner.H | 9 +- .../FDICPreconditioner/FDICPreconditioner.C | 4 +- .../FDICPreconditioner/FDICPreconditioner.H | 6 +- .../GAMGPreconditioner/GAMGPreconditioner.C | 12 +- .../GAMGPreconditioner/GAMGPreconditioner.H | 20 ++-- .../diagonalPreconditioner.C | 6 +- .../diagonalPreconditioner.H | 16 +-- .../noPreconditioner/noPreconditioner.C | 6 +- .../noPreconditioner/noPreconditioner.H | 14 +-- .../lduMatrix/smoothers/DIC/DICSmoother.H | 6 +- .../DICGaussSeidel/DICGaussSeidelSmoother.H | 9 +- .../lduMatrix/smoothers/DILU/DILUSmoother.H | 7 +- .../DILUGaussSeidel/DILUGaussSeidelSmoother.H | 9 +- .../matrices/lduMatrix/solvers/BICCG/BICCG.C | 55 ++++----- .../matrices/lduMatrix/solvers/BICCG/BICCG.H | 61 +++++----- .../lduMatrix/solvers/GAMG/GAMGSolver.C | 7 +- .../lduMatrix/solvers/GAMG/GAMGSolver.H | 4 +- .../lduMatrix/solvers/GAMG/GAMGSolverSolve.C | 4 +- .../matrices/lduMatrix/solvers/ICCG/ICCG.C | 57 ++++------ .../matrices/lduMatrix/solvers/ICCG/ICCG.H | 58 ++++------ .../matrices/lduMatrix/solvers/PBiCG/PBiCG.C | 10 +- .../matrices/lduMatrix/solvers/PBiCG/PBiCG.H | 2 +- .../matrices/lduMatrix/solvers/PCG/PCG.C | 10 +- .../matrices/lduMatrix/solvers/PCG/PCG.H | 6 +- .../solvers/diagonalSolver/diagonalSolver.C | 10 +- .../solvers/diagonalSolver/diagonalSolver.H | 7 +- .../solvers/smoothSolver/smoothSolver.C | 13 +-- .../solvers/smoothSolver/smoothSolver.H | 10 +- src/OpenFOAM/matrices/solution/solution.C | 89 ++++++++++++++- src/OpenFOAM/matrices/solution/solution.H | 18 +-- .../fvMatrices/fvMatrix/fvMatrix.C | 8 +- .../fvMatrices/fvMatrix/fvMatrix.H | 24 ++-- .../fvMatrices/fvMatrix/fvMatrixSolve.C | 14 +-- .../fvScalarMatrix/fvScalarMatrix.C | 16 +-- .../fvScalarMatrix/fvScalarMatrix.H | 18 ++- .../fvMatrices/solvers/MULES/MULESTemplates.C | 4 +- .../displacementSBRStressFvMotionSolver.C | 2 +- .../displacementSBRStressFvMotionSolver.H | 4 +- ...lacementComponentLaplacianFvMotionSolver.H | 3 +- .../displacementInterpolationFvMotionSolver.C | 2 +- .../displacementInterpolationFvMotionSolver.H | 5 +- .../displacementLaplacianFvMotionSolver.C | 2 +- .../displacementLaplacianFvMotionSolver.H | 4 +- ...velocityComponentLaplacianFvMotionSolver.H | 3 +- .../velocityLaplacianFvMotionSolver.C | 2 +- .../velocityLaplacianFvMotionSolver.H | 6 +- 56 files changed, 575 insertions(+), 394 deletions(-) create mode 100644 applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files create mode 100644 applications/utilities/preProcessing/foamUpgradeFvSolution/Make/options create mode 100644 applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files new file mode 100644 index 0000000000..f667ed655e --- /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 0000000000..e69de29bb2 diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C b/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C new file mode 100644 index 0000000000..d9e1402a34 --- /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 33fcda639d..6a6a09ab92 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -259,7 +259,7 @@ public: const FieldField& interfaceBouCoeffs, const FieldField& 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& interfaceBouCoeffs, const FieldField& 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& interfaceBouCoeffs, const FieldField& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); // Selectors @@ -317,7 +317,7 @@ public: const FieldField& interfaceBouCoeffs, const FieldField& 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& interfaceBouCoeffs, const FieldField& 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 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 82f9a19ac2..cb4a645df1 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::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 7554e4085c..e9aa429683 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::New @@ -44,23 +43,37 @@ Foam::autoPtr Foam::lduMatrix::smoother::New const FieldField& interfaceBouCoeffs, const FieldField& 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::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::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(NULL); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 19fd2435a0..4b3b8d97a9 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::New const FieldField& interfaceBouCoeffs, const FieldField& 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::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::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::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } @@ -129,7 +127,7 @@ Foam::autoPtr 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& interfaceBouCoeffs, const FieldField& 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