ENH: output finiteArea patchID with foamToVTK -with-ids

- can be quite useful for debugging/orientation with complex
  geometries
This commit is contained in:
Mark Olesen 2023-05-08 18:55:23 +02:00
parent f462a850ce
commit 31600c96d4
7 changed files with 40 additions and 31 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -52,7 +52,7 @@ if (doFiniteArea)
outputDir/regionDir/"finite-area" outputDir/regionDir/"finite-area"
/ "finiteArea" + timeDesc / "finiteArea" + timeDesc
), ),
Pstream::parRun() UPstream::parRun()
); );
Info<< " Area : " Info<< " Area : "
<< args.relativePath(writer.output()) << nl; << args.relativePath(writer.output()) << nl;
@ -62,10 +62,10 @@ if (doFiniteArea)
writer.writeTimeValue(timeValue); writer.writeTimeValue(timeValue);
writer.writeGeometry(); writer.writeGeometry();
// Optionally with (cellID, faceLabels, procID) fields // Optionally with (cellID, patchID, faceLabels, procID) fields
writer.beginCellData writer.beginCellData
( (
(withMeshIds ? 2 + (writer.parallel() ? 1 : 0) : 0) (withMeshIds ? 3 + (writer.parallel() ? 1 : 0) : 0)
+ nAreaFields + nAreaFields
); );
@ -76,6 +76,16 @@ if (doFiniteArea)
// Use global indexed values for the 'cell' ids // Use global indexed values for the 'cell' ids
writer.writeCellData("cellID", identity(procAddr.range())); writer.writeCellData("cellID", identity(procAddr.range()));
// The patch ids can also be quite useful
const polyBoundaryMesh& pbm = areaMesh.mesh().boundaryMesh();
labelList patchIds
(
areaMesh.mesh().boundaryMesh().patchID(areaMesh.faceLabels())
);
writer.writeCellData("patchID", patchIds);
// Use proc-local data for faceLabels // Use proc-local data for faceLabels
// (confusing enough already without renumbering) // (confusing enough already without renumbering)
writer.writeCellData("faceLabels", areaMesh.faceLabels()); writer.writeCellData("faceLabels", areaMesh.faceLabels());
@ -95,7 +105,7 @@ if (doFiniteArea)
writer.close(); writer.close();
if (Pstream::master()) if (UPstream::master())
{ {
// Add to file-series and emit as JSON // Add to file-series and emit as JSON

View File

@ -30,7 +30,7 @@ if (doLagrangian)
nameOp<fileName>() nameOp<fileName>()
); );
if (Pstream::parRun()) if (UPstream::parRun())
{ {
// Synchronise cloud names // Synchronise cloud names
Pstream::combineReduce(cloudNames, ListOps::uniqueEqOp<word>()); Pstream::combineReduce(cloudNames, ListOps::uniqueEqOp<word>());
@ -78,7 +78,7 @@ if (doLagrangian)
outputDir/regionDir/cloud::prefix outputDir/regionDir/cloud::prefix
/ cloudName/cloudName + timeDesc / cloudName/cloudName + timeDesc
), ),
Pstream::parRun() UPstream::parRun()
); );
Info<< " Lagrangian: " Info<< " Lagrangian: "
@ -101,7 +101,7 @@ if (doLagrangian)
writer.close(); writer.close();
if (Pstream::master()) if (UPstream::master())
{ {
// Add to file-series and emit as JSON // Add to file-series and emit as JSON

View File

@ -71,9 +71,8 @@ Description
label nPatchWriters = 0; label nPatchWriters = 0;
List<wordList> procPatchNames(Pstream::nProcs()); List<wordList> procPatchNames(UPstream::nProcs());
procPatchNames[UPstream::myProcNo()].resize(patchIds.size());
procPatchNames[Pstream::myProcNo()].resize(patchIds.size());
for (const label patchId : patchIds) for (const label patchId : patchIds)
{ {
@ -87,13 +86,13 @@ Description
nearCellValue, nearCellValue,
( (
vtmOutputBase vtmOutputBase
/ subDirNaming(Pstream::myProcNo()) / subDirNaming(UPstream::myProcNo())
/ pp.name() / pp.name()
), ),
false // This MUST be non-parallel (serial only) false // This MUST be non-parallel (serial only)
); );
procPatchNames[Pstream::myProcNo()][nPatchWriters] = pp.name(); procPatchNames[UPstream::myProcNo()][nPatchWriters] = pp.name();
writer->writeTimeValue(timeValue); writer->writeTimeValue(timeValue);
writer->writeGeometry(); writer->writeGeometry();
@ -111,10 +110,10 @@ Description
for (vtk::patchWriter& writer : patchWriters) for (vtk::patchWriter& writer : patchWriters)
{ {
// Optionally with patchID, procID, neighID fields // Optionally with patchID, procID, neighID fields
// - use Pstream::parRun() not writer.parallel() !! // - use UPstream::parRun() not writer.parallel() !!
writer.beginCellData writer.beginCellData
( (
(withMeshIds ? 1 + (Pstream::parRun() ? 2 : 0) : 0) (withMeshIds ? 1 + (UPstream::parRun() ? 2 : 0) : 0)
+ nVolFields + nVolFields
); );
@ -158,10 +157,10 @@ Description
const label nProcPatches = returnReduce(nPatchWriters, sumOp<label>()); const label nProcPatches = returnReduce(nPatchWriters, sumOp<label>());
if (Pstream::master() && nProcPatches) if (UPstream::master() && nProcPatches)
{ {
Info<< "Wrote " << nProcPatches << " processor boundaries from " Info<< "Wrote " << nProcPatches << " processor boundaries from "
<< Pstream::nProcs() << " processes" << nl; << UPstream::nProcs() << " processes" << nl;
// Collect individual boundaries into a vtm file // Collect individual boundaries into a vtm file

View File

@ -82,7 +82,7 @@ Description
outputDir/regionDir outputDir/regionDir
/ "surface-fields"/"surfaceFields" + timeDesc / "surface-fields"/"surfaceFields" + timeDesc
), ),
Pstream::parRun() UPstream::parRun()
); );
Info<< " Surface : " Info<< " Surface : "
@ -103,7 +103,7 @@ Description
writer.close(); writer.close();
if (Pstream::master()) if (UPstream::master())
{ {
// Add to file-series and emit as JSON // Add to file-series and emit as JSON
@ -173,7 +173,7 @@ Description
/ (meshProxy.useSubMesh() ? meshProxy.name() : fz.name()) / (meshProxy.useSubMesh() ? meshProxy.name() : fz.name())
+ timeDesc + timeDesc
), ),
Pstream::parRun() UPstream::parRun()
); );
Info<< " FaceZone : " Info<< " FaceZone : "
@ -199,7 +199,7 @@ Description
writer.close(); writer.close();
if (Pstream::master()) if (UPstream::master())
{ {
// Add to file-series and emit as JSON // Add to file-series and emit as JSON

View File

@ -39,7 +39,7 @@ if (faceSetName.size())
set, set,
writeOpts, writeOpts,
outputName, outputName,
Pstream::parRun() UPstream::parRun()
); );
wroteTopoSet = true; wroteTopoSet = true;
@ -67,7 +67,7 @@ if (pointSetName.size())
set, set,
writeOpts, writeOpts,
outputName, outputName,
Pstream::parRun() UPstream::parRun()
); );
wroteTopoSet = true; wroteTopoSet = true;

View File

@ -103,7 +103,7 @@ Description
? vtmOutputBase ? vtmOutputBase
: (vtmOutputBase / "internal") : (vtmOutputBase / "internal")
), ),
Pstream::parRun() UPstream::parRun()
); );
// No sub-block for internal // No sub-block for internal
@ -158,7 +158,7 @@ Description
) )
: (vtmOutputBase / "boundary") : (vtmOutputBase / "boundary")
), ),
Pstream::parRun() UPstream::parRun()
); );
// No sub-block for one-patch // No sub-block for one-patch
@ -213,7 +213,7 @@ Description
) )
: (vtmOutputBase / "boundary" / pp.name()) : (vtmOutputBase / "boundary" / pp.name())
), ),
Pstream::parRun() UPstream::parRun()
); );
if (!nPatchWriters) if (!nPatchWriters)
@ -432,7 +432,7 @@ Description
// Collective output // Collective output
if (Pstream::master()) if (UPstream::master())
{ {
// Naming for vtm, file series etc. // Naming for vtm, file series etc.
fileName outputName(vtmOutputBase); fileName outputName(vtmOutputBase);

View File

@ -203,7 +203,7 @@ labelList getSelectedPatches
{ {
continue; continue;
} }
else if (Pstream::parRun() && bool(isA<processorPolyPatch>(pp))) else if (UPstream::parRun() && bool(isA<processorPolyPatch>(pp)))
{ {
break; // No processor patches for parallel output break; // No processor patches for parallel output
} }
@ -499,7 +499,7 @@ int main(int argc, char *argv[])
if (args.found("processor-fields")) if (args.found("processor-fields"))
{ {
if (!Pstream::parRun()) if (!UPstream::parRun())
{ {
Info<< "Ignoring processor patch writing in serial" Info<< "Ignoring processor patch writing in serial"
<< nl << endl; << nl << endl;
@ -689,7 +689,7 @@ int main(int argc, char *argv[])
const fileName outputDir(args.globalPath()/vtkDirName); const fileName outputDir(args.globalPath()/vtkDirName);
if (Pstream::master()) if (UPstream::master())
{ {
// Overwrite or create the VTK/regionName directories. // Overwrite or create the VTK/regionName directories.
// For the default region, this is simply "VTK/" // For the default region, this is simply "VTK/"
@ -832,7 +832,7 @@ int main(int argc, char *argv[])
} }
// Emit multi-region vtm // Emit multi-region vtm
if (Pstream::master() && regionNames.size() > 1) if (UPstream::master() && regionNames.size() > 1)
{ {
fileName outputName fileName outputName
( (