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.
320 lines
8.5 KiB
C
320 lines
8.5 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
|
-------------------------------------------------------------------------------
|
|
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
|
|
checkMesh
|
|
|
|
Group
|
|
grpMeshManipulationUtilities
|
|
|
|
Description
|
|
Checks validity of a mesh.
|
|
|
|
Usage
|
|
\b checkMesh [OPTION]
|
|
|
|
Options:
|
|
- \par -allGeometry
|
|
Checks all (including non finite-volume specific) geometry
|
|
|
|
- \par -allTopology
|
|
Checks all (including non finite-volume specific) addressing
|
|
|
|
- \par -meshQuality
|
|
Checks against user defined (in \a system/meshQualityDict) quality
|
|
settings
|
|
|
|
- \par -region \<name\>
|
|
Specify an alternative mesh region.
|
|
|
|
\param -writeSets \<surfaceFormat\> \n
|
|
Reconstruct all cellSets and faceSets geometry and write to postProcessing
|
|
directory according to surfaceFormat (e.g. vtk or ensight). Additionally
|
|
reconstructs all pointSets and writes as vtk format.
|
|
|
|
\param -writeAllFields \n
|
|
Writes all mesh quality measures as fields.
|
|
|
|
\param -writeFields '(\<fieldName\>)' \n
|
|
Writes selected mesh quality measures as fields.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "argList.H"
|
|
#include "timeSelector.H"
|
|
#include "Time.H"
|
|
#include "fvMesh.H"
|
|
#include "globalMeshData.H"
|
|
#include "surfaceWriter.H"
|
|
#include "vtkSetWriter.H"
|
|
#include "IOdictionary.H"
|
|
|
|
#include "checkTools.H"
|
|
#include "checkTopology.H"
|
|
#include "checkGeometry.H"
|
|
#include "checkMeshQuality.H"
|
|
#include "writeFields.H"
|
|
|
|
using namespace Foam;
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
timeSelector::addOptions();
|
|
#include "addRegionOption.H"
|
|
argList::addBoolOption
|
|
(
|
|
"noTopology",
|
|
"skip checking the mesh topology"
|
|
);
|
|
argList::addBoolOption
|
|
(
|
|
"allGeometry",
|
|
"include bounding box checks"
|
|
);
|
|
argList::addBoolOption
|
|
(
|
|
"allTopology",
|
|
"include extra topology checks"
|
|
);
|
|
argList::addBoolOption
|
|
(
|
|
"writeAllFields",
|
|
"write volFields with mesh quality parameters"
|
|
);
|
|
argList::addOption
|
|
(
|
|
"writeFields",
|
|
"wordList",
|
|
"write volFields with selected mesh quality parameters"
|
|
);
|
|
argList::addBoolOption
|
|
(
|
|
"meshQuality",
|
|
"read user-defined mesh quality criterions from system/meshQualityDict"
|
|
);
|
|
argList::addOption
|
|
(
|
|
"writeSets",
|
|
"surfaceFormat",
|
|
"reconstruct and write all faceSets and cellSets in selected format"
|
|
);
|
|
|
|
#include "setRootCase.H"
|
|
#include "createTime.H"
|
|
instantList timeDirs = timeSelector::select0(runTime, args);
|
|
#include "createNamedMesh.H"
|
|
|
|
const bool noTopology = args.optionFound("noTopology");
|
|
const bool allGeometry = args.optionFound("allGeometry");
|
|
const bool allTopology = args.optionFound("allTopology");
|
|
const bool meshQuality = args.optionFound("meshQuality");
|
|
|
|
word surfaceFormat;
|
|
const bool writeSets = args.optionReadIfPresent("writeSets", surfaceFormat);
|
|
HashSet<word> selectedFields;
|
|
bool writeFields = args.optionReadIfPresent
|
|
(
|
|
"writeFields",
|
|
selectedFields
|
|
);
|
|
if (!writeFields && args.optionFound("writeAllFields"))
|
|
{
|
|
selectedFields.insert("nonOrthoAngle");
|
|
selectedFields.insert("faceWeight");
|
|
selectedFields.insert("skewness");
|
|
selectedFields.insert("cellDeterminant");
|
|
selectedFields.insert("aspectRatio");
|
|
selectedFields.insert("cellShapes");
|
|
selectedFields.insert("cellVolume");
|
|
selectedFields.insert("cellVolumeRatio");
|
|
}
|
|
|
|
|
|
if (noTopology)
|
|
{
|
|
Info<< "Disabling all topology checks." << nl << endl;
|
|
}
|
|
if (allTopology)
|
|
{
|
|
Info<< "Enabling all (cell, face, edge, point) topology checks."
|
|
<< nl << endl;
|
|
}
|
|
if (allGeometry)
|
|
{
|
|
Info<< "Enabling all geometry checks." << nl << endl;
|
|
}
|
|
if (meshQuality)
|
|
{
|
|
Info<< "Enabling user-defined geometry checks." << nl << endl;
|
|
}
|
|
if (writeSets)
|
|
{
|
|
Info<< "Reconstructing and writing " << surfaceFormat
|
|
<< " representation"
|
|
<< " of all faceSets and cellSets." << nl << endl;
|
|
}
|
|
if (selectedFields.size())
|
|
{
|
|
Info<< "Writing mesh quality as fields " << selectedFields << nl
|
|
<< endl;
|
|
}
|
|
|
|
|
|
autoPtr<IOdictionary> qualDict;
|
|
if (meshQuality)
|
|
{
|
|
qualDict.reset
|
|
(
|
|
new IOdictionary
|
|
(
|
|
IOobject
|
|
(
|
|
"meshQualityDict",
|
|
mesh.time().system(),
|
|
mesh,
|
|
IOobject::MUST_READ,
|
|
IOobject::NO_WRITE
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
autoPtr<surfaceWriter> surfWriter;
|
|
autoPtr<writer<scalar>> setWriter;
|
|
if (writeSets)
|
|
{
|
|
surfWriter = surfaceWriter::New(surfaceFormat);
|
|
setWriter = writer<scalar>::New(vtkSetWriter<scalar>::typeName);
|
|
}
|
|
|
|
|
|
forAll(timeDirs, timeI)
|
|
{
|
|
runTime.setTime(timeDirs[timeI], timeI);
|
|
|
|
polyMesh::readUpdateState state = mesh.readUpdate();
|
|
|
|
if
|
|
(
|
|
!timeI
|
|
|| state == polyMesh::TOPO_CHANGE
|
|
|| state == polyMesh::TOPO_PATCH_CHANGE
|
|
)
|
|
{
|
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
|
|
|
// Reconstruct globalMeshData
|
|
mesh.globalData();
|
|
|
|
printMeshStats(mesh, allTopology);
|
|
|
|
label nFailedChecks = 0;
|
|
|
|
if (!noTopology)
|
|
{
|
|
nFailedChecks += checkTopology
|
|
(
|
|
mesh,
|
|
allTopology,
|
|
allGeometry,
|
|
surfWriter,
|
|
setWriter
|
|
);
|
|
}
|
|
|
|
nFailedChecks += checkGeometry
|
|
(
|
|
mesh,
|
|
allGeometry,
|
|
surfWriter,
|
|
setWriter
|
|
);
|
|
|
|
if (meshQuality)
|
|
{
|
|
nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter);
|
|
}
|
|
|
|
|
|
// Note: no reduction in nFailedChecks necessary since is
|
|
// counter of checks, not counter of failed cells,faces etc.
|
|
|
|
if (nFailedChecks == 0)
|
|
{
|
|
Info<< "\nMesh OK.\n" << endl;
|
|
}
|
|
else
|
|
{
|
|
Info<< "\nFailed " << nFailedChecks << " mesh checks.\n"
|
|
<< endl;
|
|
}
|
|
|
|
|
|
// Write selected fields
|
|
Foam::writeFields(mesh, selectedFields);
|
|
}
|
|
else if (state == polyMesh::POINTS_MOVED)
|
|
{
|
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
|
|
|
label nFailedChecks = checkGeometry
|
|
(
|
|
mesh,
|
|
allGeometry,
|
|
surfWriter,
|
|
setWriter
|
|
);
|
|
|
|
if (meshQuality)
|
|
{
|
|
nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter);
|
|
}
|
|
|
|
|
|
if (nFailedChecks)
|
|
{
|
|
Info<< "\nFailed " << nFailedChecks << " mesh checks.\n"
|
|
<< endl;
|
|
}
|
|
else
|
|
{
|
|
Info<< "\nMesh OK.\n" << endl;
|
|
}
|
|
|
|
|
|
// Write selected fields
|
|
Foam::writeFields(mesh, selectedFields);
|
|
}
|
|
}
|
|
|
|
Info<< "End\n" << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|