diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 6b40b2ab5e..3d982e052b 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -361,7 +361,6 @@ snapControls // Maximum relative distance for points to be attracted by surface. // True distance is this factor times local maximum edge length. - // Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance) tolerance 2.0; // Number of mesh displacement relaxation iterations. @@ -524,7 +523,25 @@ addLayersControls - // Medial axis analysis + // Choice of mesh shrinking algorithm + + // Optional mesh shrinking algorithm (default is displacementMedialAxis) + // The displacementMotionSolver is a wrapper around the displacement + // motion solvers. It needs specification of the solver to use and + // its control dictionary. + //meshShrinker displacementMotionSolver; + //solver displacementLaplacian; + //displacementLaplacianCoeffs + //{ + // diffusivity quadratic inverseDistance + // ( + // sphere.stl_firstSolid + // maxY + // ); + //} + + + // Medial axis analysis (for use with default displacementMedialAxis) // Angle used to pick up medial axis points // Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 @@ -552,9 +569,6 @@ addLayersControls // Default is false. //detectExtrusionIsland true; - - // Mesh shrinking - // Optional: at non-patched sides allow mesh to slip if extrusion // direction makes angle larger than slipFeatureAngle. Default is // 0.5*featureAngle. @@ -564,6 +578,9 @@ addLayersControls // before upon reaching a correct mesh. nRelaxIter 5; + + // Mesh shrinking + // Create buffer region for new layer terminations, i.e. gradually // step down number of layers. Set to <0 to terminate layer in one go. nBufferCellsNoExtrude 0; diff --git a/applications/utilities/mesh/manipulation/checkMesh/Make/files b/applications/utilities/mesh/manipulation/checkMesh/Make/files index 1a3130a23c..21febe2789 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/Make/files +++ b/applications/utilities/mesh/manipulation/checkMesh/Make/files @@ -1,4 +1,4 @@ -printMeshStats.C +checkTools.C checkTopology.C checkGeometry.C checkMeshQuality.C diff --git a/applications/utilities/mesh/manipulation/checkMesh/Make/options b/applications/utilities/mesh/manipulation/checkMesh/Make/options index 2ff5dbabfe..4700e225a5 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/Make/options +++ b/applications/utilities/mesh/manipulation/checkMesh/Make/options @@ -1,8 +1,12 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ -lmeshTools \ + -lsampling \ + -lsurfMesh \ -ldynamicMesh diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 68c316f24d..320319cac7 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -7,6 +7,8 @@ #include "wedgePolyPatch.H" #include "unitConversion.H" #include "polyMeshTetDecomposition.H" +#include "surfaceWriter.H" +#include "checkTools.H" // Find wedge with opposite orientation. Note: does not actually check that @@ -477,7 +479,12 @@ bool Foam::checkCoupledPoints } -Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) +Foam::label Foam::checkGeometry +( + const polyMesh& mesh, + const bool allGeometry, + const autoPtr& writer +) { label noFailedChecks = 0; @@ -563,6 +570,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " non closed cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } @@ -575,6 +586,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << aspectCells.name() << endl; aspectCells.instance() = mesh.pointsInstance(); aspectCells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), aspectCells); + } } } @@ -592,6 +607,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " zero area faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -610,6 +629,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " zero volume cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } } @@ -629,6 +652,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " non-orthogonal faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } @@ -647,6 +674,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -665,6 +696,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " skew faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -685,6 +720,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -714,6 +753,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << "decomposition tets to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -774,6 +817,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -793,6 +840,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " warped faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -810,6 +861,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " under-determined cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } @@ -826,6 +881,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " concave cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } @@ -843,6 +902,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } @@ -860,6 +923,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H index edc1f44826..9658512eb1 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H @@ -6,6 +6,7 @@ namespace Foam { class polyMesh; class wedgePolyPatch; + class surfaceWriter; label findOppositeWedge(const polyMesh&, const wedgePolyPatch&); @@ -21,5 +22,10 @@ namespace Foam //- Check 0th vertex on coupled faces bool checkCoupledPoints(const polyMesh&, const bool report, labelHashSet*); - label checkGeometry(const polyMesh& mesh, const bool allGeometry); + label checkGeometry + ( + const polyMesh& mesh, + const bool allGeometry, + const autoPtr& + ); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index b11946a28f..527ba497d3 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.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 | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,16 +42,20 @@ Usage \param -region \ \n Specify an alternative mesh region. + \param -writeSets \ \n + Reconstruct all cellSets and faceSets geometry and write to postProcessing/ + directory according to surfaceFormat (e.g. vtk or ensight) + \*---------------------------------------------------------------------------*/ #include "argList.H" #include "timeSelector.H" #include "Time.H" - #include "polyMesh.H" #include "globalMeshData.H" +#include "vtkSurfaceWriter.H" -#include "printMeshStats.H" +#include "checkTools.H" #include "checkTopology.H" #include "checkGeometry.H" #include "checkMeshQuality.H" @@ -84,6 +88,12 @@ int main(int argc, char *argv[]) "meshQuality", "read user-defined mesh quality criterions from system/meshQualityDict" ); + argList::addOption + ( + "writeSets", + "surfaceFormat" + "reconstruct and write all faceSets and cellSets in selected format" + ); #include "setRootCase.H" #include "createTime.H" @@ -95,6 +105,9 @@ int main(int argc, char *argv[]) const bool allTopology = args.optionFound("allTopology"); const bool meshQuality = args.optionFound("meshQuality"); + word surfaceFormat; + const bool writeSets = args.optionReadIfPresent("writeSets", surfaceFormat); + if (noTopology) { Info<< "Disabling all topology checks." << nl << endl; @@ -112,6 +125,12 @@ int main(int argc, char *argv[]) { Info<< "Enabling user-defined geometry checks." << nl << endl; } + if (writeSets) + { + Info<< "Reconstructing and writing " << surfaceFormat + << " representation" + << " of all faceSets and cellSets." << nl << endl; + } autoPtr qualDict; @@ -134,6 +153,13 @@ int main(int argc, char *argv[]) } + autoPtr writer; + if (writeSets) + { + writer = surfaceWriter::New(surfaceFormat); + } + + forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); @@ -161,14 +187,20 @@ int main(int argc, char *argv[]) if (!noTopology) { - nFailedChecks += checkTopology(mesh, allTopology, allGeometry); + nFailedChecks += checkTopology + ( + mesh, + allTopology, + allGeometry, + writer + ); } - nFailedChecks += checkGeometry(mesh, allGeometry); + nFailedChecks += checkGeometry(mesh, allGeometry, writer); if (meshQuality) { - nFailedChecks += checkMeshQuality(mesh, qualDict()); + nFailedChecks += checkMeshQuality(mesh, qualDict(), writer); } @@ -189,11 +221,11 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - label nFailedChecks = checkGeometry(mesh, allGeometry); + label nFailedChecks = checkGeometry(mesh, allGeometry, writer); if (meshQuality) { - nFailedChecks += checkMeshQuality(mesh, qualDict()); + nFailedChecks += checkMeshQuality(mesh, qualDict(), writer); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C index b00f02f8ef..a6a01c7336 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -3,12 +3,14 @@ #include "cellSet.H" #include "faceSet.H" #include "motionSmoother.H" - +#include "surfaceWriter.H" +#include "checkTools.H" Foam::label Foam::checkMeshQuality ( const polyMesh& mesh, - const dictionary& dict + const dictionary& dict, + const autoPtr& writer ) { label noFailedChecks = 0; @@ -27,6 +29,10 @@ Foam::label Foam::checkMeshQuality << " faces in error to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H index 1e5b3489c9..52507986bf 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H @@ -2,5 +2,12 @@ namespace Foam { - label checkMeshQuality(const polyMesh& mesh, const dictionary&); + class surfaceWriter; + + label checkMeshQuality + ( + const polyMesh&, + const dictionary&, + const autoPtr& + ); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C new file mode 100644 index 0000000000..55cc2fcc1d --- /dev/null +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -0,0 +1,397 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "checkTools.H" +#include "polyMesh.H" +#include "globalMeshData.H" +#include "hexMatcher.H" +#include "wedgeMatcher.H" +#include "prismMatcher.H" +#include "pyrMatcher.H" +#include "tetWedgeMatcher.H" +#include "tetMatcher.H" +#include "IOmanip.H" +#include "faceSet.H" +#include "cellSet.H" +#include "PatchTools.H" +#include "Time.H" +#include "surfaceWriter.H" +#include "sampledSurfaces.H" +#include "syncTools.H" + + +void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) +{ + Info<< "Mesh stats" << nl + << " points: " + << returnReduce(mesh.points().size(), sumOp