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:
@ -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