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

@ -0,0 +1,38 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
outlet
{
type zeroGradient;
value uniform (0 0 0);
}
walls
{
type noSlip;
}
frontAndBack
{
type noSlip;
}
}
// ************************************************************************* //

28
tutorials/IO/fileHandler/Allrun Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
#- Test writing collated format
runApplication decomposePar -fileHandler collated
runParallel `getApplication` -fileHandler collated
runApplication reconstructPar -latestTime -fileHandler collated
#- Delete collated files
rm -rf processors
#- Test writing uncollated format
runApplication -s uncollated decomposePar -fileHandler uncollated
runParallel -s uncollated `getApplication` -fileHandler uncollated
#- Restart from uncollated
runParallel -s collated `getApplication` -fileHandler collated
runApplication -s collated reconstructPar -latestTime -fileHandler collated
#- Convert the parallel format to uncollated
runParallel foamFormatConvert -fileHandler uncollated
#------------------------------------------------------------------------------

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedVectorField;
location "constant";
object g;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -2 0 0 0 0];
value (0 -9.81 0);
// ************************************************************************* //

View File

@ -0,0 +1,92 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class vectorField;
object kinematicCloudPositions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
(
(0.286 0.077 0.0032)
(0.286 0.083 0.0032)
(0.286 0.089 0.0032)
(0.286 0.095 0.0032)
(0.286 0.101 0.0032)
(0.286 0.107 0.0032)
(0.286 0.113 0.0032)
(0.286 0.119 0.0032)
(0.286 0.125 0.0032)
(0.286 0.131 0.0032)
(0.286 0.137 0.0032)
(0.286 0.143 0.0032)
(0.286 0.149 0.0032)
(0.286 0.155 0.0032)
(0.286 0.161 0.0032)
(0.286 0.167 0.0032)
(0.286 0.173 0.0032)
(0.286 0.179 0.0032)
(0.286 0.185 0.0032)
(0.286 0.191 0.0032)
(0.286 0.197 0.0032)
(0.286 0.203 0.0032)
(0.286 0.209 0.0032)
(0.286 0.215 0.0032)
(0.286 0.221 0.0032)
(0.286 0.227 0.0032)
(0.286 0.233 0.0032)
(0.286 0.239 0.0032)
(0.286 0.245 0.0032)
(0.286 0.251 0.0032)
(0.286 0.257 0.0032)
(0.286 0.263 0.0032)
(0.286 0.269 0.0032)
(0.286 0.275 0.0032)
(0.286 0.281 0.0032)
(0.286 0.287 0.0032)
(0.286 0.293 0.0032)
(0.286 0.299 0.0032)
(0.286 0.305 0.0032)
(0.286 0.311 0.0032)
(0.286 0.317 0.0032)
(0.286 0.323 0.0032)
(0.286 0.329 0.0032)
(0.286 0.335 0.0032)
(0.286 0.341 0.0032)
(0.286 0.347 0.0032)
(0.286 0.353 0.0032)
(0.286 0.359 0.0032)
(0.286 0.365 0.0032)
(0.286 0.371 0.0032)
(0.286 0.377 0.0032)
(0.286 0.383 0.0032)
(0.286 0.389 0.0032)
(0.286 0.395 0.0032)
(0.286 0.401 0.0032)
(0.286 0.407 0.0032)
(0.286 0.413 0.0032)
(0.286 0.419 0.0032)
(0.286 0.425 0.0032)
(0.286 0.431 0.0032)
(0.286 0.437 0.0032)
(0.286 0.443 0.0032)
(0.286 0.449 0.0032)
(0.286 0.455 0.0032)
(0.286 0.461 0.0032)
(0.286 0.467 0.0032)
(0.286 0.473 0.0032)
(0.286 0.479 0.0032)
(0.286 0.485 0.0032)
(0.286 0.491 0.0032)
(0.286 0.497 0.0032)
)
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object kinematicCloudProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solution
{
active true;
coupled false;
transient yes;
cellValueSourceCorrection off;
maxCo 0.3;
interpolationSchemes
{
rho cell;
U cellPoint;
mu cell;
}
integrationSchemes
{
U Euler;
}
}
constantProperties
{
rho0 964;
youngsModulus 6e8;
poissonsRatio 0.35;
}
subModels
{
particleForces
{
sphereDrag;
gravity;
}
injectionModels
{
model1
{
type manualInjection;
massTotal 0;
parcelBasisType fixed;
nParticle 1;
SOI 0;
positionsFile "kinematicCloudPositions";
U0 (0 0 0);
sizeDistribution
{
type fixedValue;
fixedValueDistribution
{
value 0.006;
}
}
}
}
dispersionModel none;
patchInteractionModel none;
surfaceFilmModel none;
stochasticCollisionModel none;
collisionModel pairCollision;
pairCollisionCoeffs
{
// Maximum possible particle diameter expected at any time
maxInteractionDistance 0.006;
writeReferredParticleCloud no;
pairModel pairSpringSliderDashpot;
pairSpringSliderDashpotCoeffs
{
useEquivalentSize no;
alpha 0.12;
b 1.5;
mu 0.52;
cohesionEnergyDensity 0;
collisionResolutionSteps 12;
};
wallModel wallLocalSpringSliderDashpot;
wallLocalSpringSliderDashpotCoeffs
{
useEquivalentSize no;
collisionResolutionSteps 12;
walls
{
youngsModulus 1e10;
poissonsRatio 0.23;
alpha 0.12;
b 1.5;
mu 0.43;
cohesionEnergyDensity 0;
}
frontAndBack
{
youngsModulus 1e10;
poissonsRatio 0.23;
alpha 0.12;
b 1.5;
mu 0.1;
cohesionEnergyDensity 0;
}
};
}
}
cloudFunctions
{}
// ************************************************************************* //

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
rhoInf [1 -3 0 0 0 0 0] 1.2;
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-05;
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 77.9423 6.2)
(135 0 6.2)
(165 0 6.2)
(300 77.9423 6.2)
(300 500 6.2)
(0 500 6.2)
(0 77.9423 0)
(135 0 0)
(165 0 0)
(300 77.9423 0)
(300 500 0)
(0 500 0)
);
blocks
(
hex (6 9 10 11 0 3 4 5 ) (20 40 1) simpleGrading (1 1 1)
hex (7 8 9 6 1 2 3 0) (20 8 1) simpleGrading (1 1 1)
);
boundary
(
walls
{
type wall;
faces
(
(1 7 8 2)
(0 6 7 1)
(2 8 9 3)
(0 5 11 6)
(3 4 10 9)
(4 10 11 5)
);
}
frontAndBack
{
type wall;
faces
(
(0 3 4 5)
(1 2 3 0)
(6 11 10 9)
(6 9 8 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoUncoupledKinematicParcelFoam;
startFrom latestTime;
startTime 0;
stopAt writeNow;
endTime 0.25;
deltaT 5e-5;
writeControl runTime;
writeInterval 0.05;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
// OptimisationSwitches
// {
// fileHandler collated;
// }
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method simple;
simpleCoeffs
{
n (4 1 1);
delta 0.001;
}
hierarchicalCoeffs
{
n (4 1 1);
delta 0.001;
order xyz;
}
manualCoeffs
{
dataFile "";
}
distributed no;
roots ( );
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default none;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
}
// ************************************************************************* //

View File

@ -72,11 +72,10 @@ boundary
type empty;
faces
(
(0 3 2 1)
(4 5 6 7)
(0 3 2 1)
(4 5 6 7)
);
}
);
mergePatchPairs

View File

@ -5,7 +5,23 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
# Serial
runApplication snappyHexMesh -overwrite
runApplication `getApplication`
## Parallel
#runApplication decomposePar -fileHandler collated
#runParallel snappyHexMesh -overwrite -fileHandler collated
## Remove any include files from the field dictionaries
#( mkdir -p processors/0 && \
# cd 0 && \
# for f in *; do [ -f "$f" ] && \
# foamDictionary "$f" > "../processors/0/$f"; done \
#)
#
#runParallel `getApplication` -fileHandler collated
#runApplication reconstructParMesh -constant -mergeTol 1e-6
#runApplication reconstructPar
#------------------------------------------------------------------------------