snappyHexMesh: Added "noRefinement" writeFlag to control the writing of cellLevel, pointLevel etc. files

By default snappyHexMesh writes files relating to the hex-splitting process into
the polyMesh directory: cellLevel level0Edge pointLevel surfaceIndex

but by setting the noRefinement flag:

writeFlags
(
    noRefinement
    .
    .
    .
);

these optional files which are generally not needed are not written.

If you run the three stages of snappyHexMesh separately or run a dynamic mesh
solver supporting refinement and unrefinement these files are needed
and "noRefinement" should not be set.
This commit is contained in:
Henry Weller
2017-01-24 22:28:36 +00:00
parent 9b319dab61
commit 4e5dc43418
4 changed files with 24 additions and 137 deletions

View File

@ -653,15 +653,6 @@ void writeMesh
meshRefiner.printMeshInfo(debugLevel, msg); meshRefiner.printMeshInfo(debugLevel, msg);
Info<< "Writing mesh to time " << meshRefiner.timeName() << endl; Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
//label flag = meshRefinement::MESH;
//if (writeLevel)
//{
// flag |= meshRefinement::SCALARLEVELS;
//}
//if (debug & meshRefinement::OBJINTERSECTIONS)
//{
// flag |= meshRefinement::OBJINTERSECTIONS;
//}
meshRefiner.write meshRefiner.write
( (
debugLevel, debugLevel,
@ -711,117 +702,6 @@ int main(int argc, char *argv[])
autoPtr<fvMesh> meshPtr; autoPtr<fvMesh> meshPtr;
// if (surfaceSimplify)
// {
// IOdictionary foamyHexMeshDict
// (
// IOobject
// (
// "foamyHexMeshDict",
// runTime.system(),
// runTime,
// IOobject::MUST_READ_IF_MODIFIED,
// IOobject::NO_WRITE
// )
// );
//
// const dictionary& motionDict =
// foamyHexMeshDict.subDict("motionControl");
//
// const scalar defaultCellSize =
// readScalar(motionDict.lookup("defaultCellSize"));
//
// Info<< "Constructing single cell mesh from boundBox" << nl << endl;
//
// boundBox bb(args.optionRead<boundBox>("surfaceSimplify"));
//
// labelList owner(6, label(0));
// labelList neighbour(0);
//
// const cellModel& hexa = *(cellModeller::lookup("hex"));
// faceList faces = hexa.modelFaces();
//
// meshPtr.set
// (
// new fvMesh
// (
// IOobject
// (
// fvMesh::defaultRegion,
// runTime.timeName(),
// runTime,
// IOobject::NO_READ
// ),
// xferMove<Field<vector>>(bb.points()()),
// faces.xfer(),
// owner.xfer(),
// neighbour.xfer()
// )
// );
//
// List<polyPatch*> patches(1);
//
// patches[0] = new wallPolyPatch
// (
// "boundary",
// 6,
// 0,
// 0,
// meshPtr().boundaryMesh(),
// wallPolyPatch::typeName
// );
//
// meshPtr().addFvPatches(patches);
//
// const scalar initialCellSize = ::pow(meshPtr().V()[0], 1.0/3.0);
// const label initialRefLevels =
// ::log(initialCellSize/defaultCellSize)/::log(2);
//
// Info<< "Default cell size = " << defaultCellSize << endl;
// Info<< "Initial cell size = " << initialCellSize << endl;
//
// Info<< "Initial refinement levels = " << initialRefLevels << endl;
//
// Info<< "Mesh starting size = " << meshPtr().nCells() << endl;
//
// // meshCutter must be destroyed before writing the mesh otherwise it
// // writes the cellLevel/pointLevel files
// {
// hexRef8 meshCutter(meshPtr(), false);
//
// for (label refineI = 0; refineI < initialRefLevels; ++refineI)
// {
// // Mesh changing engine.
// polyTopoChange meshMod(meshPtr(), true);
//
// // Play refinement commands into mesh changer.
// meshCutter.setRefinement
// (
// identity(meshPtr().nCells()),
// meshMod
// );
//
// // Create mesh (no inflation), return map from old to new mesh
// autoPtr<mapPolyMesh> map =
// meshMod.changeMesh(meshPtr(), false);
//
// // Update fields
// meshPtr().updateMesh(map);
//
// // Delete mesh volumes.
// meshPtr().clearOut();
//
// Info<< "Refinement Iteration " << refineI + 1
// << ", Mesh size = " << meshPtr().nCells() << endl;
// }
// }
//
// Info<< "Mesh end size = " << meshPtr().nCells() << endl;
//
// Info<< "Create mesh" << endl;
// meshPtr().write();
// }
// else
{ {
Foam::Info Foam::Info
<< "Create mesh for time = " << "Create mesh for time = "

View File

@ -70,7 +70,6 @@ namespace Foam
>::names[] = >::names[] =
{ {
"mesh", "mesh",
//"scalarLevels",
"intersections", "intersections",
"featureSeeds", "featureSeeds",
"attraction", "attraction",
@ -91,10 +90,11 @@ namespace Foam
const char* Foam::NamedEnum const char* Foam::NamedEnum
< <
Foam::meshRefinement::IOwriteType, Foam::meshRefinement::IOwriteType,
4 5
>::names[] = >::names[] =
{ {
"mesh", "mesh",
"noRefinement",
"scalarLevels", "scalarLevels",
"layerSets", "layerSets",
"layerFields" "layerFields"
@ -108,7 +108,7 @@ Foam::meshRefinement::IOdebugTypeNames;
const Foam::NamedEnum<Foam::meshRefinement::IOoutputType, 1> const Foam::NamedEnum<Foam::meshRefinement::IOoutputType, 1>
Foam::meshRefinement::IOoutputTypeNames; Foam::meshRefinement::IOoutputTypeNames;
const Foam::NamedEnum<Foam::meshRefinement::IOwriteType, 4> const Foam::NamedEnum<Foam::meshRefinement::IOwriteType, 5>
Foam::meshRefinement::IOwriteTypeNames; Foam::meshRefinement::IOwriteTypeNames;
@ -2565,11 +2565,7 @@ void Foam::meshRefinement::updateMesh
bool Foam::meshRefinement::write() const bool Foam::meshRefinement::write() const
{ {
bool writeOk = bool writeOk = mesh_.write();
mesh_.write()
&& meshCutter_.write()
&& surfaceIndex_.write();
// Make sure that any distributed surfaces (so ones which probably have // Make sure that any distributed surfaces (so ones which probably have
// been changed) get written as well. // been changed) get written as well.
@ -2908,10 +2904,18 @@ void Foam::meshRefinement::write
{ {
write(); write();
} }
if (writeFlags && !(writeFlags & NOWRITEREFINEMENT))
{
meshCutter_.write();
surfaceIndex_.write();
}
if (writeFlags & WRITELEVELS) if (writeFlags & WRITELEVELS)
{ {
dumpRefinementLevel(); dumpRefinementLevel();
} }
if (debugFlags & OBJINTERSECTIONS && prefix.size()) if (debugFlags & OBJINTERSECTIONS && prefix.size())
{ {
dumpIntersections(prefix); dumpIntersections(prefix);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -89,17 +89,16 @@ public:
enum IOdebugType enum IOdebugType
{ {
IOMESH, IOMESH,
//IOSCALARLEVELS,
IOOBJINTERSECTIONS, IOOBJINTERSECTIONS,
IOFEATURESEEDS, IOFEATURESEEDS,
IOATTRACTION, IOATTRACTION,
IOLAYERINFO IOLAYERINFO
}; };
static const NamedEnum<IOdebugType, 5> IOdebugTypeNames; static const NamedEnum<IOdebugType, 5> IOdebugTypeNames;
enum debugType enum debugType
{ {
MESH = 1<<IOMESH, MESH = 1<<IOMESH,
//SCALARLEVELS = 1<<IOSCALARLEVELS,
OBJINTERSECTIONS = 1<<IOOBJINTERSECTIONS, OBJINTERSECTIONS = 1<<IOOBJINTERSECTIONS,
FEATURESEEDS = 1<<IOFEATURESEEDS, FEATURESEEDS = 1<<IOFEATURESEEDS,
ATTRACTION = 1<< IOATTRACTION, ATTRACTION = 1<< IOATTRACTION,
@ -111,6 +110,7 @@ public:
{ {
IOOUTPUTLAYERINFO IOOUTPUTLAYERINFO
}; };
static const NamedEnum<IOoutputType, 1> IOoutputTypeNames; static const NamedEnum<IOoutputType, 1> IOoutputTypeNames;
enum outputType enum outputType
{ {
@ -121,14 +121,17 @@ public:
enum IOwriteType enum IOwriteType
{ {
IOWRITEMESH, IOWRITEMESH,
IONOWRITEREFINEMENT,
IOWRITELEVELS, IOWRITELEVELS,
IOWRITELAYERSETS, IOWRITELAYERSETS,
IOWRITELAYERFIELDS IOWRITELAYERFIELDS
}; };
static const NamedEnum<IOwriteType, 4> IOwriteTypeNames;
static const NamedEnum<IOwriteType, 5> IOwriteTypeNames;
enum writeType enum writeType
{ {
WRITEMESH = 1<<IOWRITEMESH, WRITEMESH = 1<<IOWRITEMESH,
NOWRITEREFINEMENT = 1<<IONOWRITEREFINEMENT,
WRITELEVELS = 1<<IOWRITELEVELS, WRITELEVELS = 1<<IOWRITELEVELS,
WRITELAYERSETS = 1<<IOWRITELAYERSETS, WRITELAYERSETS = 1<<IOWRITELAYERSETS,
WRITELAYERFIELDS = 1<<IOWRITELAYERFIELDS WRITELAYERFIELDS = 1<<IOWRITELAYERFIELDS

View File

@ -87,14 +87,14 @@ addLayersControls
} }
meshQualityControls meshQualityControls
{ {}
}
writeFlags writeFlags
( (
scalarLevels noRefinement
layerSets // scalarLevels
layerFields // layerSets
// layerFields
); );
mergeTolerance 1e-6; mergeTolerance 1e-6;