From 86c5a3a228db39429b410fd908c27270077dac1f Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 11 Jul 2013 12:31:43 +0100 Subject: [PATCH 1/2] ENH: foamyHexMesh: Do not allow default patch types when reading patchInfo from dictionary --- .../conformalVoronoiMesh.H | 8 - .../conformalVoronoiMeshCalcDualMesh.C | 47 +++-- .../conformalVoronoiMeshIO.C | 45 +++-- .../polyMeshFilter/polyMeshFilterSettings.C | 141 +++++++++++++++ .../polyMeshFilter/polyMeshFilterSettings.H | 166 ++++++++++++++++++ .../polyMeshFilter/polyMeshFilterSettingsI.H | 98 +++++++++++ .../flange/system/foamyHexMeshDict | 3 + 7 files changed, 459 insertions(+), 49 deletions(-) create mode 100644 src/dynamicMesh/polyMeshFilter/polyMeshFilterSettings.C create mode 100644 src/dynamicMesh/polyMeshFilter/polyMeshFilterSettings.H create mode 100644 src/dynamicMesh/polyMeshFilter/polyMeshFilterSettingsI.H diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 15b2bd4859..ac11d1a8fa 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -793,7 +793,6 @@ private: faceList& faces, labelList& owner, labelList& neighbour, - wordList& patchTypes, wordList& patchNames, PtrList& patchDicts, pointField& cellCentres, @@ -810,7 +809,6 @@ private: faceList& faces, labelList& owner, labelList& neighbour, - wordList& patchTypes, wordList& patchNames, PtrList& patchDicts ); @@ -894,7 +892,6 @@ private: label createPatchInfo ( wordList& patchNames, - wordList& patchTypes, PtrList& patchDicts ) const; @@ -909,7 +906,6 @@ private: faceList& faces, labelList& owner, labelList& neighbour, - wordList& patchTypes, wordList& patchNames, PtrList& patchDicts, labelListList& patchPointPairSlaves, @@ -976,7 +972,6 @@ private: autoPtr createDummyMesh ( const IOobject& io, - const wordList& patchTypes, const wordList& patchNames, const PtrList& patchDicts ) const; @@ -986,7 +981,6 @@ private: void checkProcessorPatchesMatch ( - const wordList& patchTypes, const PtrList& patchDicts ) const; @@ -1005,7 +999,6 @@ private: const fileName& instance, const pointField& points, faceList& faces, - const wordList& patchTypes, const wordList& patchNames, const PtrList& patchDicts ) const; @@ -1176,7 +1169,6 @@ public: faceList& faces, labelList& owner, labelList& neighbour, - const wordList& patchTypes, const wordList& patchNames, const PtrList& patchDicts, const pointField& cellCentres, diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index b5810855df..7c07d12e67 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -514,7 +514,6 @@ void Foam::conformalVoronoiMesh::calcDualMesh faceList& faces, labelList& owner, labelList& neighbour, - wordList& patchTypes, wordList& patchNames, PtrList& patchDicts, pointField& cellCentres, @@ -595,7 +594,6 @@ void Foam::conformalVoronoiMesh::calcDualMesh faces, owner, neighbour, - patchTypes, patchNames, patchDicts, patchToDelaunayVertex, // from patch face to Delaunay vertex (slavePp) @@ -624,7 +622,6 @@ void Foam::conformalVoronoiMesh::calcTetMesh faceList& faces, labelList& owner, labelList& neighbour, - wordList& patchTypes, wordList& patchNames, PtrList& patchDicts ) @@ -679,7 +676,6 @@ void Foam::conformalVoronoiMesh::calcTetMesh patchNames.setSize(patchNames.size() + 1); patchNames[patchNames.size() - 1] = "foamyHexMesh_defaultPatch"; - patchTypes.setSize(patchNames.size(), wallPolyPatch::typeName); label nPatches = patchNames.size(); @@ -1212,7 +1208,6 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints faceList faces; labelList owner; labelList neighbour; - wordList patchTypes; wordList patchNames; PtrList patchDicts; pointField cellCentres; @@ -1229,7 +1224,6 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints faces, owner, neighbour, - patchTypes, patchNames, patchDicts, patchToDelaunayVertex, @@ -1272,7 +1266,11 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints { label totalPatchSize = readLabel(patchDicts[p].lookup("nFaces")); - if (patchTypes[p] == processorPolyPatch::typeName) + if + ( + patchDicts.set(p) + && word(patchDicts[p].lookup("type")) == processorPolyPatch::typeName + ) { // Do not create empty processor patches if (totalPatchSize > 0) @@ -1285,7 +1283,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints patchDicts[p], nValidPatches, pMesh.boundaryMesh(), - patchTypes[p] + processorPolyPatch::typeName ); nValidPatches++; @@ -1300,7 +1298,6 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints { patches[nValidPatches] = polyPatch::New ( - patchTypes[p], patchNames[p], patchDicts[p], nValidPatches, @@ -2026,13 +2023,11 @@ void Foam::conformalVoronoiMesh::reindexDualVertices Foam::label Foam::conformalVoronoiMesh::createPatchInfo ( wordList& patchNames, - wordList& patchTypes, PtrList& patchDicts ) const { patchNames = geometryToConformTo_.patchNames(); - patchTypes.setSize(patchNames.size() + 1, wallPolyPatch::typeName); patchDicts.setSize(patchNames.size() + 1); const PtrList& patchInfo = geometryToConformTo_.patchInfo(); @@ -2041,18 +2036,16 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo { if (patchInfo.set(patchI)) { - patchTypes[patchI] = - patchInfo[patchI].lookupOrDefault - ( - "type", - wallPolyPatch::typeName - ); - patchDicts.set(patchI, new dictionary(patchInfo[patchI])); } else { patchDicts.set(patchI, new dictionary()); + patchDicts[patchI].set + ( + "type", + wallPolyPatch::typeName + ); } } @@ -2060,6 +2053,11 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo label defaultPatchIndex = patchNames.size() - 1; patchNames[defaultPatchIndex] = "foamyHexMesh_defaultPatch"; patchDicts.set(defaultPatchIndex, new dictionary()); + patchDicts[defaultPatchIndex].set + ( + "type", + wallPolyPatch::typeName + ); label nProcPatches = 0; @@ -2117,7 +2115,6 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo label nTotalPatches = nNonProcPatches + nProcPatches; patchNames.setSize(nTotalPatches); - patchTypes.setSize(nTotalPatches); patchDicts.setSize(nTotalPatches); for (label pI = nNonProcPatches; pI < nTotalPatches; ++pI) { @@ -2130,20 +2127,24 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo { if (procUsed[pUI]) { - patchTypes[nNonProcPatches + procAddI] = - processorPolyPatch::typeName; - patchNames[nNonProcPatches + procAddI] = "procBoundary" + name(Pstream::myProcNo()) + "to" + name(pUI); + patchDicts[nNonProcPatches + procAddI].set + ( + "type", + processorPolyPatch::typeName + ); + patchDicts[nNonProcPatches + procAddI].set ( "myProcNo", Pstream::myProcNo() ); + patchDicts[nNonProcPatches + procAddI].set("neighbProcNo", pUI); procAddI++; @@ -2221,7 +2222,6 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches faceList& faces, labelList& owner, labelList& neighbour, - wordList& patchTypes, wordList& patchNames, PtrList& patchDicts, labelListList& patchPointPairSlaves, @@ -2232,7 +2232,6 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches const label defaultPatchIndex = createPatchInfo ( patchNames, - patchTypes, patchDicts ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index 3cef2304d6..4c584fd4b5 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -371,7 +371,6 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) faceList faces; labelList owner; labelList neighbour; - wordList patchTypes; wordList patchNames; PtrList patchDicts; pointField cellCentres; @@ -385,7 +384,6 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) faces, owner, neighbour, - patchTypes, patchNames, patchDicts, cellCentres, @@ -405,7 +403,6 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) faces, owner, neighbour, - patchTypes, patchNames, patchDicts, cellCentres, @@ -669,7 +666,6 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) Foam::autoPtr Foam::conformalVoronoiMesh::createDummyMesh ( const IOobject& io, - const wordList& patchTypes, const wordList& patchNames, const PtrList& patchDicts ) const @@ -690,7 +686,14 @@ Foam::autoPtr Foam::conformalVoronoiMesh::createDummyMesh forAll(patches, patchI) { - if (patchTypes[patchI] == processorPolyPatch::typeName) + if + ( + patchDicts.set(patchI) + && ( + word(patchDicts[patchI].lookup("type")) + == processorPolyPatch::typeName + ) + ) { patches[patchI] = new processorPolyPatch ( @@ -708,7 +711,7 @@ Foam::autoPtr Foam::conformalVoronoiMesh::createDummyMesh { patches[patchI] = polyPatch::New ( - patchTypes[patchI], + patchDicts[patchI].lookup("type"), patchNames[patchI], 0, //patchSizes[p], 0, //patchStarts[p], @@ -726,7 +729,6 @@ Foam::autoPtr Foam::conformalVoronoiMesh::createDummyMesh void Foam::conformalVoronoiMesh::checkProcessorPatchesMatch ( - const wordList& patchTypes, const PtrList& patchDicts ) const { @@ -737,9 +739,16 @@ void Foam::conformalVoronoiMesh::checkProcessorPatchesMatch labelList(Pstream::nProcs(), -1) ); - forAll(patchTypes, patchI) + forAll(patchDicts, patchI) { - if (patchTypes[patchI] == processorPolyPatch::typeName) + if + ( + patchDicts.set(patchI) + && ( + word(patchDicts[patchI].lookup("type")) + == processorPolyPatch::typeName + ) + ) { const label procNeighb = readLabel(patchDicts[patchI].lookup("neighbProcNo")); @@ -848,7 +857,6 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches const fileName& instance, const pointField& points, faceList& faces, - const wordList& patchTypes, const wordList& patchNames, const PtrList& patchDicts ) const @@ -856,7 +864,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches Info<< incrIndent << indent << "Reordering processor patches" << endl; Info<< incrIndent; - checkProcessorPatchesMatch(patchTypes, patchDicts); + checkProcessorPatchesMatch(patchDicts); // Create dummy mesh with correct proc boundaries to do sorting autoPtr sortMeshPtr @@ -872,7 +880,6 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches IOobject::NO_WRITE, false ), - patchTypes, patchNames, patchDicts ) @@ -1034,7 +1041,6 @@ void Foam::conformalVoronoiMesh::writeMesh faceList& faces, labelList& owner, labelList& neighbour, - const wordList& patchTypes, const wordList& patchNames, const PtrList& patchDicts, const pointField& cellCentres, @@ -1058,7 +1064,6 @@ void Foam::conformalVoronoiMesh::writeMesh instance, points, faces, - patchTypes, patchNames, patchDicts ); @@ -1094,7 +1099,14 @@ void Foam::conformalVoronoiMesh::writeMesh { label totalPatchSize = readLabel(patchDicts[p].lookup("nFaces")); - if (patchTypes[p] == processorPolyPatch::typeName) + if + ( + patchDicts.set(p) + && ( + word(patchDicts[p].lookup("type")) + == processorPolyPatch::typeName + ) + ) { const_cast(patchDicts[p]).set ( @@ -1112,7 +1124,7 @@ void Foam::conformalVoronoiMesh::writeMesh patchDicts[p], nValidPatches, mesh.boundaryMesh(), - patchTypes[p] + processorPolyPatch::typeName ); nValidPatches++; @@ -1127,7 +1139,6 @@ void Foam::conformalVoronoiMesh::writeMesh { patches[nValidPatches] = polyPatch::New ( - patchTypes[p], patchNames[p], patchDicts[p], nValidPatches, diff --git a/src/dynamicMesh/polyMeshFilter/polyMeshFilterSettings.C b/src/dynamicMesh/polyMeshFilter/polyMeshFilterSettings.C new file mode 100644 index 0000000000..fd3076d26b --- /dev/null +++ b/src/dynamicMesh/polyMeshFilter/polyMeshFilterSettings.C @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 "polyMeshFilterSettings.H" +#include "unitConversion.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::polyMeshFilterSettings::polyMeshFilterSettings(const dictionary& dict) +: + dict_(dict), + controlMeshQuality_ + ( + dict_.lookupOrDefault("controlMeshQuality", false) + ), + collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")), + collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")), + meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")), + minLen_(readScalar(collapseEdgesCoeffDict_.lookup("minimumEdgeLength"))), + maxCos_ + ( + ::cos + ( + degToRad + ( + readScalar(collapseEdgesCoeffDict_.lookup("maximumMergeAngle")) + ) + ) + ), + edgeReductionFactor_ + ( + meshQualityCoeffDict_.lookupOrDefault("edgeReductionFactor", -1) + ), + maxIterations_ + ( + meshQualityCoeffDict_.lookupOrAddDefault