ENH: IOobject::selectIO helper method

- centralizes IOobject handling and treatment of alternative locations.
  If an alternative file location is specified, it will be used instead.

- provide decompositionMethod::canonicalName instead of using
  "decomposeParDict" in various places.
This commit is contained in:
Mark Olesen
2018-08-02 17:39:17 +02:00
parent 0e996431b7
commit 88e5334a9f
24 changed files with 303 additions and 402 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -141,53 +141,28 @@ int main(int argc, char *argv[])
if (args.found("from") || args.found("to"))
{
autoPtr<IOobject> ioPtr;
if (args.found("dict"))
{
const fileName dictPath = args["dict"];
ioPtr.reset
IOobject ioCsys = IOobject::selectIO
(
IOobject
(
new IOobject
(
(
isDir(dictPath)
? dictPath/coordinateSystems::typeName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
ioPtr.reset
(
new IOobject
(
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
args.lookupOrDefault<fileName>("dict", "")
);
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl
<< ioCsys.objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(ioPtr());
coordinateSystems csLst(ioCsys);
if (args.found("from"))
{