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

@ -149,7 +149,7 @@ int main(int argc, char *argv[])
{
if (isDir(dictPath))
{
dictPath = dictPath / dictName;
dictPath /= dictName;
}
}
// Check if dictionary is present in the constant directory
@ -255,10 +255,9 @@ int main(int argc, char *argv[])
const pointField& cellCentres = topo.cellCentres();
forAll(cellCentres, celli)
for (const point& cc : cellCentres)
{
//point cc = b.blockShape().centre(b.points());
const point& cc = cellCentres[celli];
str << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl;
}
@ -388,9 +387,9 @@ int main(int argc, char *argv[])
{
const polyPatchList& patches = mesh.boundaryMesh();
bool hasCyclic = false;
forAll(patches, patchi)
for (const polyPatch& pp : patches)
{
if (isA<cyclicPolyPatch>(patches[patchi]))
if (isA<cyclicPolyPatch>(pp))
{
hasCyclic = true;
break;

View File

@ -788,32 +788,29 @@ int main(int argc, char *argv[])
dictionary decomposeDict;
if (Pstream::parRun())
{
fileName decompDictFile;
args.readIfPresent("decomposeParDict", decompDictFile);
// A demand-driven decompositionMethod can have issues finding
// an alternative decomposeParDict location.
// Ensure demand-driven decompositionMethod finds alternative
// decomposeParDict location properly.
IOdictionary* dictPtr = new IOdictionary
(
decompositionModel::selectIO
IOobject::selectIO
(
IOobject
(
"decomposeParDict",
decompositionModel::canonicalName,
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
decompDictFile
args.lookupOrDefault<fileName>("decomposeParDict", "")
)
);
// Store it on the object registry, but to be found it must also
// have the expected "decomposeParDict" name.
dictPtr->rename("decomposeParDict");
dictPtr->rename(decompositionModel::canonicalName);
runTime.store(dictPtr);
decomposeDict = *dictPtr;
@ -1425,7 +1422,7 @@ int main(int argc, char *argv[])
decomposeDict
)
);
decompositionMethod& decomposer = decomposerPtr();
decompositionMethod& decomposer = *decomposerPtr;
if (Pstream::parRun() && !decomposer.parallelAware())
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -182,7 +182,6 @@ int main(int argc, char *argv[])
// Read/construct control dictionary
//
const bool readDict = args.found("dict");
const bool refineAllCells = args.found("all");
const bool overwrite = args.found("overwrite");
@ -191,55 +190,57 @@ int main(int argc, char *argv[])
// Dictionary to control refinement
dictionary refineDict;
const word dictName("refineMeshDict");
if (readDict)
// The -all option has precedence over -dict, or anything else
if (!refineAllCells)
{
fileName dictPath = args["dict"];
if (isDir(dictPath))
{
dictPath = dictPath/dictName;
}
const word dictName("refineMeshDict");
IOobject dictIO
// Obtain dictPath here for messages
fileName dictPath = args.lookupOrDefault<fileName>("dict", "");
IOobject dictIO = IOobject::selectIO
(
dictPath,
mesh,
IOobject::MUST_READ
IOobject
(
dictName,
runTime.system(),
mesh,
IOobject::MUST_READ
),
dictPath
);
if (!dictIO.typeHeaderOk<IOdictionary>(true))
// The reported dictPath will not be full resolved for the output
// (it will just be the -dict value) but this is purely cosmetic.
if (dictIO.typeHeaderOk<IOdictionary>(true))
{
refineDict = IOdictionary(dictIO);
Info<< "Refining according to ";
if (dictPath.empty())
{
Info<< dictName;
}
else
{
Info<< dictPath;
}
Info<< nl << endl;
}
else if (dictPath.empty())
{
Info<< "Refinement dictionary " << dictName << " not found" << nl;
}
else
{
FatalErrorInFunction
<< "Cannot open specified refinement dictionary "
<< dictPath
<< exit(FatalError);
}
Info<< "Refining according to " << dictPath << nl << endl;
refineDict = IOdictionary(dictIO);
}
else if (!refineAllCells)
{
IOobject dictIO
(
dictName,
runTime.system(),
mesh,
IOobject::MUST_READ
);
if (dictIO.typeHeaderOk<IOdictionary>(true))
{
Info<< "Refining according to " << dictName << nl << endl;
refineDict = IOdictionary(dictIO);
}
else
{
Info<< "Refinement dictionary " << dictName << " not found" << endl;
}
}
if (refineDict.size())
@ -346,9 +347,8 @@ int main(int argc, char *argv[])
// Create cellSet with added cells for easy inspection
cellSet newCells(mesh, "refinedCells", refCells.size());
forAll(oldToNew, oldCelli)
for (const labelList& added : oldToNew)
{
const labelList& added = oldToNew[oldCelli];
newCells.insert(added);
}
@ -361,7 +361,6 @@ int main(int argc, char *argv[])
newCells.write();
//
// Invert cell split to construct map from new to old
//
@ -392,9 +391,9 @@ int main(int argc, char *argv[])
if (added.size())
{
forAll(added, i)
for (const label celli : added)
{
newToOld[added[i]] = oldCelli;
newToOld[celli] = oldCelli;
}
}
else

View File

@ -392,11 +392,11 @@ int main(int argc, char *argv[])
(
IOdictionary
(
decompositionModel::selectIO
IOobject::selectIO
(
IOobject
(
"decomposeParDict",
decompositionModel::canonicalName,
runTime.time().system(),
regionDir, // region (if non-default)
runTime,

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.
@ -51,29 +51,22 @@ int readNumProcs
const Time& runTime
)
{
const word dictName = "decomposeParDict";
fileName dictFile;
if (args.readIfPresent(optionName, dictFile) && isDir(dictFile))
{
dictFile = dictFile / dictName;
}
return decompositionMethod::nDomains
(
IOdictionary
(
decompositionModel::selectIO
IOobject::selectIO
(
IOobject
(
dictName,
decompositionModel::canonicalName,
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
false // do not register
),
dictFile
args.lookupOrDefault<fileName>(optionName, "")
)
)
);

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.
@ -152,59 +152,29 @@ int main(int argc, char *argv[])
if (args.found("from") || args.found("to"))
{
autoPtr<IOobject> csDictIoPtr;
const word dictName("coordinateSystems::typeName");
// Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary
// is in constant
fileName dictPath;
if (args.readIfPresent("dict", dictPath) && isDir(dictPath))
{
dictPath = dictPath / dictName;
}
if (dictPath.size())
{
csDictIoPtr.reset
IOobject ioCsys = IOobject::selectIO
(
IOobject
(
new IOobject
(
dictPath,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
csDictIoPtr.reset
(
new IOobject
(
dictName,
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 (!csDictIoPtr->typeHeaderOk<coordinateSystems>(false))
if (!ioCsys.typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< "Cannot open coordinateSystems file\n "
<< csDictIoPtr->objectPath() << nl
<< ioCsys.objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(csDictIoPtr());
coordinateSystems csLst(ioCsys);
if (args.found("from"))
{

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"))
{

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.
@ -154,53 +154,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"))
{

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 | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -159,32 +159,29 @@ int main(int argc, char *argv[])
// -decomposeParDict option.
if (distType == distributedTriSurfaceMesh::INDEPENDENT)
{
fileName decompDictFile;
args.readIfPresent("decomposeParDict", decompDictFile);
// A demand-driven decompositionMethod can have issues finding
// an alternative decomposeParDict location.
// Ensure demand-driven decompositionMethod finds alternative
// decomposeParDict location properly.
IOdictionary* dictPtr = new IOdictionary
(
decompositionModel::selectIO
IOobject::selectIO
(
IOobject
(
"decomposeParDict",
decompositionModel::canonicalName,
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
decompDictFile
args.lookupOrDefault<fileName>("decomposeParDict", "")
)
);
// Store it on the object registry, but to be found it must also
// have the expected "decomposeParDict" name.
dictPtr->rename("decomposeParDict");
dictPtr->rename(decompositionModel::canonicalName);
runTime.store(dictPtr);
}

View File

@ -192,6 +192,51 @@ bool Foam::IOobject::fileNameComponents
}
Foam::IOobject Foam::IOobject::selectIO
(
const IOobject& io,
const fileName& altFile,
const word& ioName
)
{
if (altFile.empty())
{
return io;
}
// Construct from file path instead
fileName altPath = altFile;
if (isDir(altPath))
{
// Resolve directories as well
if (ioName.empty())
{
altPath /= io.name();
}
else
{
altPath /= ioName;
}
}
altPath.expand();
return
IOobject
(
altPath,
io.db(),
io.readOpt(),
io.writeOpt(),
io.registerObject(),
io.globalObject()
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IOobject::IOobject
@ -339,12 +384,6 @@ Foam::IOobject::IOobject
{}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOobject::~IOobject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::objectRegistry& Foam::IOobject::db() const
@ -371,28 +410,14 @@ const Foam::fileName& Foam::IOobject::caseName() const
}
Foam::word Foam::IOobject::group() const
{
return name_.ext();
}
Foam::word Foam::IOobject::member() const
{
return name_.lessExt();
}
Foam::fileName Foam::IOobject::path() const
{
if (isOutsideOfCase(instance()))
{
return instance();
}
else
{
return rootPath()/caseName()/instance()/db_.dbDir()/local();
}
return rootPath()/caseName()/instance()/db_.dbDir()/local();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ Class
Foam::IOobject
Description
IOobject defines the attributes of an object for which implicit
Defines the attributes of an object for which implicit
objectRegistry management is supported, and provides the infrastructure
for performing stream I/O.
@ -83,6 +83,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
class Time;
class objectRegistry;
@ -184,7 +185,7 @@ public:
TypeName("IOobject");
// Static data members
// Static Data Members
//- Type of file modification checking
static fileCheckTypes fileModificationChecking;
@ -219,6 +220,27 @@ public:
template<class StringType>
static inline word groupName(StringType name, const word& group);
//- Return the IOobject, but also consider an alternative file name.
//
// \param io The expected IOobject to use
// \param altFile Alternative fileName (ignored if empty).
// \param ioName The alternative name for the IOobject when
// the altFile resolves to a directory.
//
// \note If the alternative fileName is a non-empty string,
// it defines the location but uses all other properties of the
// expected IOobject.
// The location may be an absolute or a relative path.
// If it corresponds to a directory, the name of the
// expected IOobject will be used in its resolution.
// This expected name can provided via the ioName parameter.
static IOobject selectIO
(
const IOobject& io,
const fileName& altFile,
const word& ioName = ""
);
// Constructors
@ -290,7 +312,7 @@ public:
//- Destructor
virtual ~IOobject();
virtual ~IOobject() = default;
// Member Functions
@ -355,10 +377,10 @@ public:
// Path components
//- Return group (extension part of name)
word group() const;
inline word group() const;
//- Return member (name without the extension)
word member() const;
inline word member() const;
const fileName& rootPath() const;
@ -370,17 +392,17 @@ public:
inline const fileName& local() const;
//- Return complete path
//- The complete path
fileName path() const;
//- Return complete path with alternative instance and local
//- The complete path with alternative instance and local
fileName path
(
const word& instance,
const fileName& local = fileName::null
) const;
//- Return complete path + object name
//- The complete path + object name
inline fileName objectPath() const;
//- Helper for filePath that searches locally.

View File

@ -32,10 +32,8 @@ inline Foam::word Foam::IOobject::groupName(StringType name, const word& group)
{
return name;
}
else
{
return name + ('.' + group);
}
return name + ('.' + group);
}
@ -49,6 +47,18 @@ inline const Foam::word& Foam::IOobject::name() const
}
inline Foam::word Foam::IOobject::group() const
{
return name_.ext();
}
inline Foam::word Foam::IOobject::member() const
{
return name_.lessExt();
}
inline const Foam::word& Foam::IOobject::headerClassName() const
{
return headerClassName_;

View File

@ -26,7 +26,7 @@ License
#include "IOobject.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::IOobject::readHeader(Istream& is)
{

View File

@ -21,10 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Writes the header description of the File to the stream
associated with the File.
\*---------------------------------------------------------------------------*/
#include "IOobject.H"

View File

@ -1,28 +1,12 @@
fileName dictPath;
if (args.readIfPresent("dict", dictPath))
{
if (isDir(dictPath))
{
dictPath = dictPath / dictName;
}
}
IOobject dictIO
IOobject dictIO = IOobject::selectIO
(
dictName,
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
);
if (dictPath.size())
{
dictIO = IOobject
IOobject
(
dictPath,
dictName,
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
);
}
),
args.lookupOrDefault<fileName>("dict", "")
);

View File

@ -0,0 +1,12 @@
IOobject dictIO = IOobject::selectIO
(
IOobject
(
dictName,
runTime.constant(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
),
args.lookupOrDefault<fileName>("dict", "")
);

View File

@ -1,28 +1,12 @@
fileName dictPath;
if (args.readIfPresent("dict", dictPath))
{
if (isDir(dictPath))
{
dictPath = dictPath / dictName;
}
}
IOobject dictIO
IOobject dictIO = IOobject::selectIO
(
dictName,
runTime.system(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
);
if (dictPath.size())
{
dictIO = IOobject
IOobject
(
dictPath.expand(),
dictName,
runTime.system(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
);
}
),
args.lookupOrDefault<fileName>("dict", "")
);

View File

@ -1,28 +1,12 @@
fileName dictPath;
if (args.readIfPresent("dict", dictPath))
{
if (isDir(dictPath))
{
dictPath = dictPath / dictName;
}
}
IOobject dictIO
IOobject dictIO = IOobject::selectIO
(
dictName,
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
);
if (dictPath.size())
{
dictIO = IOobject
IOobject
(
dictPath.expand(),
dictName,
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
);
}
),
args.lookupOrDefault<fileName>("dict", "")
);

View File

@ -41,7 +41,7 @@ Foam::lumpedPointIOMovement::lookupInRegistry(const objectRegistry& obr)
{
return obr.lookupObjectPtr<lumpedPointIOMovement>
(
lumpedPointMovement::dictionaryName
lumpedPointMovement::canonicalName
);
}
@ -57,7 +57,7 @@ Foam::lumpedPointIOMovement::New
(
IOobject
(
lumpedPointMovement::dictionaryName,
lumpedPointMovement::canonicalName,
obr.time().caseSystem(),
obr,
IOobject::MUST_READ,

View File

@ -61,7 +61,7 @@ Foam::lumpedPointMovement::scalingNames
const Foam::word
Foam::lumpedPointMovement::dictionaryName("lumpedPointMovement");
Foam::lumpedPointMovement::canonicalName("lumpedPointMovement");
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
@ -117,31 +117,6 @@ static void writeList(Ostream& os, const string& header, const UList<T>& list)
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::IOobject Foam::lumpedPointMovement::selectIO
(
const IOobject& io,
const fileName& f
)
{
return
(
f.size()
? IOobject // construct from filePath instead
(
f,
io.db(),
io.readOpt(),
io.writeOpt(),
io.registerObject(),
io.globalObject()
)
: io
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::lumpedPointMovement::calcThresholds() const

View File

@ -238,11 +238,8 @@ public:
// Static data members
//- The standard dictionary name
static const word dictionaryName;
//- Helper: return IOobject with optionally absolute path provided
static IOobject selectIO(const IOobject&, const fileName&);
//- The canonical name ("lumpedPointMovement") for the dictionary
static const word canonicalName;
// Constructors
@ -460,6 +457,22 @@ public:
const labelUList& patchLst,
const pointField& points0
) const;
// Housekeeping
//- Compatibility method
// \deprecated use IOobject::selectIO directly (AUG-2018)
static IOobject selectIO
(
const IOobject& io,
const fileName& altFile,
const word& ioName = ""
)
{
return IOobject::selectIO(io, altFile, ioName);
}
};

View File

@ -34,6 +34,8 @@ namespace Foam
defineTypeNameAndDebug(decompositionModel, 0);
}
const Foam::word Foam::decompositionModel::canonicalName("decomposeParDict");
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -51,11 +53,11 @@ Foam::decompositionModel::decompositionModel
>(mesh),
IOdictionary
(
selectIO
IOobject::selectIO
(
IOobject
(
"decomposeParDict",
canonicalName,
mesh.time().system(),
mesh.local(),
mesh.thisDb(),
@ -85,11 +87,11 @@ Foam::decompositionModel::decompositionModel
>(mesh),
IOdictionary
(
selectIO
IOobject::selectIO
(
IOobject
(
"decomposeParDict",
canonicalName,
mesh.time().system(),
mesh.local(),
mesh.thisDb(),
@ -140,29 +142,4 @@ const Foam::decompositionModel& Foam::decompositionModel::New
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::IOobject Foam::decompositionModel::selectIO
(
const IOobject& io,
const fileName& f
)
{
return
(
f.size()
? IOobject // construct from filePath instead
(
f,
io.db(),
io.readOpt(),
io.writeOpt(),
io.registerObject(),
io.globalObject()
)
: io
);
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,6 +28,7 @@ Description
MeshObject wrapper of decompositionMethod
SourceFiles
decompositionModel.C
\*---------------------------------------------------------------------------*/
@ -43,7 +44,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward declarations
class mapPolyMesh;
class polyMesh;
@ -62,7 +63,7 @@ class decompositionModel
public IOdictionary
{
// Private data
// Private Data
mutable autoPtr<decompositionMethod> decomposerPtr_;
@ -72,17 +73,21 @@ public:
// Declare name of the class and its debug switch
ClassName("decompositionModel");
//- The canonical name ("decomposeParDict") under which the
//- MeshObject is registered
static const word canonicalName;
// Selectors
//- Read (optionally from absolute path) & register on mesh
//- Read (optionally from absolute path) and register on mesh
static const decompositionModel& New
(
const polyMesh& mesh,
const fileName& decompDictFile = ""
);
//- Read (optionally from supplied dictionary) & register on mesh
//- Read (optionally from supplied dictionary) and register on mesh
static const decompositionModel& New
(
const polyMesh& mesh,
@ -126,9 +131,6 @@ public:
return *decomposerPtr_;
}
//- Helper: return IOobject with optionally absolute path provided
static IOobject selectIO(const IOobject& io, const fileName& f);
// UpdateableMeshObject
@ -140,6 +142,21 @@ public:
virtual void updateMesh(const mapPolyMesh&)
{}
// Housekeeping
//- Compatibility method
// \deprecated use IOobject::selectIO directly (AUG-2018)
static IOobject selectIO
(
const IOobject& io,
const fileName& altFile,
const word& ioName = ""
)
{
return IOobject::selectIO(io, altFile, ioName);
}
};

View File

@ -806,21 +806,17 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
{
// Use singleton decomposeParDict. Cannot use decompositionModel
// here since we've only got Time and not a mesh.
if
(
searchableSurface::time().foundObject<IOdictionary>
const auto* dictPtr =
searchableSurface::time().lookupObjectPtr<IOdictionary>
(
// == decompositionModel::canonicalName
"decomposeParDict"
)
)
{
decomposer_ = decompositionMethod::New
(
searchableSurface::time().lookupObject<IOdictionary>
(
"decomposeParDict"
)
);
if (dictPtr)
{
decomposer_ = decompositionMethod::New(*dictPtr);
}
else
{
@ -832,6 +828,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
(
IOobject
(
// == decompositionModel::canonicalName
"decomposeParDict",
searchableSurface::time().system(),
searchableSurface::time(),