Parallel IO: New collated file format

When an OpenFOAM simulation runs in parallel, the data for decomposed fields and
mesh(es) has historically been stored in multiple files within separate
directories for each processor.  Processor directories are named 'processorN',
where N is the processor number.

This commit introduces an alternative "collated" file format where the data for
each decomposed field (and mesh) is collated into a single file, which is
written and read on the master processor.  The files are stored in a single
directory named 'processors'.

The new format produces significantly fewer files - one per field, instead of N
per field.  For large parallel cases, this avoids the restriction on the number
of open files imposed by the operating system limits.

The file writing can be threaded allowing the simulation to continue running
while the data is being written to file.  NFS (Network File System) is not
needed when using the the collated format and additionally, there is an option
to run without NFS with the original uncollated approach, known as
"masterUncollated".

The controls for the file handling are in the OptimisationSwitches of
etc/controlDict:

OptimisationSwitches
{
    ...

    //- Parallel IO file handler
    //  uncollated (default), collated or masterUncollated
    fileHandler uncollated;

    //- collated: thread buffer size for queued file writes.
    //  If set to 0 or not sufficient for the file size threading is not used.
    //  Default: 2e9
    maxThreadFileBufferSize 2e9;

    //- masterUncollated: non-blocking buffer size.
    //  If the file exceeds this buffer size scheduled transfer is used.
    //  Default: 2e9
    maxMasterFileBufferSize 2e9;
}

When using the collated file handling, memory is allocated for the data in the
thread.  maxThreadFileBufferSize sets the maximum size of memory in bytes that
is allocated.  If the data exceeds this size, the write does not use threading.

When using the masterUncollated file handling, non-blocking MPI communication
requires a sufficiently large memory buffer on the master node.
maxMasterFileBufferSize sets the maximum size in bytes of the buffer.  If the
data exceeds this size, the system uses scheduled communication.

The installation defaults for the fileHandler choice, maxThreadFileBufferSize
and maxMasterFileBufferSize (set in etc/controlDict) can be over-ridden within
the case controlDict file, like other parameters.  Additionally the fileHandler
can be set by:
- the "-fileHandler" command line argument;
- a FOAM_FILEHANDLER environment variable.

A foamFormatConvert utility allows users to convert files between the collated
and uncollated formats, e.g.
    mpirun -np 2 foamFormatConvert -parallel -fileHandler uncollated

An example case demonstrating the file handling methods is provided in:
$FOAM_TUTORIALS/IO/fileHandling

The work was undertaken by Mattijs Janssens, in collaboration with Henry Weller.
This commit is contained in:
Henry Weller
2017-07-07 11:39:56 +01:00
parent aa1712de8f
commit 7c301dbff4
303 changed files with 13626 additions and 2129 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,6 +54,7 @@ Description
#include "emptyPolyPatch.H"
#include "removeCells.H"
#include "meshSearch.H"
#include "IOdictionary.H"
using namespace Foam;
@ -650,7 +651,7 @@ int main(int argc, char *argv[])
// corrector for mesh motion
twoDPointCorrector* correct2DPtr = nullptr;
if (motionObj.headerOk())
if (motionObj.typeHeaderOk<IOdictionary>(true))
{
Info<< "Reading " << runTime.constant() / "motionProperties"
<< endl << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,6 +59,7 @@ Description
#include "meshTools.H"
#include "Pair.H"
#include "globalIndex.H"
#include "IOdictionary.H"
using namespace Foam;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -238,7 +238,7 @@ int main(int argc, char *argv[])
runTime
);
if (!readLevel && refHeader.headerOk())
if (!readLevel && refHeader.typeHeaderOk<labelIOList>(true))
{
WarningInFunction
<< "Detected " << refHeader.name() << " file in "

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,6 +28,7 @@ License
#include "polyMesh.H"
#include "Ostream.H"
#include "twoDPointCorrector.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -82,7 +83,7 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
IOobject::NO_WRITE
);
if (motionObj.headerOk())
if (motionObj.typeHeaderOk<IOdictionary>(true))
{
Info<< "Reading " << mesh.time().constant() / "motionProperties"
<< endl << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,6 +54,7 @@ See also
#include "Time.H"
#include "polyMesh.H"
#include "STARCDMeshWriter.H"
#include "IOdictionary.H"
using namespace Foam;

View File

@ -19,7 +19,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(

View File

@ -44,7 +44,7 @@ Usage
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "IOdictionary.H"
#include "MeshedSurfaces.H"
using namespace Foam;

View File

@ -19,7 +19,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(

View File

@ -194,7 +194,7 @@ int main(int argc, char *argv[])
false
);
if (!meshDictIO.headerOk())
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< meshDictIO.objectPath()

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -96,7 +96,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(false))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
@ -122,7 +122,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false
);
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(false))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -366,7 +366,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
@ -392,7 +392,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false
);
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
@ -2657,7 +2657,7 @@ int main(int argc, char *argv[])
mesh,
IOobject::MUST_READ
);
if (io.headerOk())
if (io.typeHeaderOk<pointIOField>(true))
{
// Read patchFaceCentres and patchEdgeCentres
Info<< "Reading patch face,edge centres : "

View File

@ -44,6 +44,7 @@ Note
#include "addPatchCellLayer.H"
#include "patchToPoly2DMesh.H"
#include "globalIndex.H"
#include "IOdictionary.H"
using namespace Foam;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -387,7 +387,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
Triangulation::number_of_vertices()
label(Triangulation::number_of_vertices())
);
labelIOField processorIndices
@ -401,7 +401,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
Triangulation::number_of_vertices()
label(Triangulation::number_of_vertices())
);
for

View File

@ -525,6 +525,7 @@ void extractSurface
? runTime.path()/".."/outFileName
: runTime.path()/outFileName
);
globalCasePath.clean();
Info<< "Writing merged surface to " << globalCasePath << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,6 +59,7 @@ Usage
#include "globalMeshData.H"
#include "surfaceWriter.H"
#include "vtkSetWriter.H"
#include "IOdictionary.H"
#include "checkTools.H"
#include "checkTopology.H"

View File

@ -268,7 +268,7 @@ void Foam::mergeAndWrite
mesh.points()
);
const fileName outputDir
fileName outputDir
(
set.time().path()
/ (Pstream::parRun() ? ".." : "")
@ -276,6 +276,7 @@ void Foam::mergeAndWrite
/ mesh.pointsInstance()
/ set.name()
);
outputDir.clean();
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
}
@ -361,7 +362,7 @@ void Foam::mergeAndWrite
mesh.points()
);
const fileName outputDir
fileName outputDir
(
set.time().path()
/ (Pstream::parRun() ? ".." : "")
@ -369,6 +370,7 @@ void Foam::mergeAndWrite
/ mesh.pointsInstance()
/ set.name()
);
outputDir.clean();
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
}
@ -464,7 +466,7 @@ void Foam::mergeAndWrite
// Output e.g. pointSet p0 to
// postProcessing/<time>/p0.vtk
const fileName outputDir
fileName outputDir
(
set.time().path()
/ (Pstream::parRun() ? ".." : "")
@ -472,6 +474,7 @@ void Foam::mergeAndWrite
/ mesh.pointsInstance()
// set.name()
);
outputDir.clean();
mkDir(outputDir);
fileName outputFile(outputDir/writer.getFileName(points, wordList()));

View File

@ -49,6 +49,7 @@ Description
#include "polyTopoChange.H"
#include "polyModifyFace.H"
#include "wordReList.H"
#include "IOdictionary.H"
using namespace Foam;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
);
// Check U exists
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,6 +51,7 @@ Description
#include "wedgePolyPatch.H"
#include "plane.H"
#include "SubField.H"
#include "IOdictionary.H"
using namespace Foam;
@ -187,7 +188,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (!dictIO.headerOk())
if (!dictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< "Cannot open specified refinement dictionary "
@ -209,7 +210,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (dictIO.headerOk())
if (dictIO.typeHeaderOk<IOdictionary>(true))
{
Info<< "Refining according to " << dictName << nl << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,6 +48,7 @@ Description
#include "faceZoneSet.H"
#include "pointZoneSet.H"
#include "timeSelector.H"
#include "collatedFileOperation.H"
#include <stdio.h>
@ -805,6 +806,11 @@ commandStatus parseAction(const word& actionName)
int main(int argc, char *argv[])
{
// Specific to topoSet/setSet: quite often we want to block upon writing
// a set so we can immediately re-read it. So avoid use of threading
// for set writing.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
timeSelector::addOptions(true, false);
#include "addRegionOption.H"
argList::addBoolOption("noVTK", "do not write VTK files");

View File

@ -603,7 +603,7 @@ autoPtr<mapPolyMesh> createRegionMesh
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
// if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
@ -630,7 +630,7 @@ autoPtr<mapPolyMesh> createRegionMesh
false
);
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
//if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -483,7 +483,8 @@ int main(int argc, char *argv[])
(
runTime.writeFormat(),
IOstream::currentVersion,
runTime.writeCompression()
runTime.writeCompression(),
true
)
)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,6 +39,8 @@ Description
#include "cellZoneSet.H"
#include "faceZoneSet.H"
#include "pointZoneSet.H"
#include "IOdictionary.H"
#include "collatedFileOperation.H"
using namespace Foam;
@ -191,6 +193,11 @@ polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
int main(int argc, char *argv[])
{
// Specific to topoSet/setSet: quite often we want to block upon writing
// a set so we can immediately re-read it. So avoid use of threading
// for set writing.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
timeSelector::addOptions(true, false);
#include "addDictOption.H"
#include "addRegionOption.H"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,9 +49,19 @@ Description
#include "cellIOList.H"
#include "IOobjectList.H"
#include "IOPtrList.H"
#include "cloud.H"
#include "labelIOField.H"
#include "scalarIOField.H"
#include "sphericalTensorIOField.H"
#include "symmTensorIOField.H"
#include "tensorIOField.H"
#include "labelFieldIOField.H"
#include "vectorFieldIOField.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "fieldDictionary.H"
#include "writeMeshObject.H"
#include "fieldDictionary.H"
using namespace Foam;
@ -79,7 +89,7 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
bool writeOk = false;
if (io.headerOk())
if (io.typeHeaderOk<cellZoneMesh>(false))
{
Info<< " Reading " << io.headerClassName()
<< " : " << name << endl;
@ -130,7 +140,8 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
(
IOstream::ASCII,
IOstream::currentVersion,
runTime.writeCompression()
runTime.writeCompression(),
true
);
}
@ -138,6 +149,75 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
}
// Reduction for non-empty strings
class uniqueEqOp
{
public:
void operator()(stringList& x, const stringList& y) const
{
stringList newX(x.size()+y.size());
label n = 0;
forAll(x, i)
{
if (!x[i].empty())
{
newX[n++] = x[i];
}
}
forAll(y, i)
{
if (!y[i].empty() && findIndex(x, y[i]) == -1)
{
newX[n++] = y[i];
}
}
newX.setSize(n);
x.transfer(newX);
}
};
template<class T>
bool writeOptionalMeshObject
(
const word& name,
const fileName& meshDir,
Time& runTime,
const bool valid
)
{
IOobject io
(
name,
runTime.timeName(),
meshDir,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
bool writeOk = false;
bool haveFile = io.typeHeaderOk<IOField<label>>(false);
// Make sure all know if there is a valid class name
stringList classNames(1, io.headerClassName());
combineReduce(classNames, uniqueEqOp());
// Check for correct type
if (classNames[0] == T::typeName)
{
Info<< " Reading " << classNames[0]
<< " : " << name << endl;
T meshObject(io, valid && haveFile);
Info<< " Writing " << name << endl;
writeOk = meshObject.regIOobject::write(valid && haveFile);
}
return writeOk;
}
int main(int argc, char *argv[])
@ -165,6 +245,8 @@ int main(int argc, char *argv[])
#include "createTime.H"
// Optional mesh (used to read Clouds)
autoPtr<polyMesh> meshPtr;
// Make sure we do not use the master-only reading since we read
@ -190,11 +272,24 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl;
// Convert all the standard mesh files
writeMeshObject<cellCompactIOList>("cells", meshDir, runTime);
writeMeshObject<cellCompactIOList, cellIOList>
(
"cells",
meshDir,
runTime
);
writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceCompactIOList>("faces", meshDir, runTime);
writeMeshObject<faceCompactIOList, faceIOList>
(
"faces",
meshDir,
runTime
);
writeMeshObject<pointIOField>("points", meshDir, runTime);
// Write boundary in ascii. This is only needed for fileHandler to
// kick in. Should not give problems since always writing ascii.
writeZones("boundary", meshDir, runTime);
writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
@ -248,22 +343,196 @@ int main(int argc, char *argv[])
|| headerClassName == pointSphericalTensorField::typeName
|| headerClassName == pointSymmTensorField::typeName
|| headerClassName == pointTensorField::typeName
|| headerClassName == volScalarField::Internal::typeName
|| headerClassName == volVectorField::Internal::typeName
|| headerClassName == volSphericalTensorField::Internal::typeName
|| headerClassName == volSymmTensorField::Internal::typeName
|| headerClassName == volTensorField::Internal::typeName
)
{
Info<< " Reading " << headerClassName
<< " : " << iter()->name() << endl;
fieldDictionary fDict
(
*iter(),
headerClassName
);
fieldDictionary fDict(*iter(), headerClassName);
Info<< " Writing " << iter()->name() << endl;
fDict.regIOobject::write();
}
}
// Check for lagrangian
stringList lagrangianDirs
(
1,
fileHandler().filePath
(
runTime.timePath()
/ regionPrefix
/ cloud::prefix
)
);
combineReduce(lagrangianDirs, uniqueEqOp());
if (!lagrangianDirs.empty())
{
if (meshPtr.valid())
{
meshPtr().readUpdate();
}
else
{
Info<< " Create polyMesh for time = "
<< runTime.timeName() << endl;
meshPtr.reset
(
new polyMesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
)
)
);
}
stringList cloudDirs
(
fileHandler().readDir
(
lagrangianDirs[0],
fileName::DIRECTORY
)
);
combineReduce(cloudDirs, uniqueEqOp());
forAll(cloudDirs, i)
{
fileName dir(cloud::prefix/cloudDirs[i]);
Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false);
parcels.writeObject
(
runTime.writeFormat(),
IOstream::currentVersion,
runTime.writeCompression(),
parcels.size()
);
// Do local scan for valid cloud objects
IOobjectList sprayObjs(runTime, runTime.timeName(), dir);
// Combine with all other cloud objects
stringList sprayFields(sprayObjs.sortedToc());
combineReduce(sprayFields, uniqueEqOp());
forAll(sprayFields, fieldi)
{
const word& name = sprayFields[fieldi];
// Note: try the various field types. Make sure to
// exit once sucessful conversion to avoid re-read
// converted file.
if
(
name == "positions"
|| name == "origProcId"
|| name == "origId"
)
{
continue;
}
bool writeOk = writeOptionalMeshObject<labelIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<scalarIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<vectorIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<sphericalTensorIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<symmTensorIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<tensorIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<labelFieldIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (writeOk) continue;
writeOk = writeOptionalMeshObject<vectorFieldIOField>
(
name,
dir,
runTime,
parcels.size() > 0
);
if (!writeOk)
{
Info<< " Failed converting " << name << endl;
}
}
}
}
Info<< endl;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T>
template<class Type, class CheckType = Type>
inline bool writeMeshObject
(
const word& name,
@ -61,7 +61,11 @@ inline bool writeMeshObject
bool writeOk = false;
if (io.headerOk())
if
(
io.typeHeaderOk<Type>(false)
&& io.headerClassName() == CheckType::typeName
)
{
Info<< " Reading " << io.headerClassName()
<< " : " << name << endl;
@ -71,15 +75,15 @@ inline bool writeMeshObject
word oldTypeName;
if (disableHeaderChecking)
{
oldTypeName = T::typeName;
const_cast<word&>(T::typeName) = word::null;
oldTypeName = Type::typeName;
const_cast<word&>(Type::typeName) = word::null;
}
T meshObject(io);
Type meshObject(io);
if (disableHeaderChecking)
{
const_cast<word&>(T::typeName) = oldTypeName;
const_cast<word&>(Type::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(meshObject.type()) = io.headerClassName();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -127,7 +127,8 @@ void Foam::helpTypes::helpBoundary::execute
IOobject::MUST_READ
);
if (fieldHeader.headerOk())
// Check for any type of volField
if (fieldHeader.typeHeaderOk<volScalarField>(false))
{
if (args.optionFound("fixedValue"))
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -106,7 +106,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (obj.headerOk())
if (obj.typeHeaderOk<volScalarField>(false))
{
addToFieldList(vsf, obj, objI, mesh);
addToFieldList(vvf, obj, objI, mesh);

View File

@ -104,6 +104,7 @@ Usage
#include "pointFieldDecomposer.H"
#include "lagrangianFieldDecomposer.H"
#include "decompositionModel.H"
#include "collatedFileOperation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -157,21 +158,25 @@ void decomposeUniform
// Any uniform data to copy/link?
const fileName uniformDir(regionDir/"uniform");
if (isDir(runTime.timePath()/uniformDir))
if (fileHandler().isDir(runTime.timePath()/uniformDir))
{
Info<< "Detected additional non-decomposed files in "
<< runTime.timePath()/uniformDir
<< endl;
const fileName timePath = processorDb.timePath();
const fileName timePath =
fileHandler().filePath(processorDb.timePath());
if (copyUniform || mesh.distributed())
{
cp
(
runTime.timePath()/uniformDir,
timePath/uniformDir
);
if (!fileHandler().exists(timePath/uniformDir))
{
fileHandler().cp
(
runTime.timePath()/uniformDir,
timePath/uniformDir
);
}
}
else
{
@ -185,11 +190,15 @@ void decomposeUniform
fileName currentDir(cwd());
chDir(timePath);
ln
(
parentPath/runTime.timeName()/uniformDir,
uniformDir
);
if (!fileHandler().exists(uniformDir))
{
fileHandler().ln
(
parentPath/runTime.timeName()/uniformDir,
uniformDir
);
}
chDir(currentDir);
}
}
@ -343,24 +352,10 @@ int main(int argc, char *argv[])
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
// determine the existing processor count directly
label nProcs = 0;
while
(
isDir
(
runTime.path()
/ (word("processor") + name(nProcs))
/ runTime.constant()
/ regionDir
/ polyMesh::meshSubDir
)
)
{
++nProcs;
}
// Determine the existing processor count directly
label nProcs = fileHandler().nProcs(runTime.path(), regionDir);
// get requested numberOfSubdomains. Note: have no mesh yet so
// Get requested numberOfSubdomains. Note: have no mesh yet so
// cannot use decompositionModel::New
const label nDomains = readLabel
(
@ -413,6 +408,8 @@ int main(int argc, char *argv[])
Info<< "Removing " << nProcs
<< " existing processor directories" << endl;
fileHandler().rmDir(runTime.path()/word("processors"));
// remove existing processor dirs
// reverse order to avoid gaps if someone interrupts the process
for (label proci = nProcs-1; proci >= 0; --proci)
@ -422,7 +419,7 @@ int main(int argc, char *argv[])
runTime.path()/(word("processor") + name(proci))
);
rmDir(procDir);
fileHandler().rmDir(procDir);
}
procDirsProblem = false;
@ -459,6 +456,12 @@ int main(int argc, char *argv[])
// Decompose the mesh
if (!decomposeFieldsOnly)
{
// Disable buffering when writing mesh since we need to read
// it later on when decomposing the fields
float bufSz =
fileOperations::collatedFileOperation::maxThreadFileBufferSize;
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
mesh.decomposeMesh(dictPath);
mesh.writeDecomposition(decomposeSets);
@ -514,12 +517,15 @@ int main(int argc, char *argv[])
<< cellDist.name() << " for use in postprocessing."
<< endl;
}
fileOperations::collatedFileOperation::maxThreadFileBufferSize = bufSz;
}
if (copyZero)
{
// Link the 0 directory into each of the processor directories
// Copy the 0 directory into each of the processor directories
fileName prevTimePath;
for (label proci = 0; proci < mesh.nProcs(); proci++)
{
Time processorDb
@ -530,14 +536,32 @@ int main(int argc, char *argv[])
);
processorDb.setTime(runTime);
if (isDir(runTime.timePath()))
if (fileHandler().isDir(runTime.timePath()))
{
const fileName timePath = processorDb.timePath();
// Get corresponding directory name (to handle processors/)
const fileName timePath
(
fileHandler().objectPath
(
IOobject
(
"",
processorDb.timeName(),
processorDb
),
word::null
)
);
Info<< "Processor " << proci
<< ": linking " << runTime.timePath() << nl
<< " to " << processorDb.timePath() << endl;
cp(runTime.timePath(), processorDb.timePath());
if (timePath != prevTimePath)
{
Info<< "Processor " << proci
<< ": copying " << runTime.timePath() << nl
<< " to " << timePath << endl;
fileHandler().cp(runTime.timePath(), timePath);
prevTimePath = timePath;
}
}
}
}
@ -638,9 +662,10 @@ int main(int argc, char *argv[])
fileNameList cloudDirs
(
readDir
fileHandler().readDir
(
runTime.timePath()/cloud::prefix, fileName::DIRECTORY
runTime.timePath()/cloud::prefix,
fileName::DIRECTORY
)
);

View File

@ -315,9 +315,6 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
time().caseName()/fileName(word("processor") + Foam::name(proci))
);
// make the processor directory
mkDir(time().rootPath()/processorCasePath);
// create a database
Time processorDb
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -188,11 +188,12 @@ void Foam::lagrangianFieldDecomposer::decomposeFields
const PtrList<GeoField>& fields
) const
{
if (particleIndices_.size())
//if (particleIndices_.size())
{
bool valid = particleIndices_.size() > 0;
forAll(fields, fieldi)
{
decomposeField(cloudName, fields[fieldi])().write();
decomposeField(cloudName, fields[fieldi])().write(valid);
}
}
}
@ -205,11 +206,12 @@ void Foam::lagrangianFieldDecomposer::decomposeFieldFields
const PtrList<GeoField>& fields
) const
{
if (particleIndices_.size())
//if (particleIndices_.size())
{
bool valid = particleIndices_.size() > 0;
forAll(fields, fieldi)
{
decomposeFieldField(cloudName, fields[fieldi])().write();
decomposeFieldField(cloudName, fields[fieldi])().write(valid);
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -174,12 +174,43 @@ int main(int argc, char *argv[])
const bool allRegions = args.optionFound("allRegions");
// determine the processor count directly
label nProcs = 0;
while (isDir(args.path()/(word("processor") + name(nProcs))))
wordList regionNames;
wordList regionDirs;
if (allRegions)
{
++nProcs;
Info<< "Reconstructing for all regions in regionProperties" << nl
<< endl;
regionProperties rp(runTime);
forAllConstIter(HashTable<wordList>, rp, iter)
{
const wordList& regions = iter();
forAll(regions, i)
{
if (findIndex(regionNames, regions[i]) == -1)
{
regionNames.append(regions[i]);
}
}
}
regionDirs = regionNames;
}
else
{
word regionName;
if (args.optionReadIfPresent("region", regionName))
{
regionNames = wordList(1, regionName);
regionDirs = regionNames;
}
else
{
regionNames = wordList(1, fvMesh::defaultRegion);
regionDirs = wordList(1, word::null);
}
}
// Determine the processor count
label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]);
if (!nProcs)
{
@ -222,9 +253,8 @@ int main(int argc, char *argv[])
if (timeDirs.empty())
{
FatalErrorInFunction
<< "No times selected"
<< exit(FatalError);
WarningInFunction << "No times selected";
exit(1);
}
@ -248,42 +278,6 @@ int main(int argc, char *argv[])
}
wordList regionNames;
wordList regionDirs;
if (allRegions)
{
Info<< "Reconstructing for all regions in regionProperties" << nl
<< endl;
regionProperties rp(runTime);
forAllConstIter(HashTable<wordList>, rp, iter)
{
const wordList& regions = iter();
forAll(regions, i)
{
if (findIndex(regionNames, regions[i]) == -1)
{
regionNames.append(regions[i]);
}
}
}
regionDirs = regionNames;
}
else
{
word regionName;
if (args.optionReadIfPresent("region", regionName))
{
regionNames = wordList(1, regionName);
regionDirs = regionNames;
}
else
{
regionNames = wordList(1, fvMesh::defaultRegion);
regionDirs = wordList(1, word::null);
}
}
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
@ -550,17 +544,26 @@ int main(int argc, char *argv[])
forAll(databases, proci)
{
fileNameList cloudDirs
fileName lagrangianDir
(
readDir
fileHandler().filePath
(
databases[proci].timePath()
/ regionDir
/ cloud::prefix,
fileName::DIRECTORY
/ cloud::prefix
)
);
fileNameList cloudDirs;
if (!lagrangianDir.empty())
{
cloudDirs = fileHandler().readDir
(
lagrangianDir,
fileName::DIRECTORY
);
}
forAll(cloudDirs, i)
{
// Check if we already have cloud objects for this
@ -995,12 +998,15 @@ int main(int argc, char *argv[])
{
fileName uniformDir0
(
databases[0].timePath()/regionDir/"uniform"
fileHandler().filePath
(
databases[0].timePath()/regionDir/"uniform"
)
);
if (isDir(uniformDir0))
if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
{
cp(uniformDir0, runTime.timePath()/regionDir);
fileHandler().cp(uniformDir0, runTime.timePath()/regionDir);
}
}
@ -1010,12 +1016,15 @@ int main(int argc, char *argv[])
{
fileName uniformDir0
(
databases[0].timePath()/"uniform"
fileHandler().filePath
(
databases[0].timePath()/"uniform"
)
);
if (isDir(uniformDir0))
if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
{
cp(uniformDir0, runTime.timePath());
fileHandler().cp(uniformDir0, runTime.timePath());
}
}
}

View File

@ -548,20 +548,7 @@ int main(int argc, char *argv[])
bool writeCellDist = args.optionFound("cellDist");
int nProcs = 0;
while
(
isDir
(
args.rootPath()
/ args.caseName()
/ fileName(word("processor") + name(nProcs))
)
)
{
nProcs++;
}
label nProcs = fileHandler().nProcs(args.path());
Info<< "Found " << nProcs << " processor directories" << nl << endl;
@ -609,13 +596,21 @@ int main(int argc, char *argv[])
databases[proci].setTime(timeDirs[timeI], timeI);
}
const fileName meshPath =
databases[0].path()
/databases[0].timeName()
/regionDir
/polyMesh::meshSubDir;
IOobject facesIO
(
"faces",
databases[0].timeName(),
regionDir/polyMesh::meshSubDir,
databases[0],
IOobject::NO_READ,
IOobject::NO_WRITE
);
if (!isFile(meshPath/"faces"))
// Problem: faceCompactIOList recognises both 'faceList' and
// 'faceCompactList' so we should be lenient when doing
// typeHeaderOk
if (!facesIO.typeHeaderOk<faceCompactIOList>(false))
{
Info<< "No mesh." << nl << endl;
continue;

View File

@ -115,7 +115,10 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// Check who has a mesh
const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir);
const bool haveMesh = fileHandler().isDir
(
fileHandler().filePath(io.time().path()/io.instance()/meshSubDir)
);
if (!haveMesh)
{

View File

@ -16,6 +16,6 @@ for (label n1=0; n1<Times.size() && variableGood; ++n1)
Times[n1].name(),
mesh,
IOobject::NO_READ
).headerOk();
).typeHeaderOk<volScalarField>(false);
}
}

View File

@ -17,7 +17,7 @@ if (Times.size() > 1)
mesh,
IOobject::NO_READ
);
if (io.headerOk())
if (io.typeHeaderOk<pointIOField>(true))
{
meshMoving = true;
break;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -584,7 +584,10 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
bool fieldExists = fieldObject.headerOk();
bool fieldExists = fieldObject.typeHeaderOk<IOField<scalar>>
(
false
);
if (fieldType == scalarIOField::typeName)
{
ensightCloudField<scalar>

View File

@ -13,6 +13,6 @@ if (timeDirs.size() > 1)
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ
).headerOk();
).typeHeaderOk<pointIOField>(true);
}
}

View File

@ -24,7 +24,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
IOdictionary timeObject(io);

View File

@ -7,7 +7,7 @@
mesh
);
if (io.headerOk())
if (io.typeHeaderOk<pointIOField>(true))
{
// Read new points
io.readOpt() = IOobject::MUST_READ;

View File

@ -71,7 +71,13 @@ for (label i=0; i < nTypes; i++)
IOobject::NO_READ
);
if (lagrangianHeader.headerOk())
if
(
lagrangianHeader.typeHeaderOk<IOPosition<Cloud<passiveParticle>>>
(
false
)
)
{
Cloud<passiveParticle> particles(mesh, cloud::defaultName);

View File

@ -6,7 +6,7 @@ IOobject ioPoints
mesh
);
if (ioPoints.headerOk())
if (ioPoints.typeHeaderOk<pointIOField>(true))
{
Info<< "new points available" << endl;
// Reading new points

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,6 +30,7 @@ License
#include "fvMesh.H"
#include "Time.H"
#include "patchZones.H"
#include "collatedFileOperation.H"
// VTK includes
#include "vtkDataArraySelection.h"
@ -249,6 +250,12 @@ Foam::vtkPV3Foam::vtkPV3Foam
printMemory();
}
// Make sure not to use the threaded version - it does not like
// being loaded as a shared library - static cleanup order is problematic.
// For now just disable the threaded writer.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());
@ -567,7 +574,13 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
if
(
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
&& IOobject
(
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
)
{
break;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -63,7 +63,7 @@ public:
explicit zonesEntries(const IOobject& io)
:
regIOobject(io),
PtrList<entry>(readStream("regIOobject"))
PtrList<entry>(readStream(word("regIOobject")))
{
close();
}
@ -124,7 +124,7 @@ Foam::wordList Foam::vtkPV3Foam::getZoneNames(const word& zoneType) const
false
);
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
{
zonesEntries zones(ioObj);
@ -333,7 +333,7 @@ void Foam::vtkPV3Foam::updateInfoPatches
);
// this should only ever fail if the mesh region doesn't exist
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
{
polyBoundaryMeshEntries patchEntries(ioObj);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,7 @@ License
#include "Time.H"
#include "patchZones.H"
#include "OStringStream.H"
#include "collatedFileOperation.H"
// VTK includes
#include "vtkDataArraySelection.h"
@ -164,6 +165,12 @@ Foam::vtkPV3blockMesh::vtkPV3blockMesh
<< FileName << endl;
}
// Make sure not to use the threaded version - it does not like
// being loaded as a shared library - static cleanup order is problematic.
// For now just disable the threaded writer.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,6 +30,7 @@ License
#include "fvMesh.H"
#include "Time.H"
#include "patchZones.H"
#include "collatedFileOperation.H"
// VTK includes
#include "vtkDataArraySelection.h"
@ -249,6 +250,12 @@ Foam::vtkPVFoam::vtkPVFoam
printMemory();
}
// Make sure not to use the threaded version - it does not like
// being loaded as a shared library - static cleanup order is problematic.
// For now just disable the threaded writer.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());
@ -566,8 +573,13 @@ double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
if
(
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
IOobject
(
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
)
{
break;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -63,7 +63,7 @@ public:
explicit zonesEntries(const IOobject& io)
:
regIOobject(io),
PtrList<entry>(readStream("regIOobject"))
PtrList<entry>(readStream(word("regIOobject")))
{
close();
}
@ -124,7 +124,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
false
);
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
{
zonesEntries zones(ioObj);
@ -333,7 +333,7 @@ void Foam::vtkPVFoam::updateInfoPatches
);
// this should only ever fail if the mesh region doesn't exist
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
{
polyBoundaryMeshEntries patchEntries(ioObj);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,7 @@ License
#include "Time.H"
#include "patchZones.H"
#include "OStringStream.H"
#include "collatedFileOperation.H"
// VTK includes
#include "vtkDataArraySelection.h"
@ -170,6 +171,12 @@ Foam::vtkPVblockMesh::vtkPVblockMesh
<< FileName << endl;
}
// Make sure not to use the threaded version - it does not like
// being loaded as a shared library - static cleanup order is problematic.
// For now just disable the threaded writer.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());

View File

@ -28,7 +28,7 @@ int USERD_set_filenames
// remove the last '/' from rootDir
if (the_path[lRoot-1] == '/')
{
the_path[lRoot-1] = char(NULL);
the_path[lRoot-1] = '\0';
}
else
{
@ -171,7 +171,7 @@ int USERD_set_filenames
false
);
if (sprayHeader.headerOk())
if (sprayHeader.typeHeaderOk<Cloud<passiveParticle>>(false))
{
Info<< "[Found lagrangian]" << endl;

View File

@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volScalarField>(true))
{
return Z_UNDEF;
}

View File

@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volTensorField>(true))
{
return Z_UNDEF;
}

View File

@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volVectorField>(true))
{
return Z_UNDEF;
}

View File

@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volScalarField>(true))
{
return Z_UNDEF;
}

View File

@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volTensorField>(true))
{
return Z_UNDEF;
}

View File

@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volVectorField>(true))
{
return Z_UNDEF;
}

View File

@ -6,7 +6,7 @@
IOobject::MUST_READ
);
if (!UMeanHeader.headerOk())
if (!UMeanHeader.typeHeaderOk<volVectorField>(true))
{
Info<< " No UMean field" << endl;
continue;

View File

@ -82,6 +82,7 @@ See also
#include "argList.H"
#include "Time.H"
#include "CSV.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -187,7 +187,7 @@ int main(int argc, char *argv[])
false
);
if (omegaHeader.headerOk())
if (omegaHeader.typeHeaderOk<volScalarField>(true))
{
volScalarField omega(omegaHeader, mesh);
dimensionedScalar k0("VSMALL", k.dimensions(), VSMALL);
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
false
);
if (nuTildaHeader.headerOk())
if (nuTildaHeader.typeHeaderOk<volScalarField>(true))
{
volScalarField nuTilda(nuTildaHeader, mesh);
nuTilda = nut;

View File

@ -428,7 +428,6 @@ int main(int argc, char *argv[])
FatalErrorInFunction
<< "No times selected." << exit(FatalError);
}
forAll(times, timei)
{
word instance;
@ -641,7 +640,8 @@ int main(int argc, char *argv[])
(
runTime.writeFormat(),
runTime.writeFormat(),
IOstream::UNCOMPRESSED
IOstream::UNCOMPRESSED,
true
);
}
else

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,7 +74,8 @@ void rewriteBoundary
HashTable<word>& nbrNames
)
{
Info<< "Reading boundary from " << io.filePath() << endl;
Info<< "Reading boundary from " << typeFilePath<IOPtrList<entry>>(io)
<< endl;
// Read PtrList of dictionary.
const word oldTypeName = IOPtrList<entry>::typeName;
@ -446,7 +447,7 @@ int main(int argc, char *argv[])
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOPtrList<entry>>(false))
{
rewriteBoundary
(
@ -480,7 +481,7 @@ int main(int argc, char *argv[])
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOPtrList<entry>>(false))
{
rewriteBoundary
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,15 +44,12 @@ void MapConsistentVolFields
const CombineOp& cop
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
word fieldClassName
(
GeometricField<Type, fvPatchField, volMesh>::typeName
);
IOobjectList fields = objects.lookupClass(fieldClassName);
IOobjectList fields = objects.lookupClass(fieldType::typeName);
forAllIter(IOobjectList, fields, fieldIter)
{
@ -60,11 +57,7 @@ void MapConsistentVolFields
<< endl;
// Read field
GeometricField<Type, fvPatchField, volMesh> fieldSource
(
*fieldIter(),
meshSource
);
fieldType fieldSource(*fieldIter(), meshSource);
IOobject fieldTargetIOobject
(
@ -75,10 +68,10 @@ void MapConsistentVolFields
IOobject::AUTO_WRITE
);
if (fieldTargetIOobject.headerOk())
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
{
// Read fieldTarget
GeometricField<Type, fvPatchField, volMesh> fieldTarget
fieldType fieldTarget
(
fieldTargetIOobject,
meshTarget
@ -101,7 +94,7 @@ void MapConsistentVolFields
fieldTargetIOobject.readOpt() = IOobject::NO_READ;
// Interpolate field
GeometricField<Type, fvPatchField, volMesh> fieldTarget
fieldType fieldTarget
(
fieldTargetIOobject,
meshToMesh0Interp.interpolate

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,15 +44,12 @@ void MapVolFields
const CombineOp& cop
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
word fieldClassName
(
GeometricField<Type, fvPatchField, volMesh>::typeName
);
IOobjectList fields = objects.lookupClass(fieldClassName);
IOobjectList fields = objects.lookupClass(fieldType::typeName);
forAllIter(IOobjectList, fields, fieldIter)
{
@ -65,20 +62,15 @@ void MapVolFields
IOobject::AUTO_WRITE
);
if (fieldTargetIOobject.headerOk())
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
{
Info<< " interpolating " << fieldIter()->name()
<< endl;
Info<< " interpolating " << fieldIter()->name() << endl;
// Read field fieldSource
GeometricField<Type, fvPatchField, volMesh> fieldSource
(
*fieldIter(),
meshSource
);
fieldType fieldSource(*fieldIter(), meshSource);
// Read fieldTarget
GeometricField<Type, fvPatchField, volMesh> fieldTarget
fieldType fieldTarget
(
fieldTargetIOobject,
meshTarget

View File

@ -149,7 +149,7 @@ void MapVolFields
IOobject::MUST_READ
);
if (targetIO.headerOk())
if (targetIO.typeHeaderOk<fieldType>(true))
{
Info<< " interpolating onto existing field "
<< fieldName << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,7 +64,7 @@ bool setCellFieldType
);
// Check the "constant" directory
if (!fieldHeader.headerOk())
if (!fieldHeader.typeHeaderOk<fieldType>(true))
{
fieldHeader = IOobject
(
@ -76,7 +76,7 @@ bool setCellFieldType
}
// Check field exists
if (fieldHeader.headerOk())
if (fieldHeader.typeHeaderOk<fieldType>(true))
{
Info<< " Setting internal values of "
<< fieldHeader.headerClassName()
@ -210,7 +210,7 @@ bool setFaceFieldType
);
// Check the "constant" directory
if (!fieldHeader.headerOk())
if (!fieldHeader.typeHeaderOk<fieldType>(true))
{
fieldHeader = IOobject
(
@ -222,7 +222,7 @@ bool setFaceFieldType
}
// Check field exists
if (fieldHeader.headerOk())
if (fieldHeader.typeHeaderOk<fieldType>(true))
{
Info<< " Setting patchField values of "
<< fieldHeader.headerClassName()

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -56,6 +56,7 @@ Description
#include "point.H"
#include "triadField.H"
#include "transform.H"
#include "IOdictionary.H"
using namespace Foam;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,7 @@ Usage
#include "PackedBoolList.H"
#include "unitConversion.H"
#include "searchableSurfaces.H"
#include "IOdictionary.H"
using namespace Foam;

View File

@ -195,7 +195,7 @@ int main(int argc, char *argv[])
}
if (!csDictIoPtr->headerOk())
if (!csDictIoPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< "Cannot open coordinateSystems file\n "

View File

@ -315,7 +315,9 @@ int main(int argc, char *argv[])
Info<< "writing surfMesh as obj = oldSurfIn.obj" << endl;
surfIn.write("oldSurfIn.obj");
using Foam::surfMesh;
surfIn.write(fileName("oldSurfIn.obj"));
Info<< "runTime.instance() = " << runTime.instance() << endl;
@ -368,7 +370,7 @@ int main(int argc, char *argv[])
surfOut.write();
// write directly
surfOut.write("someName.ofs");
surfOut.surfMesh::write(fileName("someName.ofs"));
#if 1
const surfZoneList& zones = surfOut.surfZones();

View File

@ -175,7 +175,7 @@ int main(int argc, char *argv[])
}
if (!ioPtr->headerOk())
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
}
if (!ioPtr->headerOk())
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl

View File

@ -362,6 +362,7 @@ int main(int argc, char *argv[])
? runTime.path()/".."/outFileName
: runTime.path()/outFileName
);
globalCasePath.clean();
Info<< "Writing merged surface to " << globalCasePath << endl;

View File

@ -31,21 +31,18 @@ Description
Note
- best decomposition option is hierarchGeomDecomp since
guarantees square decompositions.
guarantees square decompositions.
- triangles might be present on multiple processors.
- merging uses geometric tolerance so take care with writing precision.
\*---------------------------------------------------------------------------*/
#include "treeBoundBox.H"
#include "FixedList.H"
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "distributedTriSurfaceMesh.H"
#include "mapDistribute.H"
#include "triSurfaceFields.H"
#include "Pair.H"
#include "localIOdictionary.H"
using namespace Foam;
@ -172,10 +169,11 @@ int main(int argc, char *argv[])
"triSurface", // local
runTime, // registry
IOobject::MUST_READ,
IOobject::NO_WRITE
IOobject::AUTO_WRITE
);
const fileName actualPath(io.filePath());
// Look for file (using searchableSurface rules)
const fileName actualPath(typeFilePath<searchableSurface>(io));
fileName localPath(actualPath);
localPath.replace(runTime.rootPath() + '/', "");
@ -197,7 +195,7 @@ int main(int argc, char *argv[])
dict.add("distributionType", distType);
dict.add("mergeDistance", SMALL);
IOdictionary ioDict
localIOdictionary ioDict
(
IOobject
(
@ -215,11 +213,13 @@ int main(int argc, char *argv[])
Info<< "Writing dummy bounds dictionary to " << ioDict.name()
<< nl << endl;
// Force writing in ascii
ioDict.regIOobject::writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
ioDict.time().writeCompression()
ioDict.time().writeCompression(),
true
);
}
@ -239,23 +239,17 @@ int main(int argc, char *argv[])
(
IOobject
(
surfMesh.searchableSurface::name(), // name
surfMesh.searchableSurface::instance(), // instance
surfMesh.searchableSurface::local(), // local
"faceCentres", // name
surfMesh.searchableSurface::time().timeName(), // instance
surfMesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surfMesh,
dimLength
dimLength,
s.faceCentres()
)
);
triSurfaceVectorField& fc = fcPtr();
forAll(fc, triI)
{
fc[triI] = s[triI].centre(s.points());
}
// Steal pointer and store object on surfMesh
fcPtr.ptr()->store();
@ -290,7 +284,7 @@ int main(int argc, char *argv[])
Info<< "Writing surface." << nl << endl;
surfMesh.searchableSurface::write();
surfMesh.objectRegistry::write();
Info<< "End\n" << endl;

View File

@ -43,6 +43,7 @@ Description
#include "absoluteEnthalpy.H"
#include "SLPtrList.H"
#include "IOdictionary.H"
using namespace Foam;