mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: checkMesh - added -writeChecks option
Added -writeChecks <format> option - writes computed mesh metrics to file in using <format> - currently supported formats are OpenFOAM dictionary and JSON
This commit is contained in:
@ -89,6 +89,9 @@ Usage
|
||||
#include "checkMeshQuality.H"
|
||||
#include "writeFields.H"
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "JSONformatter.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -151,6 +154,14 @@ int main(int argc, char *argv[])
|
||||
"Write bad edges (possibly relevant for finite-area) in vtk format"
|
||||
);
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"writeChecks",
|
||||
"word",
|
||||
"Write checks to file in dictionary or JSON format"
|
||||
);
|
||||
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "getAllRegionOptions.H"
|
||||
@ -187,6 +198,14 @@ int main(int argc, char *argv[])
|
||||
"faceZone"
|
||||
});
|
||||
|
||||
#include "writeMeshChecks.H"
|
||||
|
||||
if (args.found("writeChecks"))
|
||||
{
|
||||
writeChecksFormat =
|
||||
writeChecksFormatTypeNames.get(args.get<word>("writeChecks"));
|
||||
}
|
||||
|
||||
const bool writeFaceFields = args.found("writeAllSurfaceFields");
|
||||
wordHashSet selectedFields;
|
||||
if (args.found("writeFields"))
|
||||
@ -371,6 +390,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Write selected fields
|
||||
Foam::writeFields(mesh, selectedFields, writeFaceFields);
|
||||
|
||||
writeMeshChecks(mesh, writeChecksFormat);
|
||||
}
|
||||
}
|
||||
else if (state == polyMesh::POINTS_MOVED)
|
||||
@ -409,6 +430,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Write selected fields
|
||||
Foam::writeFields(mesh, selectedFields, writeFaceFields);
|
||||
|
||||
writeMeshChecks(mesh, writeChecksFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
enum class writeChecksFormatType
|
||||
{
|
||||
none,
|
||||
dictionary,
|
||||
JSON
|
||||
};
|
||||
const Enum<writeChecksFormatType> writeChecksFormatTypeNames
|
||||
{
|
||||
{ writeChecksFormatType::none, "none" },
|
||||
{ writeChecksFormatType::dictionary, "dictionary" },
|
||||
{ writeChecksFormatType::JSON, "JSON" },
|
||||
};
|
||||
|
||||
writeChecksFormatType writeChecksFormat(writeChecksFormatType::none);
|
||||
|
||||
auto writeMeshChecks = [](const fvMesh& mesh, const writeChecksFormatType fmt)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
switch (fmt)
|
||||
{
|
||||
case writeChecksFormatType::dictionary:
|
||||
{
|
||||
OFstream os(mesh.time().globalPath()/"checkMesh.dict");
|
||||
|
||||
IOdictionary data
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
mesh.time().globalPath()/"checkMesh.dict",
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
)
|
||||
);
|
||||
|
||||
data.writeHeader(os);
|
||||
|
||||
mesh.data().meshDict().write(os, false);
|
||||
|
||||
IOobject::writeEndDivider(os);
|
||||
|
||||
Info<< "Writing mesh data to " << data.objectPath()
|
||||
<< nl << endl;
|
||||
|
||||
break;
|
||||
}
|
||||
case writeChecksFormatType::JSON:
|
||||
{
|
||||
OFstream os(mesh.time().globalPath()/"checkMesh.json");
|
||||
|
||||
Info<< "Writing mesh data to " << os.name() << nl << endl;
|
||||
|
||||
JSONformatter json(os);
|
||||
|
||||
json.writeDict(mesh.data().meshDict());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user