mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
INT: Integration of Mattijs' collocated parallel IO additions
Original commit message:
------------------------
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:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -64,6 +64,7 @@ Description
|
||||
#include "globalIndex.H"
|
||||
#include "topoSet.H"
|
||||
#include "processorMeshes.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "polyMesh.H"
|
||||
#include "Ostream.H"
|
||||
#include "twoDPointCorrector.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -143,10 +144,8 @@ Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
|
||||
|
||||
const edgeList& edges = mesh_.edges();
|
||||
|
||||
forAll(edges, edgeI)
|
||||
forAll(const edge& e : edges)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
vector eVec(e.vec(mesh_.points()));
|
||||
|
||||
scalar eMag = mag(eVec);
|
||||
@ -209,13 +208,5 @@ Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -57,6 +57,7 @@ See also
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "STARCDMeshWriter.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -134,4 +135,5 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -47,7 +47,7 @@ Usage
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "MeshedSurfaces.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -387,7 +387,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
Triangulation::number_of_vertices()
|
||||
label(Triangulation::number_of_vertices())
|
||||
);
|
||||
|
||||
labelIOField processorIndices
|
||||
@ -401,7 +401,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
Triangulation::number_of_vertices()
|
||||
label(Triangulation::number_of_vertices())
|
||||
);
|
||||
|
||||
for
|
||||
|
||||
@ -531,6 +531,7 @@ void extractSurface
|
||||
? runTime.path()/".."/outFileName
|
||||
: runTime.path()/outFileName
|
||||
);
|
||||
globalCasePath.clean();
|
||||
|
||||
Info<< "Writing merged surface to " << globalCasePath << endl;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -67,6 +67,7 @@ Usage
|
||||
#include "globalMeshData.H"
|
||||
#include "surfaceWriter.H"
|
||||
#include "vtkSetWriter.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
#include "checkTools.H"
|
||||
#include "checkTopology.H"
|
||||
|
||||
@ -281,7 +281,7 @@ void Foam::mergeAndWrite
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
const fileName outputDir
|
||||
fileName outputDir
|
||||
(
|
||||
set.time().path()
|
||||
/ (Pstream::parRun() ? ".." : "")
|
||||
@ -289,6 +289,7 @@ void Foam::mergeAndWrite
|
||||
/ mesh.pointsInstance()
|
||||
/ set.name()
|
||||
);
|
||||
outputDir.clean();
|
||||
|
||||
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
|
||||
}
|
||||
@ -374,7 +375,7 @@ void Foam::mergeAndWrite
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
const fileName outputDir
|
||||
fileName outputDir
|
||||
(
|
||||
set.time().path()
|
||||
/ (Pstream::parRun() ? ".." : "")
|
||||
@ -382,6 +383,7 @@ void Foam::mergeAndWrite
|
||||
/ mesh.pointsInstance()
|
||||
/ set.name()
|
||||
);
|
||||
outputDir.clean();
|
||||
|
||||
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
|
||||
}
|
||||
@ -477,7 +479,7 @@ void Foam::mergeAndWrite
|
||||
|
||||
// Output e.g. pointSet p0 to
|
||||
// postProcessing/<time>/p0.vtk
|
||||
const fileName outputDir
|
||||
fileName outputDir
|
||||
(
|
||||
set.time().path()
|
||||
/ (Pstream::parRun() ? ".." : "")
|
||||
@ -485,6 +487,7 @@ void Foam::mergeAndWrite
|
||||
/ mesh.pointsInstance()
|
||||
// set.name()
|
||||
);
|
||||
outputDir.clean();
|
||||
mkDir(outputDir);
|
||||
|
||||
fileName outputFile(outputDir/writer.getFileName(points, wordList()));
|
||||
|
||||
@ -53,6 +53,7 @@ Description
|
||||
#include "polyModifyFace.H"
|
||||
#include "wordReList.H"
|
||||
#include "processorMeshes.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,6 +54,7 @@ Description
|
||||
#include "wedgePolyPatch.H"
|
||||
#include "plane.H"
|
||||
#include "SubField.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -52,6 +52,7 @@ Description
|
||||
#include "faceZoneSet.H"
|
||||
#include "pointZoneSet.H"
|
||||
#include "timeSelector.H"
|
||||
#include "collatedFileOperation.H"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -743,6 +744,11 @@ commandStatus parseAction(const word& actionName)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Specific to topoSet/setSet: quite often we want to block upon writing
|
||||
// a set so we can immediately re-read it. So avoid use of threading
|
||||
// for set writing.
|
||||
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
|
||||
|
||||
timeSelector::addOptions(true, false);
|
||||
#include "addRegionOption.H"
|
||||
argList::addBoolOption("noVTK", "do not write VTK files");
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -487,7 +487,8 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
runTime.writeFormat(),
|
||||
IOstream::currentVersion,
|
||||
runTime.writeCompression()
|
||||
runTime.writeCompression(),
|
||||
true
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -42,6 +42,8 @@ Description
|
||||
#include "cellZoneSet.H"
|
||||
#include "faceZoneSet.H"
|
||||
#include "pointZoneSet.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "collatedFileOperation.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -194,6 +196,11 @@ polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Specific to topoSet/setSet: quite often we want to block upon writing
|
||||
// a set so we can immediately re-read it. So avoid use of threading
|
||||
// for set writing.
|
||||
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
|
||||
|
||||
timeSelector::addOptions(true, false);
|
||||
#include "addDictOption.H"
|
||||
#include "addRegionOption.H"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,9 +62,19 @@ Usage
|
||||
#include "cellIOList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "IOPtrList.H"
|
||||
#include "cloud.H"
|
||||
#include "labelIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "sphericalTensorIOField.H"
|
||||
#include "symmTensorIOField.H"
|
||||
#include "tensorIOField.H"
|
||||
#include "labelFieldIOField.H"
|
||||
#include "vectorFieldIOField.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "fieldDictionary.H"
|
||||
|
||||
#include "writeMeshObject.H"
|
||||
#include "fieldDictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -143,7 +153,8 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
|
||||
(
|
||||
IOstream::ASCII,
|
||||
IOstream::currentVersion,
|
||||
runTime.writeCompression()
|
||||
runTime.writeCompression(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@ -151,6 +162,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[])
|
||||
@ -183,6 +263,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
#include "createTime.H"
|
||||
// Optional mesh (used to read Clouds)
|
||||
autoPtr<polyMesh> meshPtr;
|
||||
|
||||
const bool enableEntries = args.optionFound("enableFunctionEntries");
|
||||
if (enableEntries)
|
||||
@ -221,11 +303,24 @@ int main(int argc, char *argv[])
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
// Convert all the standard mesh files
|
||||
writeMeshObject<cellCompactIOList>("cells", meshDir, runTime);
|
||||
writeMeshObject<cellCompactIOList, cellIOList>
|
||||
(
|
||||
"cells",
|
||||
meshDir,
|
||||
runTime
|
||||
);
|
||||
writeMeshObject<labelIOList>("owner", meshDir, runTime);
|
||||
writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
|
||||
writeMeshObject<faceCompactIOList>("faces", meshDir, runTime);
|
||||
writeMeshObject<faceCompactIOList, faceIOList>
|
||||
(
|
||||
"faces",
|
||||
meshDir,
|
||||
runTime
|
||||
);
|
||||
writeMeshObject<pointIOField>("points", meshDir, runTime);
|
||||
// Write boundary in ascii. This is only needed for fileHandler to
|
||||
// kick in. Should not give problems since always writing ascii.
|
||||
writeZones("boundary", meshDir, runTime);
|
||||
writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
|
||||
writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
|
||||
writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
|
||||
@ -279,22 +374,196 @@ int main(int argc, char *argv[])
|
||||
|| headerClassName == pointSphericalTensorField::typeName
|
||||
|| headerClassName == pointSymmTensorField::typeName
|
||||
|| headerClassName == pointTensorField::typeName
|
||||
|
||||
|| headerClassName == volScalarField::Internal::typeName
|
||||
|| headerClassName == volVectorField::Internal::typeName
|
||||
|| headerClassName == volSphericalTensorField::Internal::typeName
|
||||
|| headerClassName == volSymmTensorField::Internal::typeName
|
||||
|| headerClassName == volTensorField::Internal::typeName
|
||||
)
|
||||
{
|
||||
Info<< " Reading " << headerClassName
|
||||
<< " : " << iter()->name() << endl;
|
||||
|
||||
fieldDictionary fDict
|
||||
(
|
||||
*iter(),
|
||||
headerClassName
|
||||
);
|
||||
fieldDictionary fDict(*iter(), headerClassName);
|
||||
|
||||
Info<< " Writing " << iter()->name() << endl;
|
||||
fDict.regIOobject::write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check for lagrangian
|
||||
stringList lagrangianDirs
|
||||
(
|
||||
1,
|
||||
fileHandler().filePath
|
||||
(
|
||||
runTime.timePath()
|
||||
/ regionPrefix
|
||||
/ cloud::prefix
|
||||
)
|
||||
);
|
||||
|
||||
combineReduce(lagrangianDirs, uniqueEqOp());
|
||||
|
||||
if (!lagrangianDirs.empty())
|
||||
{
|
||||
if (meshPtr.valid())
|
||||
{
|
||||
meshPtr().readUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " Create polyMesh for time = "
|
||||
<< runTime.timeName() << endl;
|
||||
|
||||
meshPtr.reset
|
||||
(
|
||||
new polyMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
polyMesh::defaultRegion,
|
||||
runTime.timeName(),
|
||||
runTime,
|
||||
Foam::IOobject::MUST_READ
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
stringList cloudDirs
|
||||
(
|
||||
fileHandler().readDir
|
||||
(
|
||||
lagrangianDirs[0],
|
||||
fileName::DIRECTORY
|
||||
)
|
||||
);
|
||||
|
||||
combineReduce(cloudDirs, uniqueEqOp());
|
||||
|
||||
forAll(cloudDirs, i)
|
||||
{
|
||||
fileName dir(cloud::prefix/cloudDirs[i]);
|
||||
|
||||
Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false);
|
||||
|
||||
parcels.writeObject
|
||||
(
|
||||
runTime.writeFormat(),
|
||||
IOstream::currentVersion,
|
||||
runTime.writeCompression(),
|
||||
parcels.size()
|
||||
);
|
||||
|
||||
|
||||
// Do local scan for valid cloud objects
|
||||
IOobjectList sprayObjs(runTime, runTime.timeName(), dir);
|
||||
|
||||
// Combine with all other cloud objects
|
||||
stringList sprayFields(sprayObjs.sortedToc());
|
||||
combineReduce(sprayFields, uniqueEqOp());
|
||||
|
||||
forAll(sprayFields, fieldi)
|
||||
{
|
||||
const word& name = sprayFields[fieldi];
|
||||
|
||||
// Note: try the various field types. Make sure to
|
||||
// exit once sucessful conversion to avoid re-read
|
||||
// converted file.
|
||||
|
||||
if
|
||||
(
|
||||
name == "positions"
|
||||
|| name == "origProcId"
|
||||
|| name == "origId"
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool writeOk = writeOptionalMeshObject<labelIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<scalarIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<vectorIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<sphericalTensorIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<symmTensorIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<tensorIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<labelFieldIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
if (writeOk) continue;
|
||||
|
||||
writeOk = writeOptionalMeshObject<vectorFieldIOField>
|
||||
(
|
||||
name,
|
||||
dir,
|
||||
runTime,
|
||||
parcels.size() > 0
|
||||
);
|
||||
|
||||
if (!writeOk)
|
||||
{
|
||||
Info<< " Failed converting " << name << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,7 +39,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
template<class Type, class CheckType = Type>
|
||||
inline bool writeMeshObject
|
||||
(
|
||||
const word& name,
|
||||
@ -61,7 +61,7 @@ inline bool writeMeshObject
|
||||
|
||||
bool writeOk = false;
|
||||
|
||||
if (io.typeHeaderOk<T>(false))
|
||||
if (io.typeHeaderOk<T>(true, true, false))
|
||||
{
|
||||
Info<< " Reading " << io.headerClassName()
|
||||
<< " : " << name << endl;
|
||||
@ -71,15 +71,15 @@ inline bool writeMeshObject
|
||||
word oldTypeName;
|
||||
if (disableHeaderChecking)
|
||||
{
|
||||
oldTypeName = T::typeName;
|
||||
const_cast<word&>(T::typeName) = word::null;
|
||||
oldTypeName = Type::typeName;
|
||||
const_cast<word&>(Type::typeName) = word::null;
|
||||
}
|
||||
|
||||
T meshObject(io);
|
||||
Type meshObject(io);
|
||||
|
||||
if (disableHeaderChecking)
|
||||
{
|
||||
const_cast<word&>(T::typeName) = oldTypeName;
|
||||
const_cast<word&>(Type::typeName) = oldTypeName;
|
||||
// Fake type back to what was in field
|
||||
const_cast<word&>(meshObject.type()) = io.headerClassName();
|
||||
}
|
||||
|
||||
@ -104,6 +104,7 @@ Usage
|
||||
#include "pointFieldDecomposer.H"
|
||||
#include "lagrangianFieldDecomposer.H"
|
||||
#include "decompositionModel.H"
|
||||
#include "collatedFileOperation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -157,13 +158,14 @@ void decomposeUniform
|
||||
// Any uniform data to copy/link?
|
||||
const fileName uniformDir(regionDir/"uniform");
|
||||
|
||||
if (isDir(runTime.timePath()/uniformDir))
|
||||
if (fileHandler().isDir(runTime.timePath()/uniformDir))
|
||||
{
|
||||
Info<< "Detected additional non-decomposed files in "
|
||||
<< runTime.timePath()/uniformDir
|
||||
<< endl;
|
||||
|
||||
const fileName timePath = processorDb.timePath();
|
||||
const fileName timePath =
|
||||
fileHandler().filePath(processorDb.timePath());
|
||||
|
||||
// If no fields have been decomposed the destination
|
||||
// directory will not have been created so make sure.
|
||||
@ -171,11 +173,14 @@ void decomposeUniform
|
||||
|
||||
if (copyUniform || mesh.distributed())
|
||||
{
|
||||
cp
|
||||
(
|
||||
runTime.timePath()/uniformDir,
|
||||
timePath/uniformDir
|
||||
);
|
||||
if (!fileHandler().exists(timePath/uniformDir))
|
||||
{
|
||||
fileHandler().cp
|
||||
(
|
||||
runTime.timePath()/uniformDir,
|
||||
timePath/uniformDir
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -189,11 +194,15 @@ void decomposeUniform
|
||||
|
||||
fileName currentDir(cwd());
|
||||
chDir(timePath);
|
||||
ln
|
||||
(
|
||||
parentPath/runTime.timeName()/uniformDir,
|
||||
uniformDir
|
||||
);
|
||||
|
||||
if (!fileHandler().exists(uniformDir))
|
||||
{
|
||||
fileHandler().ln
|
||||
(
|
||||
parentPath/runTime.timeName()/uniformDir,
|
||||
uniformDir
|
||||
);
|
||||
}
|
||||
chDir(currentDir);
|
||||
}
|
||||
}
|
||||
@ -329,24 +338,10 @@ int main(int argc, char *argv[])
|
||||
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
|
||||
|
||||
|
||||
// determine the existing processor count directly
|
||||
label nProcs = 0;
|
||||
while
|
||||
(
|
||||
isDir
|
||||
(
|
||||
runTime.path()
|
||||
/ (word("processor") + name(nProcs))
|
||||
/ runTime.constant()
|
||||
/ regionDir
|
||||
/ polyMesh::meshSubDir
|
||||
)
|
||||
)
|
||||
{
|
||||
++nProcs;
|
||||
}
|
||||
// Determine the existing processor count directly
|
||||
label nProcs = fileHandler().nProcs(runTime.path(), regionDir);
|
||||
|
||||
// get requested numberOfSubdomains. Note: have no mesh yet so
|
||||
// Get requested numberOfSubdomains. Note: have no mesh yet so
|
||||
// cannot use decompositionModel::New
|
||||
const label nDomains = readLabel
|
||||
(
|
||||
@ -402,6 +397,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "Removing " << nProcs
|
||||
<< " existing processor directories" << endl;
|
||||
|
||||
fileHandler().rmDir(runTime.path()/word("processors"));
|
||||
|
||||
// remove existing processor dirs
|
||||
// reverse order to avoid gaps if someone interrupts the process
|
||||
for (label proci = nProcs-1; proci >= 0; --proci)
|
||||
@ -411,7 +408,7 @@ int main(int argc, char *argv[])
|
||||
runTime.path()/(word("processor") + name(proci))
|
||||
);
|
||||
|
||||
rmDir(procDir);
|
||||
fileHandler().rmDir(procDir);
|
||||
}
|
||||
|
||||
procDirsProblem = false;
|
||||
@ -448,7 +445,11 @@ int main(int argc, char *argv[])
|
||||
// Decompose the mesh
|
||||
if (!decomposeFieldsOnly)
|
||||
{
|
||||
mesh.decomposeMesh();
|
||||
// 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.writeDecomposition(decomposeSets);
|
||||
|
||||
@ -505,12 +506,16 @@ int main(int argc, char *argv[])
|
||||
<< cellDist.name() << " for use in postprocessing."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fileOperations::collatedFileOperation::maxThreadFileBufferSize =
|
||||
bufSz;
|
||||
}
|
||||
|
||||
|
||||
if (copyZero)
|
||||
{
|
||||
// Link the 0 directory into each of the processor directories
|
||||
// Copy the 0 directory into each of the processor directories
|
||||
fileName prevTimePath;
|
||||
for (label proci = 0; proci < mesh.nProcs(); proci++)
|
||||
{
|
||||
Time processorDb
|
||||
@ -521,14 +526,32 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
processorDb.setTime(runTime);
|
||||
|
||||
if (isDir(runTime.timePath()))
|
||||
if (fileHandler().isDir(runTime.timePath()))
|
||||
{
|
||||
const fileName timePath = processorDb.timePath();
|
||||
// Get corresponding directory name (to handle processors/)
|
||||
const fileName timePath
|
||||
(
|
||||
fileHandler().objectPath
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"",
|
||||
processorDb.timeName(),
|
||||
processorDb
|
||||
),
|
||||
word::null
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Processor " << proci
|
||||
<< ": linking " << runTime.timePath() << nl
|
||||
<< " to " << processorDb.timePath() << endl;
|
||||
cp(runTime.timePath(), processorDb.timePath());
|
||||
if (timePath != prevTimePath)
|
||||
{
|
||||
Info<< "Processor " << proci
|
||||
<< ": copying " << runTime.timePath() << nl
|
||||
<< " to " << timePath << endl;
|
||||
fileHandler().cp(runTime.timePath(), timePath);
|
||||
|
||||
prevTimePath = timePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -629,9 +652,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
fileNameList cloudDirs
|
||||
(
|
||||
readDir
|
||||
fileHandler().readDir
|
||||
(
|
||||
runTime.timePath()/cloud::prefix, fileName::DIRECTORY
|
||||
runTime.timePath()/cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -317,9 +317,6 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
||||
time().caseName()/fileName(word("processor") + Foam::name(proci))
|
||||
);
|
||||
|
||||
// make the processor directory
|
||||
mkDir(time().rootPath()/processorCasePath);
|
||||
|
||||
// create a database
|
||||
Time processorDb
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -188,11 +188,12 @@ void Foam::lagrangianFieldDecomposer::decomposeFields
|
||||
const PtrList<GeoField>& fields
|
||||
) const
|
||||
{
|
||||
if (particleIndices_.size())
|
||||
//if (particleIndices_.size())
|
||||
{
|
||||
bool valid = particleIndices_.size() > 0;
|
||||
forAll(fields, fieldi)
|
||||
{
|
||||
decomposeField(cloudName, fields[fieldi])().write();
|
||||
decomposeField(cloudName, fields[fieldi])().write(valid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,11 +206,12 @@ void Foam::lagrangianFieldDecomposer::decomposeFieldFields
|
||||
const PtrList<GeoField>& fields
|
||||
) const
|
||||
{
|
||||
if (particleIndices_.size())
|
||||
//if (particleIndices_.size())
|
||||
{
|
||||
bool valid = particleIndices_.size() > 0;
|
||||
forAll(fields, fieldi)
|
||||
{
|
||||
decomposeFieldField(cloudName, fields[fieldi])().write();
|
||||
decomposeFieldField(cloudName, fields[fieldi])().write(valid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -177,12 +177,43 @@ int main(int argc, char *argv[])
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
|
||||
|
||||
// determine the processor count directly
|
||||
label nProcs = 0;
|
||||
while (isDir(args.path()/(word("processor") + name(nProcs))))
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
if (allRegions)
|
||||
{
|
||||
++nProcs;
|
||||
Info<< "Reconstructing for all regions in regionProperties" << nl
|
||||
<< endl;
|
||||
regionProperties rp(runTime);
|
||||
forAllConstIter(HashTable<wordList>, rp, iter)
|
||||
{
|
||||
const wordList& regions = iter();
|
||||
forAll(regions, i)
|
||||
{
|
||||
if (findIndex(regionNames, regions[i]) == -1)
|
||||
{
|
||||
regionNames.append(regions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames = wordList(1, fvMesh::defaultRegion);
|
||||
regionDirs = wordList(1, word::null);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the processor count
|
||||
label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]);
|
||||
|
||||
if (!nProcs)
|
||||
{
|
||||
@ -225,9 +256,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (timeDirs.empty())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No times selected"
|
||||
<< exit(FatalError);
|
||||
WarningInFunction << "No times selected";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -251,42 +281,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
if (allRegions)
|
||||
{
|
||||
Info<< "Reconstructing for all regions in regionProperties" << nl
|
||||
<< endl;
|
||||
regionProperties rp(runTime);
|
||||
forAllConstIter(HashTable<wordList>, rp, iter)
|
||||
{
|
||||
const wordList& regions = iter();
|
||||
forAll(regions, i)
|
||||
{
|
||||
if (findIndex(regionNames, regions[i]) == -1)
|
||||
{
|
||||
regionNames.append(regions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames = wordList(1, fvMesh::defaultRegion);
|
||||
regionDirs = wordList(1, word::null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
@ -553,17 +547,26 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAll(databases, proci)
|
||||
{
|
||||
fileNameList cloudDirs
|
||||
fileName lagrangianDir
|
||||
(
|
||||
readDir
|
||||
fileHandler().filePath
|
||||
(
|
||||
databases[proci].timePath()
|
||||
/ regionDir
|
||||
/ cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
/ cloud::prefix
|
||||
)
|
||||
);
|
||||
|
||||
fileNameList cloudDirs;
|
||||
if (!lagrangianDir.empty())
|
||||
{
|
||||
cloudDirs = fileHandler().readDir
|
||||
(
|
||||
lagrangianDir,
|
||||
fileName::DIRECTORY
|
||||
);
|
||||
}
|
||||
|
||||
forAll(cloudDirs, i)
|
||||
{
|
||||
// Check if we already have cloud objects for this
|
||||
@ -1067,12 +1070,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fileName uniformDir0
|
||||
(
|
||||
databases[0].timePath()/regionDir/"uniform"
|
||||
fileHandler().filePath
|
||||
(
|
||||
databases[0].timePath()/regionDir/"uniform"
|
||||
)
|
||||
);
|
||||
|
||||
if (isDir(uniformDir0))
|
||||
if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
|
||||
{
|
||||
cp(uniformDir0, runTime.timePath()/regionDir);
|
||||
fileHandler().cp(uniformDir0, runTime.timePath()/regionDir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1082,12 +1088,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fileName uniformDir0
|
||||
(
|
||||
databases[0].timePath()/"uniform"
|
||||
fileHandler().filePath
|
||||
(
|
||||
databases[0].timePath()/"uniform"
|
||||
)
|
||||
);
|
||||
|
||||
if (isDir(uniformDir0))
|
||||
if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
|
||||
{
|
||||
cp(uniformDir0, runTime.timePath());
|
||||
fileHandler().cp(uniformDir0, runTime.timePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,20 +549,7 @@ int main(int argc, char *argv[])
|
||||
bool writeCellDist = args.optionFound("cellDist");
|
||||
|
||||
|
||||
int nProcs = 0;
|
||||
|
||||
while
|
||||
(
|
||||
isDir
|
||||
(
|
||||
args.rootPath()
|
||||
/ args.caseName()
|
||||
/ fileName(word("processor") + name(nProcs))
|
||||
)
|
||||
)
|
||||
{
|
||||
nProcs++;
|
||||
}
|
||||
label nProcs = fileHandler().nProcs(args.path());
|
||||
|
||||
Info<< "Found " << nProcs << " processor directories" << nl << endl;
|
||||
|
||||
@ -610,13 +597,21 @@ int main(int argc, char *argv[])
|
||||
databases[proci].setTime(timeDirs[timeI], timeI);
|
||||
}
|
||||
|
||||
const fileName meshPath =
|
||||
databases[0].path()
|
||||
/databases[0].timeName()
|
||||
/regionDir
|
||||
/polyMesh::meshSubDir;
|
||||
IOobject facesIO
|
||||
(
|
||||
"faces",
|
||||
databases[0].timeName(),
|
||||
regionDir/polyMesh::meshSubDir,
|
||||
databases[0],
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (!isFile(meshPath/"faces"))
|
||||
|
||||
// Problem: faceCompactIOList recognises both 'faceList' and
|
||||
// 'faceCompactList' so we should be lenient when doing
|
||||
// typeHeaderOk
|
||||
if (!facesIO.typeHeaderOk<faceCompactIOList>(false))
|
||||
{
|
||||
Info<< "No mesh." << nl << endl;
|
||||
continue;
|
||||
|
||||
@ -145,13 +145,14 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
// ~~~~~~~~~~~~
|
||||
|
||||
// Check who has a mesh
|
||||
//const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir);
|
||||
const bool haveMesh = isFile
|
||||
const bool haveMesh = fileHandler().isFile
|
||||
(
|
||||
io.time().path()/io.instance()/meshSubDir/"faces"
|
||||
fileHandler().filePath
|
||||
(
|
||||
io.time().path()/io.instance()/meshSubDir/"faces"
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
bool oldParRun = Pstream::parRun();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// check for "points" in any of the result directories
|
||||
// Check for "points" in any of the result directories
|
||||
|
||||
bool meshMoving = false;
|
||||
|
||||
|
||||
@ -40,4 +40,4 @@
|
||||
|
||||
Info<< nl << "Time [" << timeIndex << "] = " << runTime.timeName() << nl;
|
||||
|
||||
// end-of-file
|
||||
// end-of-file
|
||||
|
||||
@ -64,7 +64,8 @@ Usage
|
||||
// Surface writer
|
||||
writer ensight;
|
||||
|
||||
// Collate times for ensight output - ensures geometry is only written once
|
||||
// Collate times for ensight output
|
||||
// - ensures geometry is only written once
|
||||
writeOptions
|
||||
{
|
||||
ensight
|
||||
|
||||
@ -443,255 +443,274 @@ int main(int argc, char *argv[])
|
||||
FatalErrorInFunction
|
||||
<< "No times selected." << exit(FatalError);
|
||||
}
|
||||
runTime.setTime(times[0], 0);
|
||||
word instance = args.optionLookupOrDefault("instance", runTime.timeName());
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
const bool literalRE = args.optionFound("literalRE");
|
||||
if (literalRE)
|
||||
forAll(times, timei)
|
||||
{
|
||||
Info<< "Not interpreting any regular expressions (RE)"
|
||||
<< " in the changeDictionaryDict." << endl
|
||||
<< "Instead they are handled as any other entry, i.e. added if"
|
||||
<< " not present." << endl;
|
||||
}
|
||||
|
||||
const bool enableEntries = args.optionFound("enableFunctionEntries");
|
||||
if (enableEntries)
|
||||
{
|
||||
Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const int oldFlag = entry::disableFunctionEntries;
|
||||
if (!enableEntries)
|
||||
{
|
||||
// By default disable dictionary expansion for fields
|
||||
entry::disableFunctionEntries = 1;
|
||||
}
|
||||
|
||||
|
||||
const bool disablePatchGroups = args.optionFound("disablePatchGroups");
|
||||
if (disablePatchGroups)
|
||||
{
|
||||
Info<< "Not interpreting any keys in the changeDictionary"
|
||||
<< " as patchGroups"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
fileName regionPrefix = "";
|
||||
if (regionName != fvMesh::defaultRegion)
|
||||
{
|
||||
regionPrefix = regionName;
|
||||
}
|
||||
|
||||
|
||||
// Make sure we do not use the master-only reading since we read
|
||||
// fields (different per processor) as dictionaries.
|
||||
regIOobject::fileModificationChecking = regIOobject::timeStamp;
|
||||
|
||||
|
||||
// Get the replacement rules from a dictionary
|
||||
|
||||
const word dictName("changeDictionaryDict");
|
||||
#include "setSystemMeshDictionaryIO.H"
|
||||
IOdictionary dict(dictIO);
|
||||
|
||||
const dictionary* replaceDictsPtr = &dict;
|
||||
|
||||
if (args.optionFound("subDict"))
|
||||
{
|
||||
word subDictName(args.optionLookup("subDict")());
|
||||
replaceDictsPtr = &dict.subDict(subDictName);
|
||||
}
|
||||
|
||||
const dictionary& replaceDicts = *replaceDictsPtr;
|
||||
|
||||
Info<< "Read dictionary " << dict.name()
|
||||
<< " with replacements for dictionaries "
|
||||
<< replaceDicts.toc() << endl;
|
||||
|
||||
|
||||
|
||||
// Always read boundary to get patch groups
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Info<< "Reading polyMesh/boundary file to extract patch names"
|
||||
<< endl;
|
||||
|
||||
// Read PtrList of dictionary as dictionary.
|
||||
const word oldTypeName = IOPtrList<entry>::typeName;
|
||||
const_cast<word&>(IOPtrList<entry>::typeName) = word::null;
|
||||
IOPtrList<entry> dictList
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"boundary",
|
||||
runTime.findInstance
|
||||
(
|
||||
regionPrefix/polyMesh::meshSubDir,
|
||||
"boundary",
|
||||
IOobject::READ_IF_PRESENT
|
||||
),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
|
||||
|
||||
// Fake type back to what was in field
|
||||
const_cast<word&>(dictList.type()) = dictList.headerClassName();
|
||||
|
||||
// Temporary convert to dictionary
|
||||
dictionary fieldDict;
|
||||
forAll(dictList, i)
|
||||
{
|
||||
fieldDict.add(dictList[i].keyword(), dictList[i].dict());
|
||||
}
|
||||
|
||||
if (dictList.size())
|
||||
{
|
||||
Info<< "Loaded dictionary " << dictList.name()
|
||||
<< " with entries " << fieldDict.toc() << endl;
|
||||
}
|
||||
|
||||
// Extract any patchGroups information (= shortcut for set of
|
||||
// patches)
|
||||
HashTable<wordList, word> patchGroups;
|
||||
if (!disablePatchGroups)
|
||||
{
|
||||
patchGroups = extractPatchGroups(fieldDict);
|
||||
if (patchGroups.size())
|
||||
word instance;
|
||||
if (args.optionFound("instance"))
|
||||
{
|
||||
Info<< "Extracted patch groups:" << endl;
|
||||
wordList groups(patchGroups.sortedToc());
|
||||
forAll(groups, i)
|
||||
if (times.size() > 1)
|
||||
{
|
||||
Info<< " group " << groups[i] << " with patches "
|
||||
<< patchGroups[groups[i]] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Every replacement is a dictionary name and a keyword in this
|
||||
|
||||
forAllConstIter(dictionary, replaceDicts, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter().keyword();
|
||||
Info<< "Replacing entries in dictionary " << fieldName << endl;
|
||||
|
||||
// Handle 'boundary' specially:
|
||||
// - is PtrList of dictionaries
|
||||
// - is in polyMesh/
|
||||
if (fieldName == "boundary")
|
||||
{
|
||||
Info<< "Special handling of " << fieldName
|
||||
<< " as polyMesh/boundary file." << endl;
|
||||
|
||||
// Get the replacement dictionary for the field
|
||||
const dictionary& replaceDict = fieldIter().dict();
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
|
||||
// Merge the replacements in. Do not add non-existing entries.
|
||||
merge(false, fieldDict, replaceDict, literalRE, patchGroups);
|
||||
|
||||
Info<< "fieldDict:" << fieldDict << endl;
|
||||
|
||||
// Convert back into dictList
|
||||
wordList doneKeys(dictList.size());
|
||||
|
||||
label nEntries = fieldDict.size();
|
||||
|
||||
forAll(dictList, i)
|
||||
{
|
||||
doneKeys[i] = dictList[i].keyword();
|
||||
dictList.set
|
||||
(
|
||||
i,
|
||||
fieldDict.lookupEntry
|
||||
(
|
||||
doneKeys[i],
|
||||
false,
|
||||
true
|
||||
).clone()
|
||||
);
|
||||
fieldDict.remove(doneKeys[i]);
|
||||
FatalErrorInFunction
|
||||
<< "Multiple times selected with 'instance' option"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Add remaining entries
|
||||
label sz = dictList.size();
|
||||
dictList.setSize(nEntries);
|
||||
forAllConstIter(dictionary, fieldDict, iter)
|
||||
{
|
||||
dictList.set(sz++, iter().clone());
|
||||
}
|
||||
|
||||
Info<< "Writing modified " << fieldName << endl;
|
||||
dictList.writeObject
|
||||
(
|
||||
runTime.writeFormat(),
|
||||
runTime.writeFormat(),
|
||||
IOstream::UNCOMPRESSED
|
||||
);
|
||||
args.optionLookup("instance")() >> instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read dictionary
|
||||
// Note: disable class type checking so we can load field
|
||||
Info<< "Loading dictionary " << fieldName << endl;
|
||||
const word oldTypeName = IOdictionary::typeName;
|
||||
const_cast<word&>(IOdictionary::typeName) = word::null;
|
||||
runTime.setTime(times[timei], timei);
|
||||
instance = runTime.timeName();
|
||||
}
|
||||
|
||||
IOobject fieldHeader
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
const bool literalRE = args.optionFound("literalRE");
|
||||
if (literalRE)
|
||||
{
|
||||
Info<< "Not interpreting any regular expressions (RE)"
|
||||
<< " in the changeDictionaryDict." << endl
|
||||
<< "Instead they are handled as any other entry, i.e. added if"
|
||||
<< " not present." << endl;
|
||||
}
|
||||
|
||||
const bool enableEntries = args.optionFound("enableFunctionEntries");
|
||||
if (enableEntries)
|
||||
{
|
||||
Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const int oldFlag = entry::disableFunctionEntries;
|
||||
if (!enableEntries)
|
||||
{
|
||||
// By default disable dictionary expansion for fields
|
||||
entry::disableFunctionEntries = 1;
|
||||
}
|
||||
|
||||
|
||||
const bool disablePatchGroups = args.optionFound("disablePatchGroups");
|
||||
if (disablePatchGroups)
|
||||
{
|
||||
Info<< "Not interpreting any keys in the changeDictionary"
|
||||
<< " as patchGroups"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
fileName regionPrefix = "";
|
||||
if (regionName != fvMesh::defaultRegion)
|
||||
{
|
||||
regionPrefix = regionName;
|
||||
}
|
||||
|
||||
|
||||
// Make sure we do not use the master-only reading since we read
|
||||
// fields (different per processor) as dictionaries.
|
||||
regIOobject::fileModificationChecking = regIOobject::timeStamp;
|
||||
|
||||
|
||||
// Get the replacement rules from a dictionary
|
||||
|
||||
const word dictName("changeDictionaryDict");
|
||||
#include "setSystemMeshDictionaryIO.H"
|
||||
IOdictionary dict(dictIO);
|
||||
|
||||
const dictionary* replaceDictsPtr = &dict;
|
||||
|
||||
if (args.optionFound("subDict"))
|
||||
{
|
||||
word subDictName(args.optionLookup("subDict")());
|
||||
replaceDictsPtr = &dict.subDict(subDictName);
|
||||
}
|
||||
|
||||
const dictionary& replaceDicts = *replaceDictsPtr;
|
||||
|
||||
Info<< "Read dictionary " << dict.name()
|
||||
<< " with replacements for dictionaries "
|
||||
<< replaceDicts.toc() << endl;
|
||||
|
||||
|
||||
|
||||
// Always read boundary to get patch groups
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Info<< "Reading polyMesh/boundary file to extract patch names"
|
||||
<< endl;
|
||||
|
||||
// Read PtrList of dictionary as dictionary.
|
||||
const word oldTypeName = IOPtrList<entry>::typeName;
|
||||
const_cast<word&>(IOPtrList<entry>::typeName) = word::null;
|
||||
IOPtrList<entry> dictList
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
instance,
|
||||
"boundary",
|
||||
runTime.findInstance
|
||||
(
|
||||
regionPrefix/polyMesh::meshSubDir,
|
||||
"boundary",
|
||||
IOobject::READ_IF_PRESENT
|
||||
),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
)
|
||||
);
|
||||
const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
|
||||
|
||||
if (fieldHeader.typeHeaderOk<IOdictionary>(false))
|
||||
// Fake type back to what was in field
|
||||
const_cast<word&>(dictList.type()) = dictList.headerClassName();
|
||||
|
||||
// Temporary convert to dictionary
|
||||
dictionary fieldDict;
|
||||
forAll(dictList, i)
|
||||
{
|
||||
fieldDict.add(dictList[i].keyword(), dictList[i].dict());
|
||||
}
|
||||
|
||||
if (dictList.size())
|
||||
{
|
||||
Info<< "Loaded dictionary " << dictList.name()
|
||||
<< " with entries " << fieldDict.toc() << endl;
|
||||
}
|
||||
|
||||
// Extract any patchGroups information (= shortcut for set of
|
||||
// patches)
|
||||
HashTable<wordList, word> patchGroups;
|
||||
if (!disablePatchGroups)
|
||||
{
|
||||
patchGroups = extractPatchGroups(fieldDict);
|
||||
if (patchGroups.size())
|
||||
{
|
||||
IOdictionary fieldDict(fieldHeader);
|
||||
Info<< "Extracted patch groups:" << endl;
|
||||
wordList groups(patchGroups.sortedToc());
|
||||
forAll(groups, i)
|
||||
{
|
||||
Info<< " group " << groups[i] << " with patches "
|
||||
<< patchGroups[groups[i]] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
|
||||
|
||||
// Fake type back to what was in field
|
||||
const_cast<word&>(fieldDict.type()) =
|
||||
fieldDict.headerClassName();
|
||||
// Every replacement is a dictionary name and a keyword in this
|
||||
|
||||
Info<< "Loaded dictionary " << fieldName
|
||||
<< " with entries " << fieldDict.toc() << endl;
|
||||
forAllConstIter(dictionary, replaceDicts, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter().keyword();
|
||||
Info<< "Replacing entries in dictionary " << fieldName << endl;
|
||||
|
||||
// Handle 'boundary' specially:
|
||||
// - is PtrList of dictionaries
|
||||
// - is in polyMesh/
|
||||
if (fieldName == "boundary")
|
||||
{
|
||||
Info<< "Special handling of " << fieldName
|
||||
<< " as polyMesh/boundary file." << endl;
|
||||
|
||||
// Get the replacement dictionary for the field
|
||||
const dictionary& replaceDict = fieldIter().dict();
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
|
||||
// Merge the replacements in (allow adding)
|
||||
merge(true, fieldDict, replaceDict, literalRE, patchGroups);
|
||||
// Merge the replacements in. Do not add non-existing entries.
|
||||
merge(false, fieldDict, replaceDict, literalRE, patchGroups);
|
||||
|
||||
Info<< "Writing modified fieldDict " << fieldName << endl;
|
||||
fieldDict.regIOobject::write();
|
||||
Info<< "fieldDict:" << fieldDict << endl;
|
||||
|
||||
// Convert back into dictList
|
||||
wordList doneKeys(dictList.size());
|
||||
|
||||
label nEntries = fieldDict.size();
|
||||
|
||||
forAll(dictList, i)
|
||||
{
|
||||
doneKeys[i] = dictList[i].keyword();
|
||||
dictList.set
|
||||
(
|
||||
i,
|
||||
fieldDict.lookupEntry
|
||||
(
|
||||
doneKeys[i],
|
||||
false,
|
||||
true
|
||||
).clone()
|
||||
);
|
||||
fieldDict.remove(doneKeys[i]);
|
||||
}
|
||||
|
||||
// Add remaining entries
|
||||
label sz = dictList.size();
|
||||
dictList.setSize(nEntries);
|
||||
forAllConstIter(dictionary, fieldDict, iter)
|
||||
{
|
||||
dictList.set(sz++, iter().clone());
|
||||
}
|
||||
|
||||
Info<< "Writing modified " << fieldName << endl;
|
||||
dictList.writeObject
|
||||
(
|
||||
runTime.writeFormat(),
|
||||
runTime.writeFormat(),
|
||||
IOstream::UNCOMPRESSED,
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested field to change " << fieldName
|
||||
<< " does not exist in " << fieldHeader.path() << endl;
|
||||
// Read dictionary
|
||||
// Note: disable class type checking so we can load field
|
||||
Info<< "Loading dictionary " << fieldName << endl;
|
||||
const word oldTypeName = IOdictionary::typeName;
|
||||
const_cast<word&>(IOdictionary::typeName) = word::null;
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
instance,
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (fieldHeader.typeHeaderOk<IOdictionary>(false))
|
||||
{
|
||||
IOdictionary fieldDict(fieldHeader);
|
||||
|
||||
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
|
||||
|
||||
// Fake type back to what was in field
|
||||
const_cast<word&>(fieldDict.type()) =
|
||||
fieldDict.headerClassName();
|
||||
|
||||
Info<< "Loaded dictionary " << fieldName
|
||||
<< " with entries " << fieldDict.toc() << endl;
|
||||
|
||||
// Get the replacement dictionary for the field
|
||||
const dictionary& replaceDict = fieldIter().dict();
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
|
||||
// Merge the replacements in (allow adding)
|
||||
merge(true, fieldDict, replaceDict, literalRE, patchGroups);
|
||||
|
||||
Info<< "Writing modified fieldDict " << fieldName << endl;
|
||||
fieldDict.regIOobject::write();
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested field to change " << fieldName
|
||||
<< " does not exist in " << fieldHeader.path() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
entry::disableFunctionEntries = oldFlag;
|
||||
}
|
||||
}
|
||||
|
||||
entry::disableFunctionEntries = oldFlag;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -49,9 +49,7 @@ void MapConsistentVolFields
|
||||
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
|
||||
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
||||
|
||||
word fieldClassName(fieldType::typeName);
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -49,9 +49,7 @@ void MapVolFields
|
||||
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
|
||||
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
||||
|
||||
word fieldClassName(fieldType::typeName);
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
@ -66,15 +64,10 @@ void MapVolFields
|
||||
|
||||
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
|
||||
{
|
||||
Info<< " interpolating " << fieldIter()->name()
|
||||
<< endl;
|
||||
Info<< " interpolating " << fieldIter()->name() << endl;
|
||||
|
||||
// Read field fieldSource
|
||||
fieldType fieldSource
|
||||
(
|
||||
*fieldIter(),
|
||||
meshSource
|
||||
);
|
||||
fieldType fieldSource(*fieldIter(), meshSource);
|
||||
|
||||
// Read fieldTarget
|
||||
fieldType fieldTarget
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -44,6 +44,7 @@ Usage
|
||||
#include "PackedBoolList.H"
|
||||
#include "unitConversion.H"
|
||||
#include "searchableSurfaces.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -431,6 +431,7 @@ int main(int argc, char *argv[])
|
||||
sortedFace.write(globalCasePath);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -46,6 +46,7 @@ Description
|
||||
#include "absoluteEnthalpy.H"
|
||||
|
||||
#include "SLPtrList.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user