mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: rewrite of foamToVTK to include parallel output (#926)
- Default format is now XML binary (base64) instead of legacy format. The old -xml option is redundant and ignored. The new -legacy option can be used to force legacy output instead. - Polyhedral decomposition is now off by default (old -poly is ignored). The option -poly-decomp forces decomposition of polyhedrals into primitive shapes. - reduced memory footprint by reading and converting fields successively. - Creation of symlinks to processor files is no longer required or desired. The old -noLinks option is ignored. - Ignore -useTimeName option. Always number according to timeIndex.
This commit is contained in:
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Code chunk for post-processing conversion of cloud(s) to VTK PolyData
|
||||
(.vtp extension).
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
if (doLagrangian)
|
||||
{
|
||||
const fileName cloudPrefix = (regionPrefix/cloud::prefix);
|
||||
|
||||
wordList cloudNames = ListOps::create<word>
|
||||
(
|
||||
readDir
|
||||
(
|
||||
mesh.time().path()/mesh.time().timeName()/cloudPrefix,
|
||||
fileName::DIRECTORY
|
||||
),
|
||||
nameOp<fileName>()
|
||||
);
|
||||
|
||||
// Synchronise cloud names
|
||||
Pstream::combineGather(cloudNames, ListOps::uniqueEqOp<word>());
|
||||
Pstream::combineScatter(cloudNames);
|
||||
|
||||
// Consistent order
|
||||
Foam::sort(cloudNames);
|
||||
|
||||
|
||||
for (const word& cloudName : cloudNames)
|
||||
{
|
||||
IOobjectList cloudObjs(mesh, runTime.timeName(), cloudPrefix/cloudName);
|
||||
|
||||
bool isCloud = false;
|
||||
if (cloudObjs.erase("coordinates"))
|
||||
{
|
||||
isCloud = true;
|
||||
}
|
||||
if (cloudObjs.erase("positions"))
|
||||
{
|
||||
isCloud = true;
|
||||
}
|
||||
|
||||
if (!returnReduce(isCloud, orOp<bool>()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Limited to basic IOField types
|
||||
cloudObjs.filterClasses
|
||||
(
|
||||
stringListOps::foundOp<word>(fieldTypes::basic)
|
||||
);
|
||||
|
||||
// Are there cloud fields (globally)?
|
||||
if (returnReduce(cloudObjs.empty(), andOp<bool>()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtk::lagrangianWriter writer
|
||||
(
|
||||
meshProxy.baseMesh(),
|
||||
cloudName,
|
||||
writeOpts,
|
||||
// Output name for the cloud
|
||||
(
|
||||
outputDir/regionPrefix/cloud::prefix
|
||||
/ cloudName/cloudName + timeDesc
|
||||
),
|
||||
Pstream::parRun()
|
||||
);
|
||||
|
||||
Info<< " Lagrangian: "
|
||||
<< writer.output().relative(runTime.globalPath()) << nl;
|
||||
|
||||
writer.writeTimeValue(mesh.time().value());
|
||||
writer.writeGeometry();
|
||||
|
||||
// Begin CellData/PointData
|
||||
writer.beginParcelData();
|
||||
|
||||
writer.writeFields<label>(cloudObjs);
|
||||
writer.writeFields<scalar>(cloudObjs);
|
||||
writer.writeFields<vector>(cloudObjs);
|
||||
writer.writeFields<sphericalTensor>(cloudObjs);
|
||||
writer.writeFields<symmTensor>(cloudObjs);
|
||||
writer.writeFields<tensor>(cloudObjs);
|
||||
|
||||
fileName outputName(writer.output());
|
||||
|
||||
writer.close();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Add to file-series and emit as JSON
|
||||
|
||||
fileName seriesName(vtk::seriesWriter::base(outputName));
|
||||
|
||||
vtk::seriesWriter& series = vtkSeries(seriesName);
|
||||
|
||||
// First time?
|
||||
// Load from file, verify against filesystem,
|
||||
// prune time >= currentTime
|
||||
if (series.empty())
|
||||
{
|
||||
series.load(seriesName, true, timeValue);
|
||||
}
|
||||
|
||||
series.append(timeValue, outputName);
|
||||
series.write(seriesName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user