Test-IOField: Updated and improved to use typeIOobject
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -38,7 +38,7 @@ using namespace Foam;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void write(const IOobject& io, const label sz)
|
void write(const typeIOobject<IOField<label>>& io, const label sz)
|
||||||
{
|
{
|
||||||
IOField<label> fld(io, sz);
|
IOField<label> fld(io, sz);
|
||||||
forAll(fld, i)
|
forAll(fld, i)
|
||||||
@ -50,7 +50,7 @@ void write(const IOobject& io, const label sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void read(const IOobject& io, const label sz)
|
void read(const typeIOobject<IOField<label>>& io, const label sz)
|
||||||
{
|
{
|
||||||
bool valid = (sz > 0);
|
bool valid = (sz > 0);
|
||||||
Pout<< " valid:" << valid << endl;
|
Pout<< " valid:" << valid << endl;
|
||||||
@ -59,14 +59,14 @@ void read(const IOobject& io, const label sz)
|
|||||||
|
|
||||||
if (fld.size() != sz)
|
if (fld.size() != sz)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction<< "io:" << io.objectPath() << exit(FatalError);
|
FatalErrorInFunction<< "io:" << fld.objectPath() << exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void writeAndRead
|
void writeAndRead
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const typeIOobject<IOField<label>>& io,
|
||||||
const label sz,
|
const label sz,
|
||||||
const word& writeType,
|
const word& writeType,
|
||||||
const IOobject::readOption readOpt,
|
const IOobject::readOption readOpt,
|
||||||
@ -83,11 +83,11 @@ void writeAndRead
|
|||||||
fileHandler(writeHandler);
|
fileHandler(writeHandler);
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
Pout<< "Deleting:" << fileHandler().filePath(io.objectPath()) << endl;
|
Pout<< "Deleting:" << io.filePath() << endl;
|
||||||
fileHandler().rm(fileHandler().filePath(io.objectPath()));
|
fileHandler().rm(io.objectPath());
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
Pout<< "Writing:" << fileHandler().objectPath(io, word::null) << endl;
|
Pout<< "Writing:" << io.objectPath() << endl;
|
||||||
write(io, sz);
|
write(io, sz);
|
||||||
|
|
||||||
autoPtr<fileOperation> readHandler
|
autoPtr<fileOperation> readHandler
|
||||||
@ -97,9 +97,9 @@ void writeAndRead
|
|||||||
fileHandler(readHandler);
|
fileHandler(readHandler);
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
IOobject readIO(io);
|
typeIOobject<IOField<label>> readIO(io);
|
||||||
readIO.readOpt() = readOpt;
|
readIO.readOpt() = readOpt;
|
||||||
Pout<< "Reading:" << fileHandler().filePath(readIO.objectPath()) << endl;
|
Pout<< "Reading:" << readIO.filePath() << endl;
|
||||||
read(readIO, sz);
|
read(readIO, sz);
|
||||||
|
|
||||||
Pout<< "** Done writing:" << writeType
|
Pout<< "** Done writing:" << writeType
|
||||||
@ -109,7 +109,7 @@ void writeAndRead
|
|||||||
|
|
||||||
void readIfPresent
|
void readIfPresent
|
||||||
(
|
(
|
||||||
IOobject& io,
|
typeIOobject<IOField<label>>& io,
|
||||||
const label sz,
|
const label sz,
|
||||||
const word& readType
|
const word& readType
|
||||||
)
|
)
|
||||||
@ -121,7 +121,7 @@ void readIfPresent
|
|||||||
fileHandler(readHandler);
|
fileHandler(readHandler);
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
Pout<< "Reading:" << fileHandler().filePath(io.objectPath()) << endl;
|
Pout<< "Reading:" << io.filePath() << endl;
|
||||||
io.readOpt() = IOobject::READ_IF_PRESENT;
|
io.readOpt() = IOobject::READ_IF_PRESENT;
|
||||||
read(io, sz);
|
read(io, sz);
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ int main(int argc, char *argv[])
|
|||||||
sz = 1;
|
sz = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOobject io
|
typeIOobject<IOField<label>> io
|
||||||
(
|
(
|
||||||
"bla",
|
"bla",
|
||||||
runTime.timeName(),
|
runTime.timeName(),
|
||||||
@ -158,17 +158,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Found handlers:" << handlers << endl;
|
Info<< "Found handlers:" << handlers << endl;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
forAll(handlers, readi)
|
|
||||||
{
|
|
||||||
const word& readHandler = handlers[readi];
|
|
||||||
|
|
||||||
readIfPresent(io, sz, readHandler);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
forAll(handlers, writei)
|
forAll(handlers, writei)
|
||||||
{
|
{
|
||||||
const word& writeHandler = handlers[writei];
|
const word& writeHandler = handlers[writei];
|
||||||
|
|||||||
Reference in New Issue
Block a user