IOobject: Simplified and rationalised the handling for filePath
for local and global files so that the reading and writing of local files to processor directories and global files to the case directory are consistent.
This commit is contained in:
@ -339,7 +339,7 @@ bool Foam::IOobject::global() const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::IOobject::globalWrite() const
|
||||
bool Foam::IOobject::globalFile() const
|
||||
{
|
||||
return global();
|
||||
}
|
||||
@ -353,7 +353,7 @@ const Foam::fileName& Foam::IOobject::rootPath() const
|
||||
|
||||
const Foam::fileName& Foam::IOobject::caseName() const
|
||||
{
|
||||
if (globalWrite())
|
||||
if (globalFile())
|
||||
{
|
||||
return time().globalCaseName();
|
||||
}
|
||||
@ -421,17 +421,13 @@ Foam::fileName Foam::IOobject::localPath() const
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::IOobject::localFilePath(const word& typeName) const
|
||||
Foam::fileName Foam::IOobject::filePath
|
||||
(
|
||||
const word& typeName,
|
||||
const bool isGlobal
|
||||
) const
|
||||
{
|
||||
// Do not check for undecomposed files
|
||||
return fileHandler().filePath(false, *this, typeName);
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::IOobject::globalFilePath(const word& typeName) const
|
||||
{
|
||||
// Check for undecomposed files
|
||||
return fileHandler().filePath(true, *this, typeName);
|
||||
return fileHandler().filePath(isGlobal, *this, typeName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -392,7 +392,7 @@ public:
|
||||
// and written to the global case directory,
|
||||
// i.e. not the processor time directory
|
||||
// Defaults to global()
|
||||
virtual bool globalWrite() const;
|
||||
virtual bool globalFile() const;
|
||||
|
||||
const fileName& rootPath() const;
|
||||
|
||||
@ -433,11 +433,12 @@ public:
|
||||
return localPath()/name();
|
||||
}
|
||||
|
||||
//- Helper for filePath that searches locally.
|
||||
fileName localFilePath(const word& typeName) const;
|
||||
|
||||
//- Helper for filePath that searches up if in parallel
|
||||
fileName globalFilePath(const word& typeName) const;
|
||||
//- Return complete path + object name if the file exists
|
||||
// in the case directory otherwise null.
|
||||
//
|
||||
// If isGlobal and parallel searches up into the global case
|
||||
// directory.
|
||||
fileName filePath(const word& typeName, const bool isGlobal) const;
|
||||
|
||||
|
||||
// Reading
|
||||
@ -508,7 +509,6 @@ public:
|
||||
template<>
|
||||
Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
template<class T>
|
||||
inline bool typeGlobal()
|
||||
@ -516,16 +516,18 @@ inline bool typeGlobal()
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Template function for obtaining global write status
|
||||
template<class T>
|
||||
inline bool typeGlobalFile()
|
||||
{
|
||||
return typeGlobal<T>();
|
||||
}
|
||||
|
||||
//- Template function for obtaining filePath
|
||||
template<class T>
|
||||
inline fileName typeFilePath(const IOobject& io)
|
||||
{
|
||||
return
|
||||
(
|
||||
typeGlobal<T>()
|
||||
? io.globalFilePath(T::typeName)
|
||||
: io.localFilePath(T::typeName)
|
||||
);
|
||||
return io.filePath(T::typeName, typeGlobalFile<T>());
|
||||
}
|
||||
|
||||
inline IOobject unregister(const IOobject& io)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,7 +37,7 @@ bool Foam::IOobject::typeHeaderOk(const bool checkType)
|
||||
bool ok = true;
|
||||
|
||||
// Everyone check or just master
|
||||
bool masterOnly =
|
||||
const bool masterOnly =
|
||||
typeGlobal<Type>()
|
||||
&& (
|
||||
IOobject::fileModificationChecking == timeStampMaster
|
||||
@ -49,7 +49,7 @@ bool Foam::IOobject::typeHeaderOk(const bool checkType)
|
||||
// Determine local status
|
||||
if (!masterOnly || Pstream::master())
|
||||
{
|
||||
fileName fName(typeFilePath<Type>(*this));
|
||||
const fileName fName(typeFilePath<Type>(*this));
|
||||
|
||||
ok = fp.readHeader(*this, fName, Type::typeName);
|
||||
if (ok && checkType && headerClassName_ != Type::typeName)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -92,13 +92,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
//- ReadData function required for regIOobject read operation
|
||||
virtual bool readData(Istream&);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -92,13 +92,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
//- ReadData function required for regIOobject read operation
|
||||
virtual bool readData(Istream&);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,7 +26,7 @@ Typedef
|
||||
|
||||
Description
|
||||
Typedefs for GlobalIOLists of primitive types. These are fully compatible
|
||||
with 'normal' IOLists except have global filePath() scope.
|
||||
with 'normal' IOLists except have global files.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -93,13 +93,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,13 +29,6 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTemplateTypeNameAndDebug(IOMap<dictionary>, 0);
|
||||
|
||||
//- Template specialisation for obtaining filePath
|
||||
template<>
|
||||
fileName typeFilePath<IOMap<dictionary>>(const IOobject& io)
|
||||
{
|
||||
return io.globalFilePath(IOMap<dictionary>::typeName);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -107,13 +107,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
//- ReadData function required for regIOobject read operation
|
||||
virtual bool readData(Istream&);
|
||||
|
||||
|
||||
@ -76,14 +76,6 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// in the case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
// Use default (local only) search strategy
|
||||
return localFilePath(type());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::timeIOdictionary
|
||||
|
||||
Description
|
||||
timeIOdictionary derived from IOdictionary with globalWrite set false to
|
||||
timeIOdictionary derived from IOdictionary with globalFile set false to
|
||||
enable writing to processor time directories.
|
||||
|
||||
Used for time-dependent global data written to the <time>/uniform
|
||||
@ -70,13 +70,21 @@ public:
|
||||
|
||||
//- Return false as the object is global, i.e. same for all processors
|
||||
// but written to the processor time directory
|
||||
virtual bool globalWrite() const
|
||||
virtual bool globalFile() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global write status
|
||||
template<>
|
||||
inline bool typeGlobalFile<timeIOdictionary>()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -390,7 +390,7 @@ void Foam::regIOobject::rename(const word& newName)
|
||||
|
||||
Foam::fileName Foam::regIOobject::filePath() const
|
||||
{
|
||||
return localFilePath(type());
|
||||
return IOobject::filePath(type(), globalFile());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -211,11 +211,14 @@ public:
|
||||
|
||||
// Reading
|
||||
|
||||
using IOobject::filePath;
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// in the case directory otherwise null. Does not search
|
||||
// up if parallel. Can be overridden to provide this functionality
|
||||
// (e.g. IOdictionary)
|
||||
virtual fileName filePath() const;
|
||||
// in the case directory otherwise null.
|
||||
//
|
||||
// For global objects in parallel searches up into the global
|
||||
// case directory
|
||||
fileName filePath() const;
|
||||
|
||||
//- Read and check header info
|
||||
bool headerOk();
|
||||
|
||||
@ -62,7 +62,7 @@ bool Foam::regIOobject::writeObject
|
||||
// Write global objects on master only
|
||||
// Everyone check or just master
|
||||
bool masterOnly =
|
||||
globalWrite()
|
||||
globalFile()
|
||||
&& (
|
||||
regIOobject::fileModificationChecking == timeStampMaster
|
||||
|| regIOobject::fileModificationChecking == inotifyMaster
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -103,13 +103,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
//- Return the non-dimensioned field
|
||||
FieldType field() const
|
||||
{
|
||||
|
||||
@ -110,13 +110,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
|
||||
// Checks
|
||||
|
||||
|
||||
@ -123,13 +123,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
|
||||
// Checks
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -140,13 +140,6 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -91,13 +91,6 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -47,12 +47,8 @@ Foam::fileName Foam::triSurfaceMesh::checkFile
|
||||
const bool isGlobal
|
||||
)
|
||||
{
|
||||
const fileName fName
|
||||
(
|
||||
isGlobal
|
||||
? io.globalFilePath(typeName)
|
||||
: io.localFilePath(typeName)
|
||||
);
|
||||
const fileName fName(io.filePath(typeName, isGlobal));
|
||||
|
||||
if (fName.empty())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -112,12 +108,7 @@ Foam::fileName Foam::triSurfaceMesh::checkFile
|
||||
}
|
||||
else
|
||||
{
|
||||
fName =
|
||||
(
|
||||
isGlobal
|
||||
? io.globalFilePath(typeName)
|
||||
: io.localFilePath(typeName)
|
||||
);
|
||||
fName = io.filePath(typeName, isGlobal);
|
||||
|
||||
if (!exists(fName))
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -353,13 +353,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return searchableSurface::globalFilePath(type());
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -461,13 +461,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return searchableSurface::localFilePath(type());
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
Reference in New Issue
Block a user