From 2dcd867f47ad6943942da95f573c5c26f6deb58c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 5 Oct 2009 22:53:22 +0200 Subject: [PATCH] blockMesh improvements - expose point field throughout - make output less verbose, but can switch on/off with verbose() static method --- .../mesh/generation/blockMesh/blockMeshApp.C | 2 + .../blockDescriptor/blockDescriptor.C | 4 +- src/mesh/blockMesh/blockMesh/blockMesh.C | 17 +++++++ src/mesh/blockMesh/blockMesh/blockMesh.H | 7 +++ src/mesh/blockMesh/blockMesh/blockMeshCheck.C | 49 ++++++++++--------- .../blockMesh/blockMesh/blockMeshCreate.C | 15 ++++-- src/mesh/blockMesh/blockMesh/blockMeshMerge.C | 21 ++++++-- .../blockMesh/blockMesh/blockMeshTopology.C | 23 +++++++-- 8 files changed, 102 insertions(+), 36 deletions(-) diff --git a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index 501b45c132..6cdec703dc 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -149,6 +149,8 @@ int main(int argc, char *argv[]) Info<< "Creating block mesh from\n " << meshDictIoPtr->objectPath() << endl; + blockMesh::verbose(true); + IOdictionary meshDict(meshDictIoPtr()); blockMesh blocks(meshDict); diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index 7b7a0bdcac..599a108c3c 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -78,7 +78,7 @@ Foam::blockDescriptor::blockDescriptor meshDensity_(), edgePoints_(12), edgeWeights_(12), - expand_(12), + expand_(12, 1.0), zoneName_() { // Examine next token @@ -159,7 +159,7 @@ Foam::blockDescriptor::blockDescriptor ( "blockDescriptor::blockDescriptor" "(const pointField&, const curvedEdgeList&, Istream&)" - ) << "Unknown definition of expansion ratios" + ) << "Unknown definition of expansion ratios: " << expRatios << exit(FatalError); } diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.C b/src/mesh/blockMesh/blockMesh/blockMesh.C index acdcc8b86d..4d499ea943 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.C +++ b/src/mesh/blockMesh/blockMesh/blockMesh.C @@ -26,6 +26,11 @@ License #include "blockMesh.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +bool Foam::blockMesh::blockMesh::verboseOutput(false); + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::blockMesh::blockMesh(IOdictionary& dict) @@ -48,6 +53,18 @@ Foam::blockMesh::~blockMesh() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::blockMesh::verbose(const bool on) +{ + verboseOutput = on; +} + + +const Foam::pointField& Foam::blockMesh::blockPointField() const +{ + return blockPointField_; +} + + const Foam::polyMesh& Foam::blockMesh::topology() const { if (!topologyPtr_) diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.H b/src/mesh/blockMesh/blockMesh/blockMesh.H index 3b817c5179..6e67506a79 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.H +++ b/src/mesh/blockMesh/blockMesh/blockMesh.H @@ -62,6 +62,7 @@ class blockMesh public blockList { // Private data + static bool verboseOutput; //- Point field defining the block mesh (corners) pointField blockPointField_; @@ -142,6 +143,9 @@ public: // Access + //- Reference to point field defining the block mesh + const pointField& blockPointField() const; + const polyMesh& topology() const; const curvedEdgeList& edges() const @@ -170,6 +174,9 @@ public: //- Clear geometry (internal points, cells, boundaryPatches) void clearGeom(); + //- Enable/disable verbose information about the progress + static void verbose(const bool on=true); + // Write //- Writes edges of blockMesh in OBJ format. diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCheck.C b/src/mesh/blockMesh/blockMesh/blockMeshCheck.C index 1e3d6ca693..228f41e43c 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshCheck.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshCheck.C @@ -31,7 +31,10 @@ License // Check the blockMesh topology void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const { - Info<< nl << "Check topology" << endl; + if (verboseOutput) + { + Info<< nl << "Check topology" << endl; + } bool ok = true; @@ -55,28 +58,27 @@ void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const } - Info<< nl << tab << "Basic statistics" << nl; - - Info<< tab << tab << "Number of internal faces : " - << bm.nInternalFaces() << nl; - - Info<< tab << tab << "Number of boundary faces : " - << nBoundaryFaces << nl; - - Info<< tab << tab << "Number of defined boundary faces : " - << nDefinedBoundaryFaces << nl; - - Info<< tab << tab << "Number of undefined boundary faces : " - << nBoundaryFaces - nDefinedBoundaryFaces << nl; - - if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0) + if (verboseOutput) { - Info<< tab << tab << tab - << "(Warning : only leave undefined the front and back planes " - << "of 2D planar geometries!)" << endl; - } + Info<< nl << tab << "Basic statistics" << nl + << tab << tab << "Number of internal faces : " + << bm.nInternalFaces() << nl + << tab << tab << "Number of boundary faces : " + << nBoundaryFaces << nl + << tab << tab << "Number of defined boundary faces : " + << nDefinedBoundaryFaces << nl + << tab << tab << "Number of undefined boundary faces : " + << nBoundaryFaces - nDefinedBoundaryFaces << nl; - Info<< tab << "Checking patch -> block consistency" << endl; + if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0) + { + Info<< tab << tab << tab + << "(Warning : only leave undefined the front and back planes " + << "of 2D planar geometries!)" << endl; + } + + Info<< tab << "Checking patch -> block consistency" << endl; + } forAll(patches, patchi) @@ -132,7 +134,10 @@ void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const } } - Info<< endl; + if (verboseOutput) + { + Info<< endl; + } if (!ok) { diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C index f9ebd02c66..c825469410 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C @@ -34,7 +34,10 @@ void Foam::blockMesh::createPoints() const { const blockList& blocks = *this; - Info<< "Creating points with scale " << scaleFactor_ << endl; + if (verboseOutput) + { + Info<< "Creating points with scale " << scaleFactor_ << endl; + } // // generate points @@ -65,7 +68,10 @@ void Foam::blockMesh::createCells() const const blockList& blocks = *this; const cellModel& hex = *(cellModeller::lookup("hex")); - Info<< "Creating cells" << endl; + if (verboseOutput) + { + Info<< "Creating cells" << endl; + } // // generate cells @@ -221,7 +227,10 @@ void Foam::blockMesh::createPatches() const { const polyPatchList& topoPatches = topology().boundaryMesh(); - Info<< "Creating patches" << endl; + if (verboseOutput) + { + Info<< "Creating patches" << endl; + } // // generate points diff --git a/src/mesh/blockMesh/blockMesh/blockMeshMerge.C b/src/mesh/blockMesh/blockMesh/blockMeshMerge.C index 6da65be26e..3c5ca4ca84 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshMerge.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshMerge.C @@ -32,7 +32,10 @@ void Foam::blockMesh::calcMergeInfo() { const blockList& blocks = *this; - Info<< "Creating block offsets" << endl; + if (verboseOutput) + { + Info<< "Creating block offsets" << endl; + } blockOffsets_.setSize(blocks.size()); @@ -48,7 +51,10 @@ void Foam::blockMesh::calcMergeInfo() } - Info<< "Creating merge list " << flush; + if (verboseOutput) + { + Info<< "Creating merge list " << flush; + } // set unused to -1 mergeList_.setSize(nPoints_); @@ -411,7 +417,10 @@ void Foam::blockMesh::calcMergeInfo() } } } - Info<< "." << flush; + if (verboseOutput) + { + Info<< "." << flush; + } if (nPasses > 100) { @@ -421,7 +430,11 @@ void Foam::blockMesh::calcMergeInfo() } } while (changedPointMerge); - Info<< endl; + + if (verboseOutput) + { + Info<< endl; + } forAll(blockInternalFaces, blockFaceLabel) { diff --git a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C index bb20b20468..97ad739d60 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C @@ -62,7 +62,10 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) // if (dict.found("edges")) { - Info<< "Creating curved edges" << endl; + if (verboseOutput) + { + Info<< "Creating curved edges" << endl; + } ITstream& is(dict.lookup("edges")); @@ -117,7 +120,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) // Read end of edges is.readEnd("edges"); } - else + else if (verboseOutput) { Info<< "No non-linear edges defined" << endl; } @@ -126,7 +129,11 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) // // Create the blocks // - Info<< "Creating topology blocks" << endl; + if (verboseOutput) + { + Info<< "Creating topology blocks" << endl; + } + { ITstream& is(dict.lookup("blocks")); @@ -198,7 +205,10 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) // // Create the patches // - Info<< "Creating topology patches" << endl; + if (verboseOutput) + { + Info<< "Creating topology patches" << endl; + } faceListList tmpBlocksPatches; wordList patchNames; @@ -298,7 +308,10 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) // // Create the topology // - Info<< "Creating topology mesh" << endl; + if (verboseOutput) + { + Info<< "Creating topology mesh" << endl; + } PtrList tmpBlockShapes(blocks.size()); forAll(blocks, blockI)