diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index f67363ce3..eeae861d5 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -412,7 +412,7 @@ bool limitRefinementLevel } } - if (addCutCells.size() > 0) + if (addCutCells.size()) { // Add cells to cutCells. @@ -478,7 +478,7 @@ void doRefinement { const labelList& added = addedCells[oldCellI]; - if (added.size() > 0) + if (added.size()) { // Give all cells resulting from split the refinement level // of the master. @@ -894,7 +894,7 @@ int main(int argc, char *argv[]) << " Selected for refinement :" << cutCells.size() << nl << endl; - if (cutCells.size() == 0) + if (cutCells.empty()) { Info<< "Stopping refining since 0 cells selected to be refined ..." << nl << endl; diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMeshDict b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMeshDict index e6a15b2d5..d2d9941d6 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMeshDict +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMeshDict @@ -1,33 +1,26 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.0 | -| \\ / A nd | Web: http://www.openfoam.org | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam"; - case "cavity"; - instance "system"; - local ""; - - class dictionary; - object autoRefineMeshDict; + version 2.0; + format ascii; + class dictionary; + object autoRefineMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Surface to keep to -surface "plexi.ftr"; +surface "plexi.ftr"; // What is outside. These points have to be inside a cell (so not on a face!) -outsidePoints ((-0.99001 -0.99001 -0.99001)); +outsidePoints ((-0.99001 -0.99001 -0.99001)); // @@ -51,11 +44,11 @@ curvature 0.9; nCutLayers 2; // Refine until smallest edge of mesh < minEdgeLen -minEdgeLen 0.1; +minEdgeLen 0.1; // Or until the number of cells would become more than (stops one level before // this) -cellLimit 2500000; +cellLimit 2500000; // @@ -111,16 +104,16 @@ directions // refinement level difference between neighbouring cells. Set to large if // there is no need for a limit. -splitLevel 2; +splitLevel 2; // Cut purely geometric (will cut hexes through vertices) or take topology // into account. -geometricCut false; +geometricCut false; // Whether to use hex topology. This will never cut hex through vertices. -useHexTopology yes; +useHexTopology yes; // Write meshes from intermediate steps -writeMesh true; +writeMesh true; // ************************************************************************* // diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C index a318796b9..cf6e1a9d4 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C @@ -47,7 +47,7 @@ Description #include "polyMesh.H" #include "mapPolyMesh.H" #include "mathematicalConstants.H" -#include "PackedList.H" +#include "PackedBoolList.H" #include "SortableList.H" using namespace Foam; @@ -73,20 +73,17 @@ labelList getSortedEdges const edge& e = edges[edgeI]; label fp = findIndex(f, e[0]); - - label fp1 = (fp+1) % f.size(); + label fp1 = f.fcIndex(fp); if (f[fp1] == e[1]) { - // Edgei in fp-fp1 order + // EdgeI between fp -> fp1 faceEdges[fp] = edgeI; } else { - // Edgei between fp-1 and fp - label fpMin1 = (fp == 0 ? f.size()-1 : fp-1); - - faceEdges[fpMin1] = edgeI; + // EdgeI between fp-1 -> fp + faceEdges[f.rcIndex(fp)] = edgeI; } } @@ -176,7 +173,7 @@ label mergeEdges // Return master point edge needs to be collapsed to (or -1) -label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e) +label edgeMaster(const PackedBoolList& boundaryPoint, const edge& e) { label masterPoint = -1; @@ -214,7 +211,7 @@ label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e) label collapseSmallEdges ( const polyMesh& mesh, - const PackedList<1>& boundaryPoint, + const PackedBoolList& boundaryPoint, const scalar minLen, edgeCollapser& collapser ) @@ -253,7 +250,7 @@ label collapseSmallEdges label collapseHighAspectFaces ( const polyMesh& mesh, - const PackedList<1>& boundaryPoint, + const PackedBoolList& boundaryPoint, const scalar areaFac, const scalar edgeRatio, edgeCollapser& collapser @@ -345,7 +342,7 @@ void set(const labelList& elems, const bool val, boolList& status) label simplifyFaces ( const polyMesh& mesh, - const PackedList<1>& boundaryPoint, + const PackedBoolList& boundaryPoint, const label minSize, const scalar lenGap, edgeCollapser& collapser @@ -461,13 +458,15 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" + runTime.functionObjects().off(); # include "createPolyMesh.H" + const word oldInstance = mesh.pointsInstance(); scalar minLen(readScalar(IStringStream(args.additionalArgs()[0])())); scalar angle(readScalar(IStringStream(args.additionalArgs()[1])())); - bool overwrite = args.options().found("overwrite"); + bool overwrite = args.optionFound("overwrite"); - scalar maxCos = Foam::cos(angle*180/mathematicalConstant::pi); + scalar maxCos = Foam::cos(angle*mathematicalConstant::pi/180.0); Info<< "Merging:" << nl << " edges with length less than " << minLen << " meters" << nl @@ -483,7 +482,7 @@ int main(int argc, char *argv[]) const faceList& faces = mesh.faces(); // Get all points on the boundary - PackedList<1> boundaryPoint(mesh.nPoints(), false); + PackedBoolList boundaryPoint(mesh.nPoints()); label nIntFaces = mesh.nInternalFaces(); for (label faceI = nIntFaces; faceI < mesh.nFaces(); faceI++) @@ -585,8 +584,12 @@ int main(int argc, char *argv[]) { runTime++; } + else + { + mesh.setInstance(oldInstance); + } - Info << "Writing collapsed mesh to time " << runTime.value() << endl; + Info<< "Writing collapsed mesh to time " << runTime.timeName() << endl; mesh.write(); } diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index 18048cfb9..99af2c373 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -123,8 +123,9 @@ void checkSnapMesh Pout<< "Checking face angles" << endl; label nOldSize = wrongFaces.size(); - mesh.checkFaceAngles(false, &wrongFaces); - Pout<< "Detected additional concave " << wrongFaces.size() - nOldSize + mesh.checkFaceAngles(false, maxConcave, &wrongFaces); + Pout<< "Detected additional " << wrongFaces.size() - nOldSize + << " faces with concavity > " << maxConcave << " degrees" << endl; } @@ -176,7 +177,7 @@ label mergePatchFaces List allFaceSetsFaces(allFaceSets.size()); forAll(allFaceSets, setI) { - allFaceSetsFaces[setI] = IndirectList + allFaceSetsFaces[setI] = UIndirectList ( mesh.faces(), allFaceSets[setI] @@ -438,26 +439,21 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" + runTime.functionObjects().off(); # include "createPolyMesh.H" + const word oldInstance = mesh.pointsInstance(); scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); scalar minCos = Foam::cos(featureAngle*mathematicalConstant::pi/180.0); scalar concaveAngle = defaultConcaveAngle; - - if (args.options().found("concaveAngle")) - { - concaveAngle = readScalar - ( - IStringStream(args.options()["concaveAngle"])() - ); - } + args.optionReadIfPresent("concaveAngle", concaveAngle); scalar concaveSin = Foam::sin(concaveAngle*mathematicalConstant::pi/180.0); - bool snapMeshDict = args.options().found("snapMesh"); - bool overwrite = args.options().found("overwrite"); + bool snapMeshDict = args.optionFound("snapMesh"); + bool overwrite = args.optionFound("overwrite"); Info<< "Merging all faces of a cell" << nl << " - which are on the same patch" << nl @@ -500,6 +496,11 @@ int main(int argc, char *argv[]) if (nChanged > 0) { + if (overwrite) + { + mesh.setInstance(oldInstance); + } + Info<< "Writing morphed mesh to time " << runTime.timeName() << endl; mesh.write(); diff --git a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C index 7a16ff5be..56ed5f7e8 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C +++ b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C @@ -211,7 +211,7 @@ void Foam::cellSplitter::setRefinement // Add other pyramids for (label i = 1; i < cFaces.size(); i++) - { + { label addedCellI = meshMod.setAction ( @@ -277,7 +277,7 @@ void Foam::cellSplitter::setRefinement label index = findIndex(f0, e[0]); - bool edgeInFaceOrder = (f0[(index+1) % f0.size()] == e[1]); + bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]); // Check if cellI is the face owner @@ -323,7 +323,7 @@ void Foam::cellSplitter::setRefinement label index = findIndex(f1, e[0]); - bool edgeInFaceOrder = (f1[(index+1) % f1.size()] == e[1]); + bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]); // Check if cellI is the face owner @@ -362,7 +362,7 @@ void Foam::cellSplitter::setRefinement } } } - + // // Update all existing faces for split owner or neighbour. @@ -441,7 +441,7 @@ void Foam::cellSplitter::setRefinement label patchID, zoneID, zoneFlip; getFaceInfo(faceI, patchID, zoneID, zoneFlip); - + meshMod.setAction ( polyModifyFace @@ -458,7 +458,7 @@ void Foam::cellSplitter::setRefinement ) ); } - + faceUpToDate[faceI] = true; } } diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C index 87a395d73..f6f27590f 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C +++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C @@ -332,9 +332,11 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" + runTime.functionObjects().off(); # include "createPolyMesh.H" + const word oldInstance = mesh.pointsInstance(); - bool overwrite = args.options().found("overwrite"); + bool overwrite = args.optionFound("overwrite"); Info<< "Reading modifyMeshDict\n" << endl; @@ -357,18 +359,21 @@ int main(int argc, char *argv[]) ( dict.lookup("facesToTriangulate") ); + bool cutBoundary = - pointsToMove.size() > 0 - || edgesToSplit.size() > 0 - || facesToTriangulate.size() > 0; + ( + pointsToMove.size() + || edgesToSplit.size() + || facesToTriangulate.size() + ); List > edgesToCollapse(dict.lookup("edgesToCollapse")); - bool collapseEdge = edgesToCollapse.size() > 0; + bool collapseEdge = edgesToCollapse.size(); List > cellsToPyramidise(dict.lookup("cellsToSplit")); - bool cellsToSplit = cellsToPyramidise.size() > 0; + bool cellsToSplit = cellsToPyramidise.size(); //List > // cellsToCreate(dict.lookup("cellsToCreate")); @@ -522,7 +527,7 @@ int main(int argc, char *argv[]) Info<< nl << "There was a problem in one of the inputs in the" << " dictionary. Not modifying mesh." << endl; } - else if (cellToPyrCentre.size() > 0) + else if (cellToPyrCentre.size()) { Info<< nl << "All input cells located. Modifying mesh." << endl; @@ -549,12 +554,16 @@ int main(int argc, char *argv[]) { runTime++; } + else + { + mesh.setInstance(oldInstance); + } // Write resulting mesh - Info << "Writing modified mesh to time " << runTime.value() << endl; + Info << "Writing modified mesh to time " << runTime.timeName() << endl; mesh.write(); } - else if (edgeToPos.size() > 0) + else if (edgeToPos.size()) { Info<< nl << "All input edges located. Modifying mesh." << endl; @@ -598,9 +607,13 @@ int main(int argc, char *argv[]) { runTime++; } + else + { + mesh.setInstance(oldInstance); + } // Write resulting mesh - Info << "Writing modified mesh to time " << runTime.value() << endl; + Info << "Writing modified mesh to time " << runTime.timeName() << endl; mesh.write(); } else @@ -637,9 +650,13 @@ int main(int argc, char *argv[]) { runTime++; } + else + { + mesh.setInstance(oldInstance); + } // Write resulting mesh - Info << "Writing modified mesh to time " << runTime.value() << endl; + Info << "Writing modified mesh to time " << runTime.timeName() << endl; mesh.write(); } diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMeshDict b/applications/utilities/mesh/advanced/modifyMesh/modifyMeshDict index 7ddbdf555..f2cf26169 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/modifyMeshDict +++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMeshDict @@ -1,23 +1,16 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.0 | -| \\ / A nd | Web: http://www.openfoam.org | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root "/home/penfold/mattijs/foam/mattijs2.2/run/icoFoam"; - case "cavityTut"; - instance "system"; - local ""; - - class dictionary; - object modifyMeshDict; + version 2.0; + format ascii; + class dictionary; + object modifyMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C index 952ac83bf..d9cc48307 100644 --- a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C +++ b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Hex 2x2x2 refiner + Refines a hex mesh by 2x2x2 cell splitting. \*---------------------------------------------------------------------------*/ @@ -56,11 +56,14 @@ int main(int argc, char *argv[]) argList::validArgs.append("cellSet"); # include "setRootCase.H" # include "createTime.H" + runTime.functionObjects().off(); # include "createMesh.H" + const word oldInstance = mesh.pointsInstance(); + pointMesh pMesh(mesh); word cellSetName(args.args()[1]); - bool overwrite = args.options().found("overwrite"); + bool overwrite = args.optionFound("overwrite"); Info<< "Reading cells to refine from cellSet " << cellSetName << nl << endl; @@ -176,6 +179,11 @@ int main(int argc, char *argv[]) Pout<< "Refined from " << returnReduce(map().nOldCells(), sumOp