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

@ -9,7 +9,7 @@ IOobject phiBHeader
surfaceScalarField* phiBPtr = nullptr;
if (phiBHeader.headerOk())
if (phiBHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux ";

View File

@ -0,0 +1,56 @@
// Residual control used
if (residualControlUsed)
{
bool UConv = false;
bool p_rghConv = false;
bool EConv = false;
// Check which field is not used for control
{
if (UTol == -1 || !momentumPredictor)
{
UConv = true;
}
if (p_rghTol == -1)
{
p_rghConv = true;
}
if (ETol == -1)
{
EConv = true;
}
}
// Get the last initial residual of the solvers
if (momentumPredictor && !UConv)
{
if (UTol > cmptMax(solvPerfU.initialResidual()))
{
UConv = true;
}
}
if (!p_rghConv)
{
if (p_rghTol > solvPerfp_rgh.initialResidual())
{
p_rghConv = true;
}
}
if (!EConv)
{
if (ETol > solvPerfE.initialResidual())
{
EConv = true;
}
}
// Check if each field is converged
if (UConv && p_rghConv && EConv)
{
resReachedFluid = true;
}
}

View File

@ -79,7 +79,7 @@
IOobject::AUTO_WRITE
);
if (betavSolidIO.headerOk())
if (betavSolidIO.typeHeaderOk<volScalarField>(true))
{
betavSolid.set
(

View File

@ -11,7 +11,7 @@ IOobject turbulencePropertiesHeader
false
);
if (turbulencePropertiesHeader.headerOk())
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<compressible::turbulenceModel> turbulence
(

View File

@ -81,7 +81,7 @@ IOobject Hheader
autoPtr<volVectorField> HPtr;
if (Hheader.headerOk())
if (Hheader.typeHeaderOk<volVectorField>(true))
{
Info<< "\nReading field H\n" << endl;
@ -99,7 +99,7 @@ IOobject HdotGradHheader
autoPtr<volVectorField> HdotGradHPtr;
if (HdotGradHheader.headerOk())
if (HdotGradHheader.typeHeaderOk<volVectorField>(true))
{
Info<< "Reading field HdotGradH" << endl;

View File

@ -11,7 +11,13 @@
autoPtr<uniformDimensionedVectorField> linearAccelerationPtr;
if (linearAccelerationHeader.headerOk())
if
(
linearAccelerationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{
Info<< " Reading " << linearAccelerationHeader.name() << endl;
@ -33,7 +39,7 @@
autoPtr<uniformDimensionedVectorField> angularVelocityPtr;
if (angularVelocityHeader.headerOk())
if (angularVelocityHeader.typeHeaderOk<uniformDimensionedVectorField>(true))
{
Info<< " Reading " << angularVelocityHeader.name() << endl;
@ -55,7 +61,13 @@
autoPtr<uniformDimensionedVectorField> angularAccelerationPtr;
if (angularAccelerationHeader.headerOk())
if
(
angularAccelerationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{
Info<< " Reading " << angularAccelerationHeader.name() << endl;
@ -77,7 +89,13 @@
autoPtr<uniformDimensionedVectorField> centreOfRotationPtr;
if (centreOfRotationHeader.headerOk())
if
(
centreOfRotationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{
Info<< " Reading " << centreOfRotationHeader.name() << endl;

View File

@ -7,7 +7,7 @@ IOobject alphaPhi10Header
IOobject::AUTO_WRITE
);
const bool alphaRestart = alphaPhi10Header.headerOk();
const bool alphaRestart = alphaPhi10Header.typeHeaderOk<surfaceScalarField>();
// MULES flux from previous time-step
surfaceScalarField alphaPhi10

View File

@ -123,7 +123,7 @@ Foam::phaseModel::phaseModel
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,7 +55,7 @@ Foam::MovingPhaseModel<BasePhaseModel>::phi(const volVectorField& U) const
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;

View File

@ -121,7 +121,7 @@ Foam::phaseModel::phaseModel
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;

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
@ -87,7 +87,8 @@ int main(int argc, char *argv[])
(
format,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
IOstream::UNCOMPRESSED,
true
);
Info<< "Written old format faceList in = "
@ -149,7 +150,8 @@ int main(int argc, char *argv[])
(
format,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
IOstream::UNCOMPRESSED,
true
);
Info<< "Written new format faceList in = "

View File

@ -0,0 +1,3 @@
Test-IOField.C
EXE = $(FOAM_USER_APPBIN)/Test-IOField

View File

@ -0,0 +1,2 @@
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -0,0 +1,189 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Application
Test-IOField
Description
Test the processor-local reading of IOField (used in the lagrangian libs)
\*---------------------------------------------------------------------------*/
#include "IOField.H"
#include "argList.H"
#include "polyMesh.H"
#include "Time.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void write(const IOobject& io, const label sz)
{
IOField<label> fld(io, sz);
forAll(fld, i)
{
fld[i] = i+1000;
}
Pout<< "writing:" << fld << endl;
fld.write(sz > 0);
}
void read(const IOobject& io, const label sz)
{
bool valid = (sz > 0);
Pout<< " valid:" << valid << endl;
IOField<label> fld(io, valid);
Pout<< " wanted:" << sz << " actually read:" << fld.size() << endl;
if (fld.size() != sz)
{
FatalErrorInFunction<< "io:" << io.objectPath() << exit(FatalError);
}
}
void writeAndRead
(
const IOobject& io,
const label sz,
const word& writeType,
const IOobject::readOption readOpt,
const word& readType
)
{
Pout<< "** Writing:" << writeType
<< " Reading:" << readType << endl;
autoPtr<fileOperation> writeHandler(fileOperation::New(writeType));
fileHandler(writeHandler);
// Delete
Pout<< "Deleting:" << fileHandler().filePath(io.objectPath()) << endl;
fileHandler().rm(fileHandler().filePath(io.objectPath()));
// Write
Pout<< "Writing:" << fileHandler().objectPath(io) << endl;
write(io, sz);
autoPtr<fileOperation> readHandler(fileOperation::New(readType));
fileHandler(readHandler);
// Read
IOobject readIO(io);
readIO.readOpt() = readOpt;
Pout<< "Reading:" << fileHandler().filePath(readIO.objectPath()) << endl;
read(readIO, sz);
Pout<< "** Done writing:" << writeType
<< " Reading:" << readType << endl << endl << endl;
}
void readIfPresent
(
IOobject& io,
const label sz,
const word& readType
)
{
autoPtr<fileOperation> readHandler(fileOperation::New(readType));
fileHandler(readHandler);
// Read
Pout<< "Reading:" << fileHandler().filePath(io.objectPath()) << endl;
io.readOpt() = IOobject::READ_IF_PRESENT;
read(io, sz);
}
// Main program:
int main(int argc, char *argv[])
{
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
label sz = 0;
if (Pstream::myProcNo() % 2)
{
sz = 1;
}
IOobject io
(
"bla",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
);
wordList handlers
(
Foam::fileOperation::wordConstructorTablePtr_->sortedToc()
);
Info<< "Found handlers:" << handlers << endl;
/*
forAll(handlers, readi)
{
const word& readHandler = handlers[readi];
readIfPresent(io, sz, readHandler);
}
*/
forAll(handlers, writei)
{
const word& writeHandler = handlers[writei];
forAll(handlers, readi)
{
const word& readHandler = handlers[readi];
writeAndRead
(
io,
sz,
writeHandler,
IOobject::READ_IF_PRESENT,
readHandler
);
}
}
Pout<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
Test-decomposedBlockData.C
EXE = $(FOAM_USER_APPBIN)/Test-decomposedBlockData

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Application
Test-decomposedBlockData
Description
Convert decomposedBlockData into its components.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "decomposedBlockData.H"
#include "OFstream.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.append("file");
#include "setRootCase.H"
if (!Pstream::parRun())
{
FatalErrorInFunction
<< "Run in parallel" << exit(FatalError);
}
#include "createTime.H"
const fileName file(args[1]);
Info<< "Reading " << file << nl << endl;
decomposedBlockData data
(
Pstream::worldComm,
IOobject
(
file,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
data.rename(data.name() + "Data");
fileName objPath(data.objectPath());
mkDir(objPath.path());
Info<< "Opening output file " << objPath << nl << endl;
OFstream os
(
objPath,
IOstream::BINARY,
IOstream::currentVersion,
runTime.writeCompression()
);
if (!os.good())
{
FatalErrorInFunction
<< "Failed opening " << objPath << exit(FatalError);
}
if (!data.writeData(os))
{
FatalErrorInFunction
<< "Failed writing " << objPath << exit(FatalError);
}
return 0;
}
// ************************************************************************* //

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,22 +158,26 @@ 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
if (!fileHandler().exists(timePath/uniformDir))
{
fileHandler().cp
(
runTime.timePath()/uniformDir,
timePath/uniformDir
);
}
}
else
{
// link with relative paths
@ -185,11 +190,15 @@ void decomposeUniform
fileName currentDir(cwd());
chDir(timePath);
ln
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
)
);
if (timePath != prevTimePath)
{
Info<< "Processor " << proci
<< ": linking " << runTime.timePath() << nl
<< " to " << processorDb.timePath() << endl;
cp(runTime.timePath(), processorDb.timePath());
<< ": 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
@ -994,13 +997,16 @@ int main(int argc, char *argv[])
// directory copy from the master processor
{
fileName uniformDir0
(
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);
}
}
@ -1009,13 +1015,16 @@ int main(int argc, char *argv[])
if (regioni == 0 && regionDir != word::null)
{
fileName uniformDir0
(
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

@ -37,15 +37,12 @@ Note
\*---------------------------------------------------------------------------*/
#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;

View File

@ -55,6 +55,20 @@ OptimisationSwitches
// - inotifyMaster : do inotify (and file reading) only on master.
fileModificationChecking timeStampMaster;
//- 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;
commsType nonBlocking; //scheduled; //blocking;
floatTransfer 0;
nProcsSimpleSum 0;

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
@ -38,6 +38,8 @@ Description
#include "timer.H"
#include "IFstream.H"
#include "DynamicList.H"
#include "IOstreams.H"
#include "Pstream.H"
#include <fstream>
#include <cstdlib>
@ -294,6 +296,16 @@ bool Foam::chDir(const fileName& dir)
bool Foam::mkDir(const fileName& pathName, mode_t mode)
{
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : pathName:" << pathName << " mode:" << mode
<< endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
// empty names are meaningless
if (pathName.empty())
{
@ -440,13 +452,25 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
bool Foam::chMod(const fileName& name, const mode_t m)
{
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
return ::chmod(name.c_str(), m) == 0;
}
mode_t Foam::mode(const fileName& name)
mode_t Foam::mode(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
}
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return fileStatus.status().st_mode;
@ -458,14 +482,26 @@ mode_t Foam::mode(const fileName& name)
}
Foam::fileName::Type Foam::type(const fileName& name)
Foam::fileName::Type Foam::type(const fileName& name, const bool followLink)
{
mode_t m = mode(name);
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
mode_t m = mode(name, followLink);
if (S_ISREG(m))
{
return fileName::FILE;
}
else if (S_ISLNK(m))
{
return fileName::LINK;
}
else if (S_ISDIR(m))
{
return fileName::DIRECTORY;
@ -477,27 +513,73 @@ Foam::fileName::Type Foam::type(const fileName& name)
}
bool Foam::exists(const fileName& name, const bool checkGzip)
bool Foam::exists
(
const fileName& name,
const bool checkGzip,
const bool followLink
)
{
return mode(name) || isFile(name, checkGzip);
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << " checkGzip:" << checkGzip
<< endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
return mode(name, followLink) || isFile(name, checkGzip, followLink);
}
bool Foam::isDir(const fileName& name)
bool Foam::isDir(const fileName& name, const bool followLink)
{
return S_ISDIR(mode(name));
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
return S_ISDIR(mode(name, followLink));
}
bool Foam::isFile(const fileName& name, const bool checkGzip)
bool Foam::isFile
(
const fileName& name,
const bool checkGzip,
const bool followLink
)
{
return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz")));
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << " checkGzip:" << checkGzip
<< endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
return
S_ISREG(mode(name, followLink))
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)));
}
off_t Foam::fileSize(const fileName& name)
off_t Foam::fileSize(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return fileStatus.status().st_size;
@ -509,9 +591,17 @@ off_t Foam::fileSize(const fileName& name)
}
time_t Foam::lastModified(const fileName& name)
time_t Foam::lastModified(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return fileStatus.status().st_mtime;
@ -523,9 +613,17 @@ time_t Foam::lastModified(const fileName& name)
}
double Foam::highResLastModified(const fileName& name)
double Foam::highResLastModified(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : name:" << name << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return
@ -543,7 +641,8 @@ Foam::fileNameList Foam::readDir
(
const fileName& directory,
const fileName::Type type,
const bool filtergz
const bool filtergz,
const bool followLink
)
{
// Initial filename list size
@ -552,8 +651,12 @@ Foam::fileNameList Foam::readDir
if (POSIX::debug)
{
InfoInFunction
<< "reading directory " << directory << endl;
//InfoInFunction
Pout<< FUNCTION_NAME << " : reading directory " << directory << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
// Setup empty string list MAXTVALUES long
@ -603,7 +706,7 @@ Foam::fileNameList Foam::readDir
)
)
{
if ((directory/fName).type() == type)
if ((directory/fName).type(followLink) == type)
{
if (nEntries >= dirEntries.size())
{
@ -633,18 +736,28 @@ Foam::fileNameList Foam::readDir
}
bool Foam::cp(const fileName& src, const fileName& dest)
bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
{
if (POSIX::debug)
{
Pout<< FUNCTION_NAME << " : src:" << src << " dest:" << dest << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
// Make sure source exists.
if (!exists(src))
{
return false;
}
const fileName::Type srcType = src.type(followLink);
fileName destFile(dest);
// Check type of source file.
if (src.type() == fileName::FILE)
if (srcType == fileName::FILE)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
@ -684,7 +797,23 @@ bool Foam::cp(const fileName& src, const fileName& dest)
return false;
}
}
else if (src.type() == fileName::DIRECTORY)
else if (srcType == fileName::LINK)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
{
destFile = destFile/src.name();
}
// Make sure the destination directory exists.
if (!isDir(destFile.path()) && !mkDir(destFile.path()))
{
return false;
}
ln(src, destFile);
}
else if (srcType == fileName::DIRECTORY)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
@ -699,7 +828,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// Copy files
fileNameList contents = readDir(src, fileName::FILE, false);
fileNameList contents = readDir(src, fileName::FILE, false, followLink);
forAll(contents, i)
{
if (POSIX::debug)
@ -710,11 +839,18 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// File to file.
cp(src/contents[i], destFile/contents[i]);
cp(src/contents[i], destFile/contents[i], followLink);
}
// Copy sub directories.
fileNameList subdirs = readDir(src, fileName::DIRECTORY);
fileNameList subdirs = readDir
(
src,
fileName::DIRECTORY,
false,
followLink
);
forAll(subdirs, i)
{
if (POSIX::debug)
@ -725,7 +861,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// Dir to Dir.
cp(src/subdirs[i], destFile);
cp(src/subdirs[i], destFile, followLink);
}
}
@ -737,9 +873,13 @@ bool Foam::ln(const fileName& src, const fileName& dst)
{
if (POSIX::debug)
{
InfoInFunction
<< "Create softlink from : " << src << " to " << dst
<< endl;
//InfoInFunction
Pout<< FUNCTION_NAME
<< " : Create softlink from : " << src << " to " << dst << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
if (exists(dst))
@ -770,18 +910,22 @@ bool Foam::ln(const fileName& src, const fileName& dst)
}
bool Foam::mv(const fileName& src, const fileName& dst)
bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink)
{
if (POSIX::debug)
{
InfoInFunction
<< "Move : " << src << " to " << dst << endl;
//InfoInFunction
Pout<< FUNCTION_NAME << " : Move : " << src << " to " << dst << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
if
(
dst.type() == fileName::DIRECTORY
&& src.type() != fileName::DIRECTORY
&& src.type(followLink) != fileName::DIRECTORY
)
{
const fileName dstName(dst/src.name());
@ -799,8 +943,13 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
{
if (POSIX::debug)
{
InfoInFunction
<< "mvBak : " << src << " to extension " << ext << endl;
//InfoInFunction
Pout<< FUNCTION_NAME
<< " : moving : " << src << " to extension " << ext << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
if (exists(src, false))
@ -836,8 +985,12 @@ bool Foam::rm(const fileName& file)
{
if (POSIX::debug)
{
InfoInFunction
<< "Removing : " << file << endl;
//InfoInFunction
Pout<< FUNCTION_NAME << " : Removing : " << file << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
// Try returning plain file name; if not there, try with .gz
@ -856,8 +1009,12 @@ bool Foam::rmDir(const fileName& directory)
{
if (POSIX::debug)
{
InfoInFunction
<< "removing directory " << directory << endl;
//InfoInFunction
Pout<< FUNCTION_NAME << " : removing directory " << directory << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
}
// Pointers to the directory entries
@ -883,7 +1040,7 @@ bool Foam::rmDir(const fileName& directory)
{
fileName path = directory/fName;
if (path.type() == fileName::DIRECTORY)
if (path.type(false) == fileName::DIRECTORY)
{
if (!rmDir(path))
{
@ -1192,4 +1349,143 @@ Foam::scalar Foam::osRandomDouble()
}
static Foam::DynamicList<Foam::autoPtr<pthread_t>> threads_;
static Foam::DynamicList<Foam::autoPtr<pthread_mutex_t>> mutexes_;
Foam::label Foam::allocateThread()
{
forAll(threads_, i)
{
if (!threads_[i].valid())
{
if (POSIX::debug)
{
Pout<< "allocateThread : reusing index:" << i << endl;
}
// Reuse entry
threads_[i].reset(new pthread_t());
return i;
}
}
label index = threads_.size();
if (POSIX::debug)
{
Pout<< "allocateThread : new index:" << index << endl;
}
threads_.append(autoPtr<pthread_t>(new pthread_t()));
return index;
}
void Foam::createThread
(
const label index,
void *(*start_routine) (void *),
void *arg
)
{
if (POSIX::debug)
{
Pout<< "createThread : index:" << index << endl;
}
if (pthread_create(&threads_[index](), nullptr, start_routine, arg))
{
FatalErrorInFunction
<< "Failed starting thread " << index << exit(FatalError);
}
}
void Foam::joinThread(const label index)
{
if (POSIX::debug)
{
Pout<< "freeThread : join:" << index << endl;
}
if (pthread_join(threads_[index](), nullptr))
{
FatalErrorInFunction << "Failed freeing thread " << index
<< exit(FatalError);
}
}
void Foam::freeThread(const label index)
{
if (POSIX::debug)
{
Pout<< "freeThread : index:" << index << endl;
}
threads_[index].clear();
}
Foam::label Foam::allocateMutex()
{
forAll(mutexes_, i)
{
if (!mutexes_[i].valid())
{
if (POSIX::debug)
{
Pout<< "allocateMutex : reusing index:" << i << endl;
}
// Reuse entry
mutexes_[i].reset(new pthread_mutex_t());
return i;
}
}
label index = mutexes_.size();
if (POSIX::debug)
{
Pout<< "allocateMutex : new index:" << index << endl;
}
mutexes_.append(autoPtr<pthread_mutex_t>(new pthread_mutex_t()));
return index;
}
void Foam::lockMutex(const label index)
{
if (POSIX::debug)
{
Pout<< "lockMutex : index:" << index << endl;
}
if (pthread_mutex_lock(&mutexes_[index]()))
{
FatalErrorInFunction << "Failed locking mutex " << index
<< exit(FatalError);
}
}
void Foam::unlockMutex(const label index)
{
if (POSIX::debug)
{
Pout<< "unlockMutex : index:" << index << endl;
}
if (pthread_mutex_unlock(&mutexes_[index]()))
{
FatalErrorInFunction << "Failed unlocking mutex " << index
<< exit(FatalError);
}
}
void Foam::freeMutex(const label index)
{
if (POSIX::debug)
{
Pout<< "freeMutex : index:" << index << endl;
}
mutexes_[index].clear();
}
// ************************************************************************* //

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
@ -38,7 +38,12 @@ Foam::fileStat::fileStat()
{}
Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
Foam::fileStat::fileStat
(
const fileName& fName,
const bool followLink,
const unsigned int maxTime
)
{
// Work on volatile
volatile bool locIsValid = false;
@ -46,6 +51,8 @@ Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
timer myTimer(maxTime);
if (!timedOut(myTimer))
{
if (followLink)
{
if (::stat(fName.c_str(), &status_) != 0)
{
@ -56,6 +63,18 @@ Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
locIsValid = true;
}
}
else
{
if (::lstat(fName.c_str(), &status_) != 0)
{
locIsValid = false;
}
else
{
locIsValid = true;
}
}
}
// Copy into (non-volatile, possible register based) member var
isValid_ = locIsValid;

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
@ -79,8 +79,15 @@ public:
//- Empty constructor
fileStat();
//- Construct from components
fileStat(const fileName& fName, const unsigned int maxTime=0);
//- Construct from components.
// followLink : in case of link get status of pointed-to file
// maxTime : time out
fileStat
(
const fileName& fName,
const bool followLink = true,
const unsigned int maxTime = 0
);
//- Construct from Istream
fileStat(Istream&);

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
@ -143,7 +143,7 @@ public:
//- Return the number of (groups)
inline int ngroups() const
{
return preg_ ? preg_->re_nsub : 0;
return int(preg_ ? preg_->re_nsub : 0);
}

View File

@ -5,6 +5,14 @@ global/argList/argList.C
global/clock/clock.C
global/etcFiles/etcFiles.C
fileOps = global/fileOperations
$(fileOps)/fileOperation/fileOperation.C
$(fileOps)/uncollatedFileOperation/uncollatedFileOperation.C
$(fileOps)/masterUncollatedFileOperation/masterUncollatedFileOperation.C
$(fileOps)/collatedFileOperation/collatedFileOperation.C
$(fileOps)/collatedFileOperation/threadedCollatedOFstream.C
$(fileOps)/collatedFileOperation/OFstreamCollator.C
bools = primitives/bools
$(bools)/bool/bool.C
$(bools)/bool/boolIO.C
@ -161,6 +169,7 @@ $(gzstream)/gzstream.C
Fstreams = $(Streams)/Fstreams
$(Fstreams)/IFstream.C
$(Fstreams)/OFstream.C
$(Fstreams)/masterOFstream.C
Tstreams = $(Streams)/Tstreams
$(Tstreams)/ITstream.C
@ -210,10 +219,16 @@ $(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/baseIOdictionary.C
$(IOdictionary)/baseIOdictionaryIO.C
$(IOdictionary)/IOdictionary.C
$(IOdictionary)/IOdictionaryIO.C
$(IOdictionary)/localIOdictionary.C
$(IOdictionary)/unwatchedIOdictionary.C
db/IOobjects/IOMap/IOMapName.C
db/IOobjects/decomposedBlockData/decomposedBlockData.C
db/IOobjects/GlobalIOField/GlobalIOFields.C
IOobject = db/IOobject
$(IOobject)/IOobject.C

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
@ -32,6 +32,71 @@ License
namespace Foam
{
defineTypeNameAndDebug(IOobject, 0);
template<>
const char* NamedEnum
<
IOobject::fileCheckTypes,
4
>::names[] =
{
"timeStamp",
"timeStampMaster",
"inotify",
"inotifyMaster"
};
}
const Foam::NamedEnum<Foam::IOobject::fileCheckTypes, 4>
Foam::IOobject::fileCheckTypesNames;
// Default fileCheck type
Foam::IOobject::fileCheckTypes Foam::IOobject::fileModificationChecking
(
fileCheckTypesNames.read
(
debug::optimisationSwitches().lookup
(
"fileModificationChecking"
)
)
);
namespace Foam
{
// Register re-reader
class addfileModificationCheckingToOpt
:
public ::Foam::simpleRegIOobject
{
public:
addfileModificationCheckingToOpt(const char* name)
:
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
{}
virtual ~addfileModificationCheckingToOpt()
{}
virtual void readData(Foam::Istream& is)
{
IOobject::fileModificationChecking =
IOobject::fileCheckTypesNames.read(is);
}
virtual void writeData(Foam::Ostream& os) const
{
os << IOobject::fileCheckTypesNames
[IOobject::fileModificationChecking];
}
};
addfileModificationCheckingToOpt addfileModificationCheckingToOpt_
(
"fileModificationChecking"
);
}
@ -129,6 +194,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(false),
objState_(GOOD)
{
if (objectRegistry::debug)
@ -149,7 +215,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
bool registerObject,
bool globalObject
)
:
name_(name),
@ -161,6 +228,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD)
{
if (objectRegistry::debug)
@ -179,7 +247,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
bool registerObject,
bool globalObject
)
:
name_(),
@ -191,6 +260,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD)
{
if (!fileNameComponents(path, instance_, local_, name_))
@ -210,6 +280,46 @@ Foam::IOobject::IOobject
}
Foam::IOobject::IOobject
(
const IOobject& io,
const objectRegistry& registry
)
:
name_(io.name_),
headerClassName_(io.headerClassName_),
note_(io.note_),
instance_(io.instance_),
local_(io.local_),
db_(registry),
rOpt_(io.rOpt_),
wOpt_(io.wOpt_),
registerObject_(io.registerObject_),
globalObject_(io.globalObject_),
objState_(io.objState_)
{}
Foam::IOobject::IOobject
(
const IOobject& io,
const word& name
)
:
name_(name),
headerClassName_(io.headerClassName_),
note_(io.note_),
instance_(io.instance_),
local_(io.local_),
db_(io.db_),
rOpt_(io.rOpt_),
wOpt_(io.wOpt_),
registerObject_(io.registerObject_),
globalObject_(io.globalObject_),
objState_(io.objState_)
{}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOobject::~IOobject()
@ -296,144 +406,17 @@ Foam::fileName Foam::IOobject::path
}
Foam::fileName Foam::IOobject::filePath() const
Foam::fileName Foam::IOobject::localFilePath(const word& typeName) const
{
if (instance().isAbsolute())
{
fileName objectPath = instance()/name();
if (isFile(objectPath))
{
return objectPath;
}
else
{
return fileName::null;
}
}
else
{
fileName path = this->path();
fileName objectPath = path/name();
if (isFile(objectPath))
{
return objectPath;
}
else
{
if
(
time().processorCase()
&& (
instance() == time().system()
|| instance() == time().constant()
)
)
{
fileName parentObjectPath =
rootPath()/time().globalCaseName()
/instance()/db_.dbDir()/local()/name();
if (isFile(parentObjectPath))
{
return parentObjectPath;
}
}
if (!isDir(path))
{
word newInstancePath = time().findInstancePath
(
instant(instance())
);
if (newInstancePath.size())
{
fileName fName
(
rootPath()/caseName()
/newInstancePath/db_.dbDir()/local()/name()
);
if (isFile(fName))
{
return fName;
}
}
}
}
return fileName::null;
}
// Do not check for undecomposed files
return fileHandler().filePath(false, *this, typeName);
}
Foam::Istream* Foam::IOobject::objectStream()
Foam::fileName Foam::IOobject::globalFilePath(const word& typeName) const
{
return objectStream(filePath());
}
Foam::Istream* Foam::IOobject::objectStream(const fileName& fName)
{
if (fName.size())
{
IFstream* isPtr = new IFstream(fName);
if (isPtr->good())
{
return isPtr;
}
else
{
delete isPtr;
return nullptr;
}
}
else
{
return nullptr;
}
}
bool Foam::IOobject::headerOk()
{
bool ok = true;
Istream* isPtr = objectStream();
// If the stream has failed return
if (!isPtr)
{
if (objectRegistry::debug)
{
InfoInFunction
<< "File " << objectPath() << " could not be opened"
<< endl;
}
ok = false;
}
else
{
// Try reading header
if (!readHeader(*isPtr))
{
if (objectRegistry::debug)
{
IOWarningInFunction((*isPtr))
<< "Failed to read header of file " << objectPath()
<< endl;
}
ok = false;
}
}
delete isPtr;
return ok;
// Check for undecomposed files
return fileHandler().filePath(true, *this, typeName);
}
@ -465,6 +448,7 @@ void Foam::IOobject::operator=(const IOobject& io)
local_ = io.local_;
rOpt_ = io.rOpt_;
wOpt_ = io.wOpt_;
globalObject_ = io.globalObject_;
objState_ = io.objState_;
}

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
@ -76,6 +76,7 @@ SourceFiles
#include "typeInfo.H"
#include "autoPtr.H"
#include "InfoProxy.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,6 +120,16 @@ public:
NO_WRITE = 1
};
//- Enumeration defining the file checking options
enum fileCheckTypes
{
timeStamp,
timeStampMaster,
inotify,
inotifyMaster
};
static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames;
private:
@ -151,6 +162,9 @@ private:
//- Register object created from this IOobject with registry if true
bool registerObject_;
//- Is object same for all processors
bool globalObject_;
//- IOobject state
objectState objState_;
@ -159,14 +173,6 @@ protected:
// Protected Member Functions
//- Construct and return an IFstream for the object.
// The results is nullptr if the stream construction failed
Istream* objectStream();
//- Construct and return an IFstream for the object given the
// exact file. The results is nullptr if the stream construction failed
Istream* objectStream(const fileName&);
//- Set the object state to bad
void setBad(const string&);
@ -199,6 +205,9 @@ public:
template<class Name>
static inline word groupName(Name name, const word& group);
//- Type of file modification checking
static fileCheckTypes fileModificationChecking;
// Constructors
@ -222,7 +231,8 @@ public:
const objectRegistry& registry,
readOption r=NO_READ,
writeOption w=NO_WRITE,
bool registerObject=true
bool registerObject=true,
bool globalObject = false
);
//- Construct from path, registry, io options
@ -233,15 +243,36 @@ public:
const objectRegistry& registry,
readOption r=NO_READ,
writeOption w=NO_WRITE,
bool registerObject=true
bool registerObject=true,
bool globalObject = false
);
//- Construct from copy resetting registry
IOobject
(
const IOobject& io,
const objectRegistry& registry
);
//- Construct from copy resetting name
IOobject
(
const IOobject& io,
const word& name
);
//- Clone
Foam::autoPtr<IOobject> clone() const
autoPtr<IOobject> clone() const
{
return autoPtr<IOobject>(new IOobject(*this));
}
//- Clone resetting registry
autoPtr<IOobject> clone(const objectRegistry& registry) const
{
return autoPtr<IOobject>(new IOobject(*this, registry));
}
//- Destructor
virtual ~IOobject();
@ -269,6 +300,12 @@ public:
return headerClassName_;
}
//- Return name of the class name read from header
word& headerClassName()
{
return headerClassName_;
}
//- Return non-constant access to the optional note
string& note()
{
@ -299,6 +336,18 @@ public:
return registerObject_;
}
//- Is object same for all processors
bool& globalObject()
{
return globalObject_;
}
//- Is object same for all processors
bool globalObject() const
{
return globalObject_;
}
// Read/write options
@ -366,9 +415,11 @@ public:
return path()/name();
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
fileName filePath() const;
//- Helper for filePath that searches locally.
fileName localFilePath(const word& typeName) const;
//- Helper for filePath that searches up if in parallel
fileName globalFilePath(const word& typeName) const;
// Reading
@ -376,9 +427,14 @@ public:
//- Read header
bool readHeader(Istream&);
//- Read and check header info
bool headerOk();
//- Read header (uses typeFilePath to find file) and check header
// info. Optionally checks headerClassName against type
template<class Type>
bool typeHeaderOk(const bool checkType = true);
//- Helper: warn that type does not support re-reading
template<class Type>
void warnNoRereading() const;
// Writing
@ -435,6 +491,26 @@ template<>
Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
//- Template function for obtaining global status
template<class T>
inline bool typeGlobal()
{
return false;
}
//- Template function for obtaining filePath
template<class T>
inline fileName typeFilePath(const IOobject& io)
{
return
(
typeGlobal<T>()
? io.globalFilePath(T::typeName)
: io.localFilePath(T::typeName)
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
@ -445,6 +521,12 @@ Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IOobjectTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -36,6 +36,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<IOobject>& ip)
os << "IOobject: "
<< io.type() << token::SPACE
<< io.name() << token::SPACE
<< "readOpt:" << token::SPACE << io.readOpt() << token::SPACE
<< "writeOpt:" << token::SPACE << io.writeOpt() << token::SPACE
<< "globalObject:" << token::SPACE << io.globalObject() << token::SPACE
<< io.path() << endl;
return os;

View File

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
\*---------------------------------------------------------------------------*/
#include "IOobject.H"
#include "fileOperation.H"
#include "Istream.H"
#include "IOstreams.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
bool Foam::IOobject::typeHeaderOk(const bool checkType)
{
bool ok = true;
// Everyone check or just master
bool masterOnly =
typeGlobal<Type>()
&& (
IOobject::fileModificationChecking == timeStampMaster
|| IOobject::fileModificationChecking == inotifyMaster
);
const fileOperation& fp = Foam::fileHandler();
// Determine local status
if (!masterOnly || Pstream::master())
{
fileName fName(typeFilePath<Type>(*this));
ok = fp.readHeader(*this, fName, Type::typeName);
if (ok && checkType && headerClassName_ != Type::typeName)
{
WarningInFunction
<< "unexpected class name " << headerClassName_
<< " expected " << Type::typeName
<< " when reading " << fName << endl;
ok = false;
}
}
// If masterOnly make sure all processors know about it
if (masterOnly)
{
Pstream::scatter(ok);
}
return ok;
}
template<class Type>
void Foam::IOobject::warnNoRereading() const
{
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningInFunction
<< Type::typeName << ' ' << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but " << Type::typeName
<< " does not support automatic rereading."
<< endl;
}
}
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More