ENH: improve consistency in handling of global IOobjects (#3045)
- replace typeGlobal() global function with is_globalIOobject traits for more consistent and easier overriding. - relocate typeFilePath() global function as a member of IOobject for consistency with typeHeaderOk. BUG: faSchemes, fvSchemes not marked as global file types - caused issues with collated
This commit is contained in:
parent
43143f21d2
commit
13352861c8
@ -1,3 +1,3 @@
|
||||
Test-IOField.C
|
||||
Test-IOField.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IOField
|
||||
|
@ -206,6 +206,22 @@ int main(int argc, char *argv[])
|
||||
Info<< "Serial: using " << sz << nl;
|
||||
}
|
||||
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"points",
|
||||
mesh.time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "points path: " << io.typeFilePath<labelIOList>() << nl;
|
||||
Info<< "points path: " << io.typeFilePath<void>() << nl;
|
||||
|
||||
io.resetHeader("bad-points");
|
||||
Info<< "bad path: " << io.typeFilePath<void>() << nl;
|
||||
}
|
||||
|
||||
IOobject io
|
||||
(
|
||||
"bla",
|
3
applications/test/IOobject-type/Make/files
Normal file
3
applications/test/IOobject-type/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-IOobject-type.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IOobject-type
|
9
applications/test/IOobject-type/Make/options
Normal file
9
applications/test/IOobject-type/Make/options
Normal file
@ -0,0 +1,9 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteArea \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools
|
80
applications/test/IOobject-type/Test-IOobject-type.cxx
Normal file
80
applications/test/IOobject-type/Test-IOobject-type.cxx
Normal file
@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Report global/local path for various types
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "IOobject.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "IOMap.H"
|
||||
#include "coordinateSystems.H"
|
||||
#include "faSchemes.H"
|
||||
#include "fvSchemes.H"
|
||||
#include "schemesLookup.H"
|
||||
#include "scalarIOList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
template<class Type>
|
||||
word report()
|
||||
{
|
||||
if (is_globalIOobject<Type>::value)
|
||||
{
|
||||
return "global";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "local";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "void: " << report<void>() << nl;
|
||||
Info<< "IOobject: " << report<IOobject>() << nl;
|
||||
Info<< "IOdictionary: " << report<IOdictionary>() << nl;
|
||||
Info<< "faSchemes: " << report<faSchemes>() << nl;
|
||||
Info<< "fvSchemes: " << report<fvSchemes>() << nl;
|
||||
Info<< "schemesLookup: " << report<schemesLookup>() << nl;
|
||||
Info<< "coordinateSystems: " << report<coordinateSystems>() << nl;
|
||||
Info<< "IOMap<labelList>: " << report<IOMap<labelList>>() << nl;
|
||||
Info<< "IOMap<dictionary>: " << report<IOMap<dictionary>>() << nl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -79,8 +79,8 @@ void rewriteBoundary
|
||||
HashTable<word>& nbrNames
|
||||
)
|
||||
{
|
||||
Info<< "Reading boundary from " << typeFilePath<IOPtrList<entry>>(io)
|
||||
<< endl;
|
||||
Info<< "Reading boundary from "
|
||||
<< io.typeFilePath<IOPtrList<entry>>() << nl;
|
||||
|
||||
// Read PtrList of dictionary.
|
||||
const word oldTypeName = IOPtrList<entry>::typeName;
|
||||
|
@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
// Look for file (using searchableSurface rules)
|
||||
const fileName actualPath(typeFilePath<searchableSurface>(io));
|
||||
const fileName actualPath(io.typeFilePath<searchableSurface>());
|
||||
fileName localPath(actualPath);
|
||||
localPath.replace(runTime.rootPath() + '/', "");
|
||||
|
||||
|
@ -561,6 +561,17 @@ Foam::fileName Foam::IOobject::globalFilePath
|
||||
}
|
||||
|
||||
|
||||
// Foam::fileName Foam::IOobject::filePath
|
||||
// (
|
||||
// const bool isGlobal,
|
||||
// const word& typeName,
|
||||
// const bool search
|
||||
// ) const
|
||||
// {
|
||||
// return fileHandler().filePath(isGlobal, *this, typeName, search);
|
||||
// }
|
||||
|
||||
|
||||
void Foam::IOobject::setBad(const string& s)
|
||||
{
|
||||
if (objState_ != objectState::GOOD)
|
||||
|
@ -105,6 +105,7 @@ SourceFiles
|
||||
#include "InfoProxy.H"
|
||||
#include "IOobjectOption.H"
|
||||
#include "IOstreamOption.H"
|
||||
#include <type_traits>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -196,6 +197,19 @@ private:
|
||||
//- Construct from registry, io options. Without name, instance, local
|
||||
IOobject(const objectRegistry& registry, IOobjectOption ioOpt);
|
||||
|
||||
//- Read header and check its info.
|
||||
// Optionally checks headerClassName against the type-name.
|
||||
// When search is false, simply use the current instance,
|
||||
// otherwise search previous instances.
|
||||
bool readAndCheckHeader
|
||||
(
|
||||
const bool isGlobal,
|
||||
const word& typeName,
|
||||
const bool checkType = true,
|
||||
const bool search = true,
|
||||
const bool verbose = true
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -621,22 +635,42 @@ public:
|
||||
// Saves the header content in the given dictionary.
|
||||
bool readHeader(dictionary& headerDict, Istream& is);
|
||||
|
||||
//- Read header (uses typeFilePath to find file) and check its info.
|
||||
// Optionally checks headerClassName against the type-name.
|
||||
// When search is false, simply use the current instance,
|
||||
// otherwise search previous instances.
|
||||
//- Read header (respects is_globalIOobject trait) and check its info.
|
||||
template<class Type>
|
||||
bool typeHeaderOk
|
||||
(
|
||||
//! Check headerClassName against the type-name
|
||||
const bool checkType = true,
|
||||
//! Also search previous instances if not found at current instance
|
||||
const bool search = true,
|
||||
//! Report any check-type failures
|
||||
const bool verbose = true
|
||||
);
|
||||
|
||||
//- Call localFilePath or globalFilePath for given type
|
||||
//- depending on its is_globalIOobject trait.
|
||||
template<class Type>
|
||||
fileName typeFilePath(const bool search = true) const;
|
||||
|
||||
//- Helper: warn that type does not support re-reading
|
||||
template<class Type>
|
||||
void warnNoRereading() const;
|
||||
|
||||
//- Read header (localFilePath only) with optional searching
|
||||
template<>
|
||||
bool typeHeaderOk<void>
|
||||
(
|
||||
//! ignored for \c void
|
||||
const bool checkType,
|
||||
const bool search,
|
||||
//! ignored for \c void
|
||||
const bool verbose
|
||||
);
|
||||
|
||||
//- Call localFilePath for \c void type
|
||||
template<>
|
||||
fileName typeFilePath<void>(const bool search) const;
|
||||
|
||||
|
||||
// Writing
|
||||
|
||||
@ -701,25 +735,9 @@ inline bool IOobject::isHeaderClass<void>() const
|
||||
}
|
||||
|
||||
|
||||
//- Template function for obtaining global vs. local status
|
||||
//- Trait for specifying global vs. local file types
|
||||
template<class T>
|
||||
inline bool typeGlobal()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//- Template function for obtaining local or global filePath
|
||||
template<class T>
|
||||
inline fileName typeFilePath(const IOobject& io, const bool search = true)
|
||||
{
|
||||
return
|
||||
(
|
||||
typeGlobal<T>()
|
||||
? io.globalFilePath(T::typeName, search)
|
||||
: io.localFilePath(T::typeName, search)
|
||||
);
|
||||
}
|
||||
struct is_globalIOobject : std::false_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,8 @@ License
|
||||
#include "IOobject.H"
|
||||
#include "dictionary.H"
|
||||
#include "foamVersion.H"
|
||||
#include "fileOperation.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -171,4 +173,136 @@ bool Foam::IOobject::readHeader(Istream& is)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::IOobject::readAndCheckHeader
|
||||
(
|
||||
const bool isGlobal,
|
||||
const word& typeName,
|
||||
const bool checkType,
|
||||
const bool search,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
// Mark as not yet read. cf, IOobject::readHeader()
|
||||
headerClassName_.clear();
|
||||
|
||||
// Everyone check or just master
|
||||
const bool masterOnly
|
||||
(
|
||||
isGlobal
|
||||
&& (
|
||||
IOobject::fileModificationChecking == IOobject::timeStampMaster
|
||||
|| IOobject::fileModificationChecking == IOobject::inotifyMaster
|
||||
)
|
||||
);
|
||||
|
||||
const auto& handler = Foam::fileHandler();
|
||||
|
||||
// Determine local status
|
||||
bool ok = false;
|
||||
|
||||
if (masterOnly)
|
||||
{
|
||||
if (UPstream::master())
|
||||
{
|
||||
// Force master-only header reading
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
const fileName fName
|
||||
(
|
||||
handler.filePath(isGlobal, *this, typeName, search)
|
||||
);
|
||||
ok = handler.readHeader(*this, fName, typeName);
|
||||
UPstream::parRun(oldParRun);
|
||||
|
||||
if
|
||||
(
|
||||
ok && checkType
|
||||
&& !typeName.empty() && headerClassName_ != typeName
|
||||
)
|
||||
{
|
||||
ok = false;
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unexpected class name \"" << headerClassName_
|
||||
<< "\" expected \"" << typeName
|
||||
<< "\" when reading " << fName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If masterOnly make sure all processors know about the read
|
||||
// information. Note: should ideally be inside fileHandler...
|
||||
Pstream::broadcasts
|
||||
(
|
||||
UPstream::worldComm,
|
||||
ok,
|
||||
headerClassName_,
|
||||
note_
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// All read header
|
||||
const fileName fName
|
||||
(
|
||||
handler.filePath(isGlobal, *this, typeName, search)
|
||||
);
|
||||
ok = handler.readHeader(*this, fName, typeName);
|
||||
|
||||
if
|
||||
(
|
||||
ok && checkType
|
||||
&& !typeName.empty() && headerClassName_ != typeName
|
||||
)
|
||||
{
|
||||
ok = false;
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unexpected class name \"" << headerClassName_
|
||||
<< "\" expected \"" << typeName
|
||||
<< "\" when reading " << fName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Template Specializations * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<>
|
||||
bool IOobject::typeHeaderOk<void>
|
||||
(
|
||||
const bool checkType,
|
||||
const bool search,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
return readAndCheckHeader
|
||||
(
|
||||
false, // global = false
|
||||
word::null,
|
||||
false, // checkType = false (not meaningful)
|
||||
search,
|
||||
false // verbose = false (not meaningful)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
fileName IOobject::typeFilePath<void>(const bool search) const
|
||||
{
|
||||
return this->localFilePath(word::null, search);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -27,10 +27,10 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOobject.H"
|
||||
#include "fileOperation.H"
|
||||
#include "Istream.H"
|
||||
#include "IOstreams.H"
|
||||
#include "Pstream.H"
|
||||
#include "fileOperation.H" // legacy include
|
||||
#include "Istream.H" // legacy include
|
||||
#include "Pstream.H" // legacy include
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -42,78 +42,26 @@ bool Foam::IOobject::typeHeaderOk
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
// Mark as not yet read. cf, IOobject::readHeader()
|
||||
headerClassName_.clear();
|
||||
|
||||
// Everyone check or just master
|
||||
const bool masterOnly
|
||||
return readAndCheckHeader
|
||||
(
|
||||
typeGlobal<Type>()
|
||||
&& (
|
||||
IOobject::fileModificationChecking == IOobject::timeStampMaster
|
||||
|| IOobject::fileModificationChecking == IOobject::inotifyMaster
|
||||
)
|
||||
is_globalIOobject<Type>::value,
|
||||
Type::typeName,
|
||||
checkType,
|
||||
search,
|
||||
verbose
|
||||
);
|
||||
}
|
||||
|
||||
const fileOperation& fp = Foam::fileHandler();
|
||||
|
||||
// Determine local status
|
||||
bool ok = false;
|
||||
|
||||
if (masterOnly)
|
||||
{
|
||||
if (UPstream::master())
|
||||
{
|
||||
// Force master-only header reading
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
const fileName fName(typeFilePath<Type>(*this, search));
|
||||
ok = fp.readHeader(*this, fName, Type::typeName);
|
||||
UPstream::parRun(oldParRun);
|
||||
|
||||
if (ok && checkType && headerClassName_ != Type::typeName)
|
||||
{
|
||||
ok = false;
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unexpected class name \"" << headerClassName_
|
||||
<< "\" expected \"" << Type::typeName
|
||||
<< "\" when reading " << fName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If masterOnly make sure all processors know about the read
|
||||
// information. Note: should ideally be inside fileHandler...
|
||||
Pstream::broadcasts
|
||||
(
|
||||
UPstream::worldComm,
|
||||
ok,
|
||||
headerClassName_,
|
||||
note_
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
const fileName fName(typeFilePath<Type>(*this, search));
|
||||
|
||||
// All read header
|
||||
ok = fp.readHeader(*this, fName, Type::typeName);
|
||||
|
||||
if (ok && checkType && headerClassName_ != Type::typeName)
|
||||
{
|
||||
ok = false;
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unexpected class name \"" << headerClassName_
|
||||
<< "\" expected \"" << Type::typeName
|
||||
<< "\" when reading " << fName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
template<class Type>
|
||||
Foam::fileName Foam::IOobject::typeFilePath(const bool search) const
|
||||
{
|
||||
return
|
||||
(
|
||||
is_globalIOobject<Type>::value
|
||||
? this->globalFilePath(Type::typeName, search)
|
||||
: this->localFilePath(Type::typeName, search)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -121,6 +121,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for GlobalIOList
|
||||
template<class T>
|
||||
struct is_globalIOobject<GlobalIOList<T>> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -32,8 +32,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef globalIOLists_H
|
||||
#define globalIOLists_H
|
||||
#ifndef Foam_globalIOLists_H
|
||||
#define Foam_globalIOLists_H
|
||||
|
||||
#include "primitiveFields.H"
|
||||
#include "GlobalIOList.H"
|
||||
@ -48,43 +48,6 @@ namespace Foam
|
||||
typedef GlobalIOList<sphericalTensor> sphericalTensorGlobalIOList;
|
||||
typedef GlobalIOList<symmTensor> symmTensorGlobalIOList;
|
||||
typedef GlobalIOList<tensor> tensorGlobalIOList;
|
||||
|
||||
//- Template function for obtaining global status
|
||||
template<>
|
||||
inline bool typeGlobal<labelGlobalIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<scalarGlobalIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<vectorGlobalIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<sphericalTensorGlobalIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<symmTensorGlobalIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<tensorGlobalIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,6 +127,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for IOMap
|
||||
template<class T>
|
||||
struct is_globalIOobject<IOMap<T>> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -29,27 +29,10 @@ License
|
||||
#include "IOMap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTemplateTypeNameAndDebug(IOMap<dictionary>, 0);
|
||||
|
||||
//- Template specialization for global status
|
||||
template<>
|
||||
bool typeGlobal<IOMap<dictionary>>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Template specialisation for obtaining filePath
|
||||
template<>
|
||||
fileName typeFilePath<IOMap<dictionary>>
|
||||
(
|
||||
const IOobject& io,
|
||||
const bool search
|
||||
)
|
||||
{
|
||||
return io.globalFilePath(IOMap<dictionary>::typeName, search);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,12 +116,9 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Template function for obtaining global status
|
||||
//- Global file type for IOdictionary
|
||||
template<>
|
||||
inline bool typeGlobal<IOdictionary>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<IOdictionary> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -137,12 +137,9 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Template function for obtaining global status
|
||||
//- Global file type for unwatchedIOdictionary
|
||||
template<>
|
||||
inline bool typeGlobal<unwatchedIOdictionary>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<unwatchedIOdictionary> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -32,8 +32,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef globalIOFields_H
|
||||
#define globalIOFields_H
|
||||
#ifndef Foam_globalIOFields_H
|
||||
#define Foam_globalIOFields_H
|
||||
|
||||
#include "primitiveFields.H"
|
||||
#include "GlobalIOField.H"
|
||||
@ -48,39 +48,6 @@ namespace Foam
|
||||
typedef GlobalIOField<sphericalTensor> sphericalTensorGlobalIOField;
|
||||
typedef GlobalIOField<symmTensor> symmTensorGlobalIOField;
|
||||
typedef GlobalIOField<tensor> tensorGlobalIOField;
|
||||
|
||||
//- Template function for obtaining global status
|
||||
template<>
|
||||
inline bool typeGlobal<labelGlobalIOField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<scalarGlobalIOField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<vectorGlobalIOField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<sphericalTensorGlobalIOField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<symmTensorGlobalIOField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<tensorGlobalIOField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -152,6 +152,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for UniformDimensionedField
|
||||
template<class Type>
|
||||
struct is_globalIOobject<UniformDimensionedField<Type>> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -73,40 +73,6 @@ typedef
|
||||
uniformDimensionedTensorField;
|
||||
|
||||
|
||||
// Global file status
|
||||
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedLabelField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedScalarField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedVectorField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedSphericalTensorField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedSymmTensorField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<>
|
||||
inline bool typeGlobal<uniformDimensionedTensorField>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -385,6 +385,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for schemesLookup - same content for all ranks
|
||||
template<>
|
||||
struct is_globalIOobject<schemesLookup> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -208,6 +208,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for coordinateSystems - same content for all ranks
|
||||
template<>
|
||||
struct is_globalIOobject<coordinateSystems> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -110,23 +110,24 @@ Foam::componentDisplacementMotionSolver::componentDisplacementMotionSolver
|
||||
{
|
||||
if (points0_.size() != mesh.nPoints())
|
||||
{
|
||||
const fileName fName
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
mesh.time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
).typeFilePath<pointIOField>()
|
||||
);
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Number of points in mesh " << mesh.nPoints()
|
||||
<< " differs from number of points " << points0_.size()
|
||||
<< " read from file "
|
||||
<< typeFilePath<pointIOField>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
mesh.time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
)
|
||||
<< " read from file " << fName << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
@ -97,23 +97,24 @@ Foam::points0MotionSolver::points0MotionSolver
|
||||
}
|
||||
else if (points0_.size() != mesh.nPoints())
|
||||
{
|
||||
const fileName fName
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
).typeFilePath<pointIOField>()
|
||||
);
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Number of points in mesh " << mesh.nPoints()
|
||||
<< " differs from number of points " << points0_.size()
|
||||
<< " read from file "
|
||||
<< typeFilePath<pointIOField>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
)
|
||||
<< " read from file " << fName << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for faSchemes - same content for all ranks
|
||||
template<>
|
||||
struct is_globalIOobject<faSchemes> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -287,12 +287,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for porosityModel
|
||||
template<>
|
||||
inline bool typeGlobal<porosityModel>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<porosityModel> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -129,6 +129,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for fvSchemes - same content for all ranks
|
||||
template<>
|
||||
struct is_globalIOobject<fvSchemes> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -71,7 +71,10 @@ void Foam::refinementFeatures::read
|
||||
IOobject::NO_REGISTER
|
||||
);
|
||||
|
||||
const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(extFeatObj));
|
||||
const fileName fName
|
||||
(
|
||||
extFeatObj.typeFilePath<extendedFeatureEdgeMesh>()
|
||||
);
|
||||
|
||||
if (!fName.empty() && extendedEdgeMesh::canRead(fName))
|
||||
{
|
||||
@ -105,7 +108,10 @@ void Foam::refinementFeatures::read
|
||||
IOobject::NO_REGISTER
|
||||
);
|
||||
|
||||
const fileName fName(typeFilePath<featureEdgeMesh>(featObj));
|
||||
const fileName fName
|
||||
(
|
||||
featObj.typeFilePath<featureEdgeMesh>()
|
||||
);
|
||||
|
||||
if (fName.empty())
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ bool Foam::fileFormats::edgeMeshFormat::read
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const fileName fName(typeFilePath<featureEdgeMesh>(io));
|
||||
const fileName fName(io.typeFilePath<featureEdgeMesh>());
|
||||
|
||||
autoPtr<IFstream> isPtr(new IFstream(fName));
|
||||
bool ok = false;
|
||||
|
@ -72,7 +72,7 @@ bool Foam::fileFormats::extendedEdgeMeshFormat::read
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(io));
|
||||
const fileName fName(io.typeFilePath<extendedFeatureEdgeMesh>());
|
||||
|
||||
autoPtr<IFstream> isPtr(new IFstream(fName));
|
||||
bool ok = false;
|
||||
|
@ -154,12 +154,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for extendedFeatureEdgeMesh
|
||||
template<>
|
||||
inline bool typeGlobal<extendedFeatureEdgeMesh>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<extendedFeatureEdgeMesh> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -102,12 +102,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for featureEdgeMesh
|
||||
template<>
|
||||
inline bool typeGlobal<featureEdgeMesh>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<featureEdgeMesh> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -393,12 +393,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for searchableSurface
|
||||
template<>
|
||||
inline bool typeGlobal<searchableSurface>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<searchableSurface> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -431,6 +431,11 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const readAction r)
|
||||
: io.localFilePath(typeName)
|
||||
);
|
||||
|
||||
// const fileName actualFile
|
||||
// (
|
||||
// io.filePath(searchGlobal, typeName)
|
||||
// );
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "triSurfaceMesh(const IOobject& io) :"
|
||||
@ -537,6 +542,11 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
||||
: io.localFilePath(typeName)
|
||||
);
|
||||
|
||||
// const fileName actualFile
|
||||
// (
|
||||
// io.filePath(searchGlobal, typeName)
|
||||
// );
|
||||
|
||||
// Reading from supplied file name instead of objectPath/filePath
|
||||
if (dict.readIfPresent("file", fName_, keyType::LITERAL))
|
||||
{
|
||||
|
@ -334,12 +334,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for triSurfaceMesh
|
||||
template<>
|
||||
inline bool typeGlobal<triSurfaceMesh>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
struct is_globalIOobject<triSurfaceMesh> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -203,7 +203,7 @@ void Foam::fieldToCell::applyToSet
|
||||
// Note: cannot use volScalarField::typeName since that would
|
||||
// introduce linkage problems (finiteVolume needs meshTools)
|
||||
|
||||
IFstream str(typeFilePath<labelIOList>(fieldObject));
|
||||
IFstream str(fieldObject.typeFilePath<labelIOList>());
|
||||
|
||||
// Read as dictionary
|
||||
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
|
||||
@ -217,7 +217,7 @@ void Foam::fieldToCell::applyToSet
|
||||
// Note: cannot use volVectorField::typeName since that would
|
||||
// introduce linkage problems (finiteVolume needs meshTools)
|
||||
|
||||
IFstream str(typeFilePath<labelIOList>(fieldObject));
|
||||
IFstream str(fieldObject.typeFilePath<labelIOList>());
|
||||
|
||||
// Read as dictionary
|
||||
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
|
||||
|
@ -602,12 +602,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Global file type for distributedTriSurfaceMesh
|
||||
template<>
|
||||
inline bool typeGlobal<distributedTriSurfaceMesh>()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct is_globalIOobject<distributedTriSurfaceMesh> : std::true_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
Loading…
Reference in New Issue
Block a user