foanToVTK: Compatibility with NCC

foamToVTK now supports cases with non-conformal patches. These are
excluded from the final output because their faces do not correspond to
anything in the conformal polyMesh.

In addition, patches are now excluded due to type or selection
consistently, regardless of the presence of the -allPatches option.
This commit is contained in:
Will Bainbridge
2022-08-10 11:23:37 +01:00
parent 436c6e4403
commit 65b7979147

View File

@ -137,6 +137,7 @@ Usage
#include "pointMesh.H" #include "pointMesh.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "nonConformalPolyPatch.H"
#include "labelIOField.H" #include "labelIOField.H"
#include "scalarIOField.H" #include "scalarIOField.H"
#include "sphericalTensorIOField.H" #include "sphericalTensorIOField.H"
@ -204,12 +205,13 @@ labelList getSelectedPatches
if if
( (
isType<emptyPolyPatch>(pp) isA<emptyPolyPatch>(pp)
|| isA<nonConformalPolyPatch>(pp)
|| (Pstream::parRun() && isType<processorPolyPatch>(pp)) || (Pstream::parRun() && isType<processorPolyPatch>(pp))
) )
{ {
Info<< " discarding empty/processor patch " << patchi Info<< " discarding empty/nonConformal/processor patch "
<< " " << pp.name() << endl; << patchi << " " << pp.name() << endl;
} }
else if (findStrings(excludePatches, pp.name())) else if (findStrings(excludePatches, pp.name()))
{ {
@ -222,6 +224,7 @@ labelList getSelectedPatches
Info<< " patch " << patchi << " " << pp.name() << endl; Info<< " patch " << patchi << " " << pp.name() << endl;
} }
} }
return patchIDs.shrink(); return patchIDs.shrink();
} }
@ -873,6 +876,8 @@ int main(int argc, char *argv[])
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
const labelList patchIDs(getSelectedPatches(patches, excludePatches));
if (allPatches) if (allPatches)
{ {
mkDir(fvPath/"allPatches"); mkDir(fvPath/"allPatches");
@ -944,94 +949,88 @@ int main(int argc, char *argv[])
} }
else else
{ {
forAll(patches, patchi) forAll(patchIDs, i)
{ {
const polyPatch& pp = patches[patchi]; const polyPatch& pp = patches[patchIDs[i]];
if (!findStrings(excludePatches, pp.name())) mkDir(fvPath/pp.name());
fileName patchFileName;
if (vMesh.useSubMesh())
{ {
mkDir(fvPath/pp.name()); patchFileName =
fvPath/pp.name()/cellSetName
+ "_"
+ timeDesc
+ ".vtk";
}
else
{
patchFileName =
fvPath/pp.name()/pp.name()
+ "_"
+ timeDesc
+ ".vtk";
}
fileName patchFileName; Info<< " Patch : " << patchFileName << endl;
if (vMesh.useSubMesh()) patchWriter writer
{ (
patchFileName = vMesh,
fvPath/pp.name()/cellSetName binary,
+ "_" nearCellValue,
+ timeDesc patchFileName,
+ ".vtk"; labelList(1, patchIDs[i])
} );
else
{
patchFileName =
fvPath/pp.name()/pp.name()
+ "_"
+ timeDesc
+ ".vtk";
}
Info<< " Patch : " << patchFileName << endl; // VolFields + patchID
vtkWriteOps::writeCellDataHeader
(
writer.os(),
writer.nFaces(),
1 + nVolFields
);
patchWriter writer // Write patchID field
writer.writePatchIDs();
// Write volFields
writer.write(vsf);
writer.write(vvf);
writer.write(vsptf);
writer.write(vsytf);
writer.write(vtf);
if (!noPointValues)
{
vtkWriteOps::writePointDataHeader
( (
vMesh, writer.os(),
binary, writer.nPoints(),
nearCellValue, nVolFields
patchFileName, + nPointFields
labelList(1, patchi)
); );
if (!isA<emptyPolyPatch>(pp)) // Write pointFields
{ writer.write(psf);
// VolFields + patchID writer.write(pvf);
vtkWriteOps::writeCellDataHeader writer.write(psptf);
( writer.write(psytf);
writer.os(), writer.write(ptf);
writer.nFaces(),
1 + nVolFields
);
// Write patchID field PrimitivePatchInterpolation<primitivePatch> pInter
writer.writePatchIDs(); (
pp
);
// Write volFields // Write interpolated volFields
writer.write(vsf); writer.write(pInter, vsf);
writer.write(vvf); writer.write(pInter, vvf);
writer.write(vsptf); writer.write(pInter, vsptf);
writer.write(vsytf); writer.write(pInter, vsytf);
writer.write(vtf); writer.write(pInter, vtf);
if (!noPointValues)
{
vtkWriteOps::writePointDataHeader
(
writer.os(),
writer.nPoints(),
nVolFields
+ nPointFields
);
// Write pointFields
writer.write(psf);
writer.write(pvf);
writer.write(psptf);
writer.write(psytf);
writer.write(ptf);
PrimitivePatchInterpolation<primitivePatch> pInter
(
pp
);
// Write interpolated volFields
writer.write(pInter, vsf);
writer.write(pInter, vvf);
writer.write(pInter, vsptf);
writer.write(pInter, vsytf);
writer.write(pInter, vtf);
}
}
} }
} }
} }