- The internal storage location of finite-area changes from being piggybacked on the polyMesh registry to a having its own dedicated registry: * allows a clearer separation of field types without name clashes. * prerequisite for supporting multiple finite-area regions (future) Old Locations: ``` 0/Us constant/faMesh system/faMeshDefinition system/faSchemes system/faSolution ``` New Locations: ``` 0/finite-area/Us constant/finite-area/faMesh system/finite-area/faMeshDefinition (or system/faMeshDefinition) system/finite-area/faSchemes system/finite-area/faSolution ``` NOTES: The new locations represent a hard change (breaking change) that is normally to be avoided, but seamless compatibility handling within the code was found to be unworkable. The `foamUpgradeFiniteArea` script provides assistance with migration. As a convenience, the system/faMeshDefinition location continues to be supported (may be deprecated in the future).
132 lines
3.6 KiB
C
132 lines
3.6 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | www.openfoam.com
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
|
|
|
Description
|
|
Code chunk for converting finite-area - included by foamToVTK.
|
|
|
|
Typedef vtkWriterType_areaMesh is declared in writeAreaFields.H
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
//
|
|
// Finite-area mesh and fields - need not exist
|
|
//
|
|
|
|
// No subsetting!
|
|
if (doFiniteArea)
|
|
{
|
|
using reportFields = foamToVtkReportFields;
|
|
|
|
autoPtr<faMesh> faMeshPtr;
|
|
|
|
const label nAreaFields =
|
|
faObjects.count(stringListOps::foundOp<word>(fieldTypes::area));
|
|
|
|
if (nAreaFields || withMeshIds)
|
|
{
|
|
faMeshPtr = faMesh::TryNew(meshProxy.baseMesh());
|
|
}
|
|
|
|
if (faMeshPtr && (nAreaFields || withMeshIds))
|
|
{
|
|
const faMesh& areaMesh = faMeshPtr();
|
|
|
|
reportFields::area(Info, faObjects);
|
|
|
|
const auto& pp = faMeshPtr->patch();
|
|
|
|
vtkWriterType_areaMesh writer
|
|
(
|
|
pp,
|
|
writeOpts,
|
|
(
|
|
outputDir/regionDir/"finite-area"
|
|
/ "finiteArea" + timeDesc
|
|
),
|
|
UPstream::parRun()
|
|
);
|
|
Info<< " Area : "
|
|
<< args.relativePath(writer.output()) << nl;
|
|
|
|
writer.beginFile(areaMesh.name());
|
|
|
|
writer.writeTimeValue(timeValue);
|
|
writer.writeGeometry();
|
|
|
|
// Optionally with (cellID, patchID, faceLabels, procID) fields
|
|
writer.beginCellData
|
|
(
|
|
(withMeshIds ? 3 + (writer.parallel() ? 1 : 0) : 0)
|
|
+ nAreaFields
|
|
);
|
|
|
|
if (withMeshIds)
|
|
{
|
|
const globalIndex procAddr(areaMesh.nFaces());
|
|
|
|
// Use global indexed values for the 'cell' ids
|
|
writer.writeCellData("cellID", identity(procAddr.range()));
|
|
|
|
// The patch ids can also be quite useful
|
|
const polyBoundaryMesh& pbm = areaMesh.mesh().boundaryMesh();
|
|
|
|
labelList patchIds
|
|
(
|
|
pbm.patchID(areaMesh.faceLabels())
|
|
);
|
|
|
|
writer.writeCellData("patchID", patchIds);
|
|
|
|
// Use proc-local data for faceLabels
|
|
// (confusing enough already without renumbering)
|
|
writer.writeCellData("faceLabels", areaMesh.faceLabels());
|
|
|
|
writer.writeProcIDs(); // parallel only
|
|
}
|
|
|
|
writeAllAreaFields
|
|
(
|
|
writer,
|
|
areaMesh,
|
|
faObjects,
|
|
true // syncPar
|
|
);
|
|
|
|
fileName outputName(writer.output());
|
|
|
|
writer.close();
|
|
|
|
if (UPstream::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);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|