Skip to content
Snippets Groups Projects
Commit f8742146 authored by Andrew Heather's avatar Andrew Heather
Browse files

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
parent 9d20dd84
Branches
Tags
1 merge request!646Extract case and solver information
......@@ -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);
}
}
}
......
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
}
}
}
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment