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.
This commit is contained in:
Mark Olesen
2008-12-08 17:22:01 +01:00
parent 507e7a1b98
commit 4f1bb8345f
56 changed files with 575 additions and 394 deletions

View File

@ -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);
}