From e86d3f2e0eeacb164406d013516e7256b95a1ca5 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 18 Jun 2016 01:00:55 +0200 Subject: [PATCH] ENH: add preliminary profiling items into snappyHexMesh - needs more refinement, but provides the general idea. --- .../generation/snappyHexMesh/snappyHexMesh.C | 24 ++++++++++++++++--- .../snappyHexMeshDriver/snappyLayerDriver.C | 3 +++ .../snappyHexMeshDriver/snappyRefineDriver.C | 10 ++++++++ .../snappyHexMeshDriver/snappySnapDriver.C | 6 ++++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index b73c1fbecc..4faa6f74dd 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,6 +59,7 @@ Description #include "IOmanip.H" #include "decompositionModel.H" #include "fvMeshTools.H" +#include "Profiling.H" using namespace Foam; @@ -633,6 +634,7 @@ int main(int argc, char *argv[]) "fileName", "name of the file to save the simplified surface to" ); + #include "addProfilingOption.H" #include "addDictOption.H" #include "setRootCase.H" @@ -816,7 +818,6 @@ int main(int argc, char *argv[]) const Switch keepPatches(meshDict.lookupOrDefault("keepPatches", false)); - // Read decomposePar dictionary dictionary decomposeDict; { @@ -927,6 +928,8 @@ int main(int argc, char *argv[]) } } + // for the impatient who want to see some output files: + Profiling::writeNow(); // Read geometry // ~~~~~~~~~~~~~ @@ -957,6 +960,7 @@ int main(int argc, char *argv[]) if (surfaceSimplify) { + addProfiling(surfaceSimplify, "snappyHexMesh::surfaceSimplify"); IOdictionary foamyHexMeshDict ( IOobject @@ -1001,6 +1005,8 @@ int main(int argc, char *argv[]) refineDict.lookupOrDefault("gapLevelIncrement", 0), initialCellSize/defaultCellSize ); + + Profiling::writeNow(); } else { @@ -1535,6 +1541,8 @@ int main(int argc, char *argv[]) Info<< "Mesh refined in = " << timer.cpuTimeIncrement() << " s." << endl; + + Profiling::writeNow(); } if (wantSnap) @@ -1583,6 +1591,8 @@ int main(int argc, char *argv[]) Info<< "Mesh snapped in = " << timer.cpuTimeIncrement() << " s." << endl; + + Profiling::writeNow(); } if (wantLayers) @@ -1639,11 +1649,14 @@ int main(int argc, char *argv[]) Info<< "Layers added in = " << timer.cpuTimeIncrement() << " s." << endl; + + Profiling::writeNow(); } - { + addProfiling(checkMesh, "snappyHexMesh::checkMesh"); + // Check final mesh Info<< "Checking final mesh ..." << endl; faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100); @@ -1665,11 +1678,15 @@ int main(int argc, char *argv[]) { Info<< "Finished meshing without any errors" << endl; } + + Profiling::writeNow(); } if (surfaceSimplify) { + addProfiling(surfaceSimplify, "snappyHexMesh::surfaceSimplify"); + const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); labelHashSet includePatches(bMesh.size()); @@ -1727,6 +1744,7 @@ int main(int argc, char *argv[]) cellCentres.write(); } + Profiling::writeNow(); Info<< "Finished meshing in = " << runTime.elapsedCpuTime() << " s." << endl; diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index cfbb7c3de8..49b952710e 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -57,6 +57,7 @@ Description #include "localPointRegion.H" #include "externalDisplacementMeshMover.H" #include "scalarIOField.H" +#include "Profiling.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -3399,6 +3400,7 @@ void Foam::snappyLayerDriver::addLayers // extrudeStatus //); + addProfiling(grow, "snappyHexMesh::layers::grow"); // Grow out region of non-extrusion for (label i = 0; i < layerParams.nGrow(); i++) @@ -4219,6 +4221,7 @@ void Foam::snappyLayerDriver::doLayers fvMeshDistribute& distributor ) { + addProfiling(layers, "snappyHexMesh::layers"); const fvMesh& mesh = meshRefiner_.mesh(); Info<< nl diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C index 484229bf93..c6d24bd019 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C @@ -39,6 +39,7 @@ License #include "localPointRegion.H" #include "IOmanip.H" #include "labelVector.H" +#include "Profiling.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -79,6 +80,7 @@ Foam::label Foam::snappyRefineDriver::featureEdgeRefine const label minRefine ) { + addProfiling(edge, "snappyHexMesh::refine::edge"); const fvMesh& mesh = meshRefiner_.mesh(); label iter = 0; @@ -188,6 +190,7 @@ Foam::label Foam::snappyRefineDriver::smallFeatureRefine const label maxIter ) { + addProfiling(feature, "snappyHexMesh::refine::smallFeature"); const fvMesh& mesh = meshRefiner_.mesh(); @@ -310,6 +313,7 @@ Foam::label Foam::snappyRefineDriver::surfaceOnlyRefine const label maxIter ) { + addProfiling(surface, "snappyHexMesh::refine::surface"); const fvMesh& mesh = meshRefiner_.mesh(); // Determine the maximum refinement level over all surfaces. This @@ -807,6 +811,7 @@ Foam::label Foam::snappyRefineDriver::danglingCellRefine const label maxIter ) { + addProfiling(dangling, "snappyHexMesh::refine::danglingCell"); const fvMesh& mesh = meshRefiner_.mesh(); label iter; @@ -952,6 +957,7 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine const label maxIter ) { + addProfiling(interface, "snappyHexMesh::refine::transition"); const fvMesh& mesh = meshRefiner_.mesh(); label iter = 0; @@ -1340,6 +1346,7 @@ Foam::label Foam::snappyRefineDriver::shellRefine const label maxIter ) { + addProfiling(shell, "snappyHexMesh::refine::shell"); const fvMesh& mesh = meshRefiner_.mesh(); // Mark current boundary faces with 0. Have meshRefiner maintain them. @@ -1515,6 +1522,7 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh const dictionary& motionDict ) { + addProfiling(split, "snappyHexMesh::refine::splitting"); Info<< nl << "Splitting mesh at surface intersections" << nl << "---------------------------------------" << nl @@ -1839,6 +1847,7 @@ void Foam::snappyRefineDriver::mergePatchFaces const dictionary& motionDict ) { + addProfiling(merge, "snappyHexMesh::refine::merge"); Info<< nl << "Merge refined boundary faces" << nl << "----------------------------" << nl @@ -1893,6 +1902,7 @@ void Foam::snappyRefineDriver::doRefine const dictionary& motionDict ) { + addProfiling(refine, "snappyHexMesh::refine"); Info<< nl << "Refinement phase" << nl << "----------------" << nl diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C index 95178d2881..ebc4e90229 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,6 +45,7 @@ Description #include "localPointRegion.H" #include "PatchTools.H" #include "refinementFeatures.H" +#include "Profiling.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -832,6 +833,7 @@ void Foam::snappySnapDriver::preSmoothPatch motionSmoother& meshMover ) { + addProfiling(smooth, "snappyHexMesh::snap::smoothing"); const fvMesh& mesh = meshRefiner.mesh(); labelList checkFaces; @@ -2168,6 +2170,7 @@ bool Foam::snappySnapDriver::scaleMesh motionSmoother& meshMover ) { + addProfiling(scale, "snappyHexMesh::snap::scale"); const fvMesh& mesh = meshRefiner_.mesh(); // Relax displacement until correct mesh @@ -2534,6 +2537,7 @@ void Foam::snappySnapDriver::doSnap const snapParameters& snapParams ) { + addProfiling(snap, "snappyHexMesh::snap"); fvMesh& mesh = meshRefiner_.mesh(); Info<< nl