foamFormatConvert: Added support for both compact and non-compact faceLists

This commit is contained in:
Henry Weller
2024-07-03 15:40:20 +01:00
parent 28ee79e7a4
commit 728c14c902

View File

@ -130,6 +130,7 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
} }
const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName; const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
// Fake type back to what was in field // Fake type back to what was in field
const_cast<word&>(meshObject.type()) = io.headerClassName(); const_cast<word&>(meshObject.type()) = io.headerClassName();
@ -199,7 +200,7 @@ bool writeOptionalMeshObject
bool writeOk = false; bool writeOk = false;
bool haveFile = io.headerOk(); const bool haveFile = io.headerOk();
// Make sure all know if there is a valid class name // Make sure all know if there is a valid class name
stringList classNames(1, io.headerClassName()); stringList classNames(1, io.headerClassName());
@ -243,17 +244,15 @@ int main(int argc, char *argv[])
Info<< "Excluding the constant directory." << nl << endl; Info<< "Excluding the constant directory." << nl << endl;
} }
#include "createTime.H" #include "createTime.H"
// Optional mesh (used to read Clouds) // Optional mesh (used to read Clouds)
autoPtr<polyMesh> meshPtr; autoPtr<polyMesh> meshPtr;
// Make sure we do not use the master-only reading since we read // Make sure we do not use the master-only reading since we read
// fields (different per processor) as dictionaries. // fields (different per processor) as dictionaries.
regIOobject::fileModificationChecking = regIOobject::timeStamp; regIOobject::fileModificationChecking = regIOobject::timeStamp;
fileName meshDir = polyMesh::meshSubDir; fileName meshDir = polyMesh::meshSubDir;
fileName regionPrefix = ""; fileName regionPrefix = "";
word regionName = polyMesh::defaultRegion; word regionName = polyMesh::defaultRegion;
@ -264,7 +263,7 @@ int main(int argc, char *argv[])
meshDir = regionName/polyMesh::meshSubDir; meshDir = regionName/polyMesh::meshSubDir;
} }
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); const instantList timeDirs = Foam::timeSelector::select0(runTime, args);
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
{ {
@ -280,7 +279,15 @@ int main(int argc, char *argv[])
); );
writeMeshObject<labelIOList>("owner", meshDir, runTime); writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", meshDir, runTime); writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceCompactIOList>("faces", meshDir, runTime); if (!writeMeshObject<faceCompactIOList>("faces", meshDir, runTime))
{
writeMeshObject<faceCompactIOList, faceIOList>
(
"faces",
meshDir,
runTime
);
}
writeMeshObject<pointIOField>("points", meshDir, runTime); writeMeshObject<pointIOField>("points", meshDir, runTime);
// Write boundary in ascii. This is only needed for fileHandler to // Write boundary in ascii. This is only needed for fileHandler to
// kick in. Should not give problems since always writing ascii. // kick in. Should not give problems since always writing ascii.
@ -342,16 +349,12 @@ int main(int argc, char *argv[])
} }
} }
// Check for lagrangian // Check for lagrangian
const fileName lagrangianDir const fileName lagrangianDir
( (
fileHandler().filePath fileHandler().filePath
( (
runTime.timePath() runTime.timePath()/regionPrefix/cloud::prefix
/ regionPrefix
/ cloud::prefix
) )
); );
stringList lagrangianDirs stringList lagrangianDirs
@ -401,7 +404,7 @@ int main(int argc, char *argv[])
forAll(cloudDirs, i) forAll(cloudDirs, i)
{ {
fileName dir(cloud::prefix/cloudDirs[i]); const fileName dir(cloud::prefix/cloudDirs[i]);
Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false); Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false);