openfoam/applications/utilities/mesh/manipulation/checkMesh/writeMeshChecks.H
Mark Olesen 0352a224b7 COMP: access transformedElements by reference, not copy
- better code style and seems to avoid triggering a gcc warning about
  possibly uninitialized values

COMP: JSONformatter writeEntry missing a return value

STYLE: accept 'json' for checkMesh write format

- consistent with caseInfo functionObject
2023-12-15 16:17:15 +01:00

65 lines
1.6 KiB
C

enum class writeChecksFormatType
{
none,
dictionary,
JSON
};
const Enum<writeChecksFormatType> writeChecksFormatTypeNames
{
{ writeChecksFormatType::none, "none" },
{ writeChecksFormatType::dictionary, "dictionary" },
{ writeChecksFormatType::JSON, "json" },
{ writeChecksFormatType::JSON, "JSON" },
};
writeChecksFormatType writeChecksFormat(writeChecksFormatType::none);
auto writeMeshChecks = [](const fvMesh& mesh, const writeChecksFormatType fmt)
{
if (UPstream::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
)
);
Info<< "Writing mesh data to " << os.name() << nl << endl;
data.writeHeader(os);
mesh.data().meshDict().write(os, false);
IOobject::writeEndDivider(os);
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
}
}
}
};