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; surfaceScalarField* phiBPtr = nullptr;
if (phiBHeader.headerOk()) if (phiBHeader.typeHeaderOk<surfaceScalarField>(true))
{ {
Info<< "Reading face flux "; 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 IOobject::AUTO_WRITE
); );
if (betavSolidIO.headerOk()) if (betavSolidIO.typeHeaderOk<volScalarField>(true))
{ {
betavSolid.set betavSolid.set
( (

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,6 +48,7 @@ Description
#include "faceZoneSet.H" #include "faceZoneSet.H"
#include "pointZoneSet.H" #include "pointZoneSet.H"
#include "timeSelector.H" #include "timeSelector.H"
#include "collatedFileOperation.H"
#include <stdio.h> #include <stdio.h>
@ -805,6 +806,11 @@ commandStatus parseAction(const word& actionName)
int main(int argc, char *argv[]) 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); timeSelector::addOptions(true, false);
#include "addRegionOption.H" #include "addRegionOption.H"
argList::addBoolOption("noVTK", "do not write VTK files"); argList::addBoolOption("noVTK", "do not write VTK files");

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,6 +39,8 @@ Description
#include "cellZoneSet.H" #include "cellZoneSet.H"
#include "faceZoneSet.H" #include "faceZoneSet.H"
#include "pointZoneSet.H" #include "pointZoneSet.H"
#include "IOdictionary.H"
#include "collatedFileOperation.H"
using namespace Foam; using namespace Foam;
@ -191,6 +193,11 @@ polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
int main(int argc, char *argv[]) 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); timeSelector::addOptions(true, false);
#include "addDictOption.H" #include "addDictOption.H"
#include "addRegionOption.H" #include "addRegionOption.H"

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,9 +49,19 @@ Description
#include "cellIOList.H" #include "cellIOList.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "IOPtrList.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 "writeMeshObject.H"
#include "fieldDictionary.H"
using namespace Foam; using namespace Foam;
@ -79,7 +89,7 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
bool writeOk = false; bool writeOk = false;
if (io.headerOk()) if (io.typeHeaderOk<cellZoneMesh>(false))
{ {
Info<< " Reading " << io.headerClassName() Info<< " Reading " << io.headerClassName()
<< " : " << name << endl; << " : " << name << endl;
@ -130,7 +140,8 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
( (
IOstream::ASCII, IOstream::ASCII,
IOstream::currentVersion, 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[]) int main(int argc, char *argv[])
@ -165,6 +245,8 @@ int main(int argc, char *argv[])
#include "createTime.H" #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 // 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; Info<< "Time = " << runTime.timeName() << endl;
// Convert all the standard mesh files // Convert all the standard mesh files
writeMeshObject<cellCompactIOList>("cells", meshDir, runTime); writeMeshObject<cellCompactIOList, cellIOList>
(
"cells",
meshDir,
runTime
);
writeMeshObject<labelIOList>("owner", meshDir, runTime); writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", meshDir, runTime); writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceCompactIOList>("faces", meshDir, runTime); writeMeshObject<faceCompactIOList, faceIOList>
(
"faces",
meshDir,
runTime
);
writeMeshObject<pointIOField>("points", 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>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime); writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime); writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
@ -248,22 +343,196 @@ int main(int argc, char *argv[])
|| headerClassName == pointSphericalTensorField::typeName || headerClassName == pointSphericalTensorField::typeName
|| headerClassName == pointSymmTensorField::typeName || headerClassName == pointSymmTensorField::typeName
|| headerClassName == pointTensorField::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 Info<< " Reading " << headerClassName
<< " : " << iter()->name() << endl; << " : " << iter()->name() << endl;
fieldDictionary fDict fieldDictionary fDict(*iter(), headerClassName);
(
*iter(),
headerClassName
);
Info<< " Writing " << iter()->name() << endl; Info<< " Writing " << iter()->name() << endl;
fDict.regIOobject::write(); 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; Info<< endl;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -188,11 +188,12 @@ void Foam::lagrangianFieldDecomposer::decomposeFields
const PtrList<GeoField>& fields const PtrList<GeoField>& fields
) const ) const
{ {
if (particleIndices_.size()) //if (particleIndices_.size())
{ {
bool valid = particleIndices_.size() > 0;
forAll(fields, fieldi) 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 PtrList<GeoField>& fields
) const ) const
{ {
if (particleIndices_.size()) //if (particleIndices_.size())
{ {
bool valid = particleIndices_.size() > 0;
forAll(fields, fieldi) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -174,12 +174,43 @@ int main(int argc, char *argv[])
const bool allRegions = args.optionFound("allRegions"); const bool allRegions = args.optionFound("allRegions");
// determine the processor count directly wordList regionNames;
label nProcs = 0; wordList regionDirs;
while (isDir(args.path()/(word("processor") + name(nProcs)))) 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) if (!nProcs)
{ {
@ -222,9 +253,8 @@ int main(int argc, char *argv[])
if (timeDirs.empty()) if (timeDirs.empty())
{ {
FatalErrorInFunction WarningInFunction << "No times selected";
<< "No times selected" exit(1);
<< exit(FatalError);
} }
@ -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) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
@ -550,17 +544,26 @@ int main(int argc, char *argv[])
forAll(databases, proci) forAll(databases, proci)
{ {
fileNameList cloudDirs fileName lagrangianDir
( (
readDir fileHandler().filePath
( (
databases[proci].timePath() databases[proci].timePath()
/ regionDir / regionDir
/ cloud::prefix, / cloud::prefix
fileName::DIRECTORY
) )
); );
fileNameList cloudDirs;
if (!lagrangianDir.empty())
{
cloudDirs = fileHandler().readDir
(
lagrangianDir,
fileName::DIRECTORY
);
}
forAll(cloudDirs, i) forAll(cloudDirs, i)
{ {
// Check if we already have cloud objects for this // Check if we already have cloud objects for this
@ -995,12 +998,15 @@ int main(int argc, char *argv[])
{ {
fileName uniformDir0 fileName uniformDir0
( (
databases[0].timePath()/regionDir/"uniform" fileHandler().filePath
(
databases[0].timePath()/regionDir/"uniform"
)
); );
if (isDir(uniformDir0)) if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
{ {
cp(uniformDir0, runTime.timePath()/regionDir); fileHandler().cp(uniformDir0, runTime.timePath()/regionDir);
} }
} }
@ -1010,12 +1016,15 @@ int main(int argc, char *argv[])
{ {
fileName uniformDir0 fileName uniformDir0
( (
databases[0].timePath()/"uniform" fileHandler().filePath
(
databases[0].timePath()/"uniform"
)
); );
if (isDir(uniformDir0)) if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
{ {
cp(uniformDir0, runTime.timePath()); fileHandler().cp(uniformDir0, runTime.timePath());
} }
} }
} }

View File

@ -548,20 +548,7 @@ int main(int argc, char *argv[])
bool writeCellDist = args.optionFound("cellDist"); bool writeCellDist = args.optionFound("cellDist");
int nProcs = 0; label nProcs = fileHandler().nProcs(args.path());
while
(
isDir
(
args.rootPath()
/ args.caseName()
/ fileName(word("processor") + name(nProcs))
)
)
{
nProcs++;
}
Info<< "Found " << nProcs << " processor directories" << nl << endl; Info<< "Found " << nProcs << " processor directories" << nl << endl;
@ -609,13 +596,21 @@ int main(int argc, char *argv[])
databases[proci].setTime(timeDirs[timeI], timeI); databases[proci].setTime(timeDirs[timeI], timeI);
} }
const fileName meshPath = IOobject facesIO
databases[0].path() (
/databases[0].timeName() "faces",
/regionDir databases[0].timeName(),
/polyMesh::meshSubDir; 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; Info<< "No mesh." << nl << endl;
continue; continue;

View File

@ -115,7 +115,10 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// Check who has a mesh // 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) if (!haveMesh)
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,6 +30,7 @@ License
#include "fvMesh.H" #include "fvMesh.H"
#include "Time.H" #include "Time.H"
#include "patchZones.H" #include "patchZones.H"
#include "collatedFileOperation.H"
// VTK includes // VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
@ -249,6 +250,12 @@ Foam::vtkPV3Foam::vtkPV3Foam
printMemory(); 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 // avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path()); fileName fullCasePath(fileName(FileName).path());
@ -567,7 +574,13 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
if if
( (
isFile(runTime.path()/timeName/meshDir_/"points") isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk() && IOobject
(
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
) )
{ {
break; break;

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,6 +31,7 @@ License
#include "Time.H" #include "Time.H"
#include "patchZones.H" #include "patchZones.H"
#include "OStringStream.H" #include "OStringStream.H"
#include "collatedFileOperation.H"
// VTK includes // VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
@ -164,6 +165,12 @@ Foam::vtkPV3blockMesh::vtkPV3blockMesh
<< FileName << endl; << 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 // avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path()); fileName fullCasePath(fileName(FileName).path());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,6 +30,7 @@ License
#include "fvMesh.H" #include "fvMesh.H"
#include "Time.H" #include "Time.H"
#include "patchZones.H" #include "patchZones.H"
#include "collatedFileOperation.H"
// VTK includes // VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
@ -249,6 +250,12 @@ Foam::vtkPVFoam::vtkPVFoam
printMemory(); 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 // avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path()); fileName fullCasePath(fileName(FileName).path());
@ -566,8 +573,13 @@ double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
if if
( (
isFile(runTime.path()/timeName/meshDir_/"points") IOobject
&& IOobject("points", timeName, meshDir_, runTime).headerOk() (
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
) )
{ {
break; break;

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,6 +31,7 @@ License
#include "Time.H" #include "Time.H"
#include "patchZones.H" #include "patchZones.H"
#include "OStringStream.H" #include "OStringStream.H"
#include "collatedFileOperation.H"
// VTK includes // VTK includes
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
@ -170,6 +171,12 @@ Foam::vtkPVblockMesh::vtkPVblockMesh
<< FileName << endl; << 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 // avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path()); fileName fullCasePath(fileName(FileName).path());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -195,7 +195,7 @@ int main(int argc, char *argv[])
} }
if (!csDictIoPtr->headerOk()) if (!csDictIoPtr->typeHeaderOk<coordinateSystems>(false))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot open coordinateSystems file\n " << "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; 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; Info<< "runTime.instance() = " << runTime.instance() << endl;
@ -368,7 +370,7 @@ int main(int argc, char *argv[])
surfOut.write(); surfOut.write();
// write directly // write directly
surfOut.write("someName.ofs"); surfOut.surfMesh::write(fileName("someName.ofs"));
#if 1 #if 1
const surfZoneList& zones = surfOut.surfZones(); 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 FatalErrorInFunction
<< ioPtr->objectPath() << nl << ioPtr->objectPath() << nl

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,6 +38,8 @@ Description
#include "timer.H" #include "timer.H"
#include "IFstream.H" #include "IFstream.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "IOstreams.H"
#include "Pstream.H"
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
@ -294,6 +296,16 @@ bool Foam::chDir(const fileName& dir)
bool Foam::mkDir(const fileName& pathName, mode_t mode) 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 // empty names are meaningless
if (pathName.empty()) 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) 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; 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()) if (fileStatus.isValid())
{ {
return fileStatus.status().st_mode; 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)) if (S_ISREG(m))
{ {
return fileName::FILE; return fileName::FILE;
} }
else if (S_ISLNK(m))
{
return fileName::LINK;
}
else if (S_ISDIR(m)) else if (S_ISDIR(m))
{ {
return fileName::DIRECTORY; 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()) if (fileStatus.isValid())
{ {
return fileStatus.status().st_size; 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()) if (fileStatus.isValid())
{ {
return fileStatus.status().st_mtime; 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()) if (fileStatus.isValid())
{ {
return return
@ -543,7 +641,8 @@ Foam::fileNameList Foam::readDir
( (
const fileName& directory, const fileName& directory,
const fileName::Type type, const fileName::Type type,
const bool filtergz const bool filtergz,
const bool followLink
) )
{ {
// Initial filename list size // Initial filename list size
@ -552,8 +651,12 @@ Foam::fileNameList Foam::readDir
if (POSIX::debug) if (POSIX::debug)
{ {
InfoInFunction //InfoInFunction
<< "reading directory " << directory << endl; Pout<< FUNCTION_NAME << " : reading directory " << directory << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
} }
// Setup empty string list MAXTVALUES long // 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()) 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. // Make sure source exists.
if (!exists(src)) if (!exists(src))
{ {
return false; return false;
} }
const fileName::Type srcType = src.type(followLink);
fileName destFile(dest); fileName destFile(dest);
// Check type of source file. // 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 dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY) if (destFile.type() == fileName::DIRECTORY)
@ -684,7 +797,23 @@ bool Foam::cp(const fileName& src, const fileName& dest)
return false; 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 dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY) if (destFile.type() == fileName::DIRECTORY)
@ -699,7 +828,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// Copy files // Copy files
fileNameList contents = readDir(src, fileName::FILE, false); fileNameList contents = readDir(src, fileName::FILE, false, followLink);
forAll(contents, i) forAll(contents, i)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -710,11 +839,18 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// File to file. // File to file.
cp(src/contents[i], destFile/contents[i]); cp(src/contents[i], destFile/contents[i], followLink);
} }
// Copy sub directories. // Copy sub directories.
fileNameList subdirs = readDir(src, fileName::DIRECTORY); fileNameList subdirs = readDir
(
src,
fileName::DIRECTORY,
false,
followLink
);
forAll(subdirs, i) forAll(subdirs, i)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -725,7 +861,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// Dir to Dir. // 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) if (POSIX::debug)
{ {
InfoInFunction //InfoInFunction
<< "Create softlink from : " << src << " to " << dst Pout<< FUNCTION_NAME
<< endl; << " : Create softlink from : " << src << " to " << dst << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
} }
if (exists(dst)) 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) if (POSIX::debug)
{ {
InfoInFunction //InfoInFunction
<< "Move : " << src << " to " << dst << endl; Pout<< FUNCTION_NAME << " : Move : " << src << " to " << dst << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
} }
if if
( (
dst.type() == fileName::DIRECTORY dst.type() == fileName::DIRECTORY
&& src.type() != fileName::DIRECTORY && src.type(followLink) != fileName::DIRECTORY
) )
{ {
const fileName dstName(dst/src.name()); const fileName dstName(dst/src.name());
@ -799,8 +943,13 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
{ {
if (POSIX::debug) if (POSIX::debug)
{ {
InfoInFunction //InfoInFunction
<< "mvBak : " << src << " to extension " << ext << endl; Pout<< FUNCTION_NAME
<< " : moving : " << src << " to extension " << ext << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
} }
if (exists(src, false)) if (exists(src, false))
@ -836,8 +985,12 @@ bool Foam::rm(const fileName& file)
{ {
if (POSIX::debug) if (POSIX::debug)
{ {
InfoInFunction //InfoInFunction
<< "Removing : " << file << endl; 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 // Try returning plain file name; if not there, try with .gz
@ -856,8 +1009,12 @@ bool Foam::rmDir(const fileName& directory)
{ {
if (POSIX::debug) if (POSIX::debug)
{ {
InfoInFunction //InfoInFunction
<< "removing directory " << directory << endl; Pout<< FUNCTION_NAME << " : removing directory " << directory << endl;
if ((POSIX::debug & 2) && !Pstream::master())
{
error::printStack(Pout);
}
} }
// Pointers to the directory entries // Pointers to the directory entries
@ -883,7 +1040,7 @@ bool Foam::rmDir(const fileName& directory)
{ {
fileName path = directory/fName; fileName path = directory/fName;
if (path.type() == fileName::DIRECTORY) if (path.type(false) == fileName::DIRECTORY)
{ {
if (!rmDir(path)) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 // Work on volatile
volatile bool locIsValid = false; volatile bool locIsValid = false;
@ -47,13 +52,27 @@ Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
if (!timedOut(myTimer)) if (!timedOut(myTimer))
{ {
if (::stat(fName.c_str(), &status_) != 0) if (followLink)
{ {
locIsValid = false; if (::stat(fName.c_str(), &status_) != 0)
{
locIsValid = false;
}
else
{
locIsValid = true;
}
} }
else else
{ {
locIsValid = true; if (::lstat(fName.c_str(), &status_) != 0)
{
locIsValid = false;
}
else
{
locIsValid = true;
}
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -79,8 +79,15 @@ public:
//- Empty constructor //- Empty constructor
fileStat(); fileStat();
//- Construct from components //- Construct from components.
fileStat(const fileName& fName, const unsigned int maxTime=0); // 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 //- Construct from Istream
fileStat(Istream&); fileStat(Istream&);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -143,7 +143,7 @@ public:
//- Return the number of (groups) //- Return the number of (groups)
inline int ngroups() const 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/clock/clock.C
global/etcFiles/etcFiles.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 = primitives/bools
$(bools)/bool/bool.C $(bools)/bool/bool.C
$(bools)/bool/boolIO.C $(bools)/bool/boolIO.C
@ -161,6 +169,7 @@ $(gzstream)/gzstream.C
Fstreams = $(Streams)/Fstreams Fstreams = $(Streams)/Fstreams
$(Fstreams)/IFstream.C $(Fstreams)/IFstream.C
$(Fstreams)/OFstream.C $(Fstreams)/OFstream.C
$(Fstreams)/masterOFstream.C
Tstreams = $(Streams)/Tstreams Tstreams = $(Streams)/Tstreams
$(Tstreams)/ITstream.C $(Tstreams)/ITstream.C
@ -210,10 +219,16 @@ $(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C $(functionEntries)/removeEntry/removeEntry.C
IOdictionary = db/IOobjects/IOdictionary IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/baseIOdictionary.C
$(IOdictionary)/baseIOdictionaryIO.C
$(IOdictionary)/IOdictionary.C $(IOdictionary)/IOdictionary.C
$(IOdictionary)/IOdictionaryIO.C $(IOdictionary)/localIOdictionary.C
$(IOdictionary)/unwatchedIOdictionary.C
db/IOobjects/IOMap/IOMapName.C db/IOobjects/IOMap/IOMapName.C
db/IOobjects/decomposedBlockData/decomposedBlockData.C
db/IOobjects/GlobalIOField/GlobalIOFields.C
IOobject = db/IOobject IOobject = db/IOobject
$(IOobject)/IOobject.C $(IOobject)/IOobject.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,6 +32,71 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(IOobject, 0); 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), rOpt_(ro),
wOpt_(wo), wOpt_(wo),
registerObject_(registerObject), registerObject_(registerObject),
globalObject_(false),
objState_(GOOD) objState_(GOOD)
{ {
if (objectRegistry::debug) if (objectRegistry::debug)
@ -149,7 +215,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry, const objectRegistry& registry,
readOption ro, readOption ro,
writeOption wo, writeOption wo,
bool registerObject bool registerObject,
bool globalObject
) )
: :
name_(name), name_(name),
@ -161,6 +228,7 @@ Foam::IOobject::IOobject
rOpt_(ro), rOpt_(ro),
wOpt_(wo), wOpt_(wo),
registerObject_(registerObject), registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD) objState_(GOOD)
{ {
if (objectRegistry::debug) if (objectRegistry::debug)
@ -179,7 +247,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry, const objectRegistry& registry,
readOption ro, readOption ro,
writeOption wo, writeOption wo,
bool registerObject bool registerObject,
bool globalObject
) )
: :
name_(), name_(),
@ -191,6 +260,7 @@ Foam::IOobject::IOobject
rOpt_(ro), rOpt_(ro),
wOpt_(wo), wOpt_(wo),
registerObject_(registerObject), registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD) objState_(GOOD)
{ {
if (!fileNameComponents(path, instance_, local_, name_)) 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 * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOobject::~IOobject() 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()) // Do not check for undecomposed files
{ return fileHandler().filePath(false, *this, typeName);
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;
}
} }
Foam::Istream* Foam::IOobject::objectStream() Foam::fileName Foam::IOobject::globalFilePath(const word& typeName) const
{ {
return objectStream(filePath()); // Check for undecomposed files
} return fileHandler().filePath(true, *this, typeName);
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;
} }
@ -465,6 +448,7 @@ void Foam::IOobject::operator=(const IOobject& io)
local_ = io.local_; local_ = io.local_;
rOpt_ = io.rOpt_; rOpt_ = io.rOpt_;
wOpt_ = io.wOpt_; wOpt_ = io.wOpt_;
globalObject_ = io.globalObject_;
objState_ = io.objState_; objState_ = io.objState_;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -76,6 +76,7 @@ SourceFiles
#include "typeInfo.H" #include "typeInfo.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "InfoProxy.H" #include "InfoProxy.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,6 +120,16 @@ public:
NO_WRITE = 1 NO_WRITE = 1
}; };
//- Enumeration defining the file checking options
enum fileCheckTypes
{
timeStamp,
timeStampMaster,
inotify,
inotifyMaster
};
static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames;
private: private:
@ -151,6 +162,9 @@ private:
//- Register object created from this IOobject with registry if true //- Register object created from this IOobject with registry if true
bool registerObject_; bool registerObject_;
//- Is object same for all processors
bool globalObject_;
//- IOobject state //- IOobject state
objectState objState_; objectState objState_;
@ -159,14 +173,6 @@ protected:
// Protected Member Functions // 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 //- Set the object state to bad
void setBad(const string&); void setBad(const string&);
@ -199,6 +205,9 @@ public:
template<class Name> template<class Name>
static inline word groupName(Name name, const word& group); static inline word groupName(Name name, const word& group);
//- Type of file modification checking
static fileCheckTypes fileModificationChecking;
// Constructors // Constructors
@ -222,7 +231,8 @@ public:
const objectRegistry& registry, const objectRegistry& registry,
readOption r=NO_READ, readOption r=NO_READ,
writeOption w=NO_WRITE, writeOption w=NO_WRITE,
bool registerObject=true bool registerObject=true,
bool globalObject = false
); );
//- Construct from path, registry, io options //- Construct from path, registry, io options
@ -233,15 +243,36 @@ public:
const objectRegistry& registry, const objectRegistry& registry,
readOption r=NO_READ, readOption r=NO_READ,
writeOption w=NO_WRITE, 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 //- Clone
Foam::autoPtr<IOobject> clone() const autoPtr<IOobject> clone() const
{ {
return autoPtr<IOobject>(new IOobject(*this)); return autoPtr<IOobject>(new IOobject(*this));
} }
//- Clone resetting registry
autoPtr<IOobject> clone(const objectRegistry& registry) const
{
return autoPtr<IOobject>(new IOobject(*this, registry));
}
//- Destructor //- Destructor
virtual ~IOobject(); virtual ~IOobject();
@ -269,6 +300,12 @@ public:
return headerClassName_; return headerClassName_;
} }
//- Return name of the class name read from header
word& headerClassName()
{
return headerClassName_;
}
//- Return non-constant access to the optional note //- Return non-constant access to the optional note
string& note() string& note()
{ {
@ -299,6 +336,18 @@ public:
return registerObject_; 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 // Read/write options
@ -366,9 +415,11 @@ public:
return path()/name(); return path()/name();
} }
//- Return complete path + object name if the file exists //- Helper for filePath that searches locally.
// either in the case/processor or case otherwise null fileName localFilePath(const word& typeName) const;
fileName filePath() const;
//- Helper for filePath that searches up if in parallel
fileName globalFilePath(const word& typeName) const;
// Reading // Reading
@ -376,9 +427,14 @@ public:
//- Read header //- Read header
bool readHeader(Istream&); bool readHeader(Istream&);
//- Read and check header info //- Read header (uses typeFilePath to find file) and check header
bool headerOk(); // 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 // Writing
@ -435,6 +491,26 @@ template<>
Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip); 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 } // End namespace Foam
@ -445,6 +521,12 @@ Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IOobjectTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,6 +36,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<IOobject>& ip)
os << "IOobject: " os << "IOobject: "
<< io.type() << token::SPACE << io.type() << token::SPACE
<< io.name() << 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; << io.path() << endl;
return os; 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