From f53f614c430264d69c29295921bf40dabfbf370d Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 24 Apr 2008 13:16:10 +0100 Subject: [PATCH] Initial autoMesh merge --- .../mesh/conversion/plot3dToFoam/hexBlock.C | 52 +- .../mesh/conversion/plot3dToFoam/hexBlock.H | 9 +- .../conversion/plot3dToFoam/plot3dToFoam.C | 46 +- .../manipulation/Optional/setSet/setSet.C | 57 +- .../couplePatches/FoamX/couplePatches.cfg | 27 - .../manipulation/couplePatches/Make/files | 3 - .../manipulation/couplePatches/Make/options | 7 - .../couplePatches/couplePatches.C | 160 - src/Allwmake | 2 + .../containers/Lists/ListOps/ListOps.H | 48 +- .../Lists/ListOps/ListOpsTemplates.C | 96 +- src/autoMesh/Make/files | 18 + src/autoMesh/Make/options | 21 + .../autoHexMeshDriver/autoHexMeshDriver.C | 1604 +++++++++ .../autoHexMeshDriver/autoHexMeshDriver.H | 810 +++++ .../autoHexMeshDriverLayers.C | 2999 +++++++++++++++++ .../autoHexMeshDriverShrink.C | 1151 +++++++ .../autoHexMeshDriver/autoHexMeshDriverSnap.C | 1196 +++++++ .../autoHexMeshDriverTemplates.C | 75 + .../autoHexMeshDriver/pointData/pointData.C | 53 + .../autoHexMeshDriver/pointData/pointData.H | 228 ++ .../autoHexMeshDriver/pointData/pointDataI.H | 356 ++ .../meshRefinement/meshRefinement.C | 2011 +++++++++++ .../meshRefinement/meshRefinement.H | 667 ++++ .../meshRefinement/meshRefinementBaffles.C | 2719 +++++++++++++++ .../meshRefinement/meshRefinementMerge.C | 230 ++ .../meshRefinement/meshRefinementRefine.C | 1360 ++++++++ .../meshRefinement/meshRefinementTemplates.C | 195 ++ .../offsetTriSurfaceMesh.C | 199 ++ .../offsetTriSurfaceMesh.H | 167 + .../refinementSurfaces/refinementSurfaces.C | 503 +++ .../refinementSurfaces/refinementSurfaces.H | 279 ++ .../trackedParticle/ExactParticle.C | 263 ++ .../trackedParticle/ExactParticle.H | 193 ++ .../autoHexMesh/trackedParticle/Particle.H | 431 +++ .../trackedParticle/trackedParticle.C | 261 ++ .../trackedParticle/trackedParticle.H | 276 ++ .../trackedParticle/trackedParticleCloud.C | 44 + 38 files changed, 18566 insertions(+), 250 deletions(-) delete mode 100644 applications/utilities/mesh/manipulation/couplePatches/FoamX/couplePatches.cfg delete mode 100644 applications/utilities/mesh/manipulation/couplePatches/Make/files delete mode 100644 applications/utilities/mesh/manipulation/couplePatches/Make/options delete mode 100644 applications/utilities/mesh/manipulation/couplePatches/couplePatches.C create mode 100644 src/autoMesh/Make/files create mode 100644 src/autoMesh/Make/options create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.H create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriverLayers.C create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriverShrink.C create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriverSnap.C create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriverTemplates.C create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.C create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H create mode 100644 src/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointDataI.H create mode 100644 src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C create mode 100644 src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H create mode 100644 src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C create mode 100644 src/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C create mode 100644 src/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C create mode 100644 src/autoMesh/autoHexMesh/meshRefinement/meshRefinementTemplates.C create mode 100644 src/autoMesh/autoHexMesh/offsetTriSurfaceMesh/offsetTriSurfaceMesh.C create mode 100644 src/autoMesh/autoHexMesh/offsetTriSurfaceMesh/offsetTriSurfaceMesh.H create mode 100644 src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C create mode 100644 src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H create mode 100644 src/autoMesh/autoHexMesh/trackedParticle/ExactParticle.C create mode 100644 src/autoMesh/autoHexMesh/trackedParticle/ExactParticle.H create mode 100644 src/autoMesh/autoHexMesh/trackedParticle/Particle.H create mode 100644 src/autoMesh/autoHexMesh/trackedParticle/trackedParticle.C create mode 100644 src/autoMesh/autoHexMesh/trackedParticle/trackedParticle.H create mode 100644 src/autoMesh/autoHexMesh/trackedParticle/trackedParticleCloud.C diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.C b/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.C index 7a5ebd43c7..5a1b39cd78 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.C +++ b/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.C @@ -87,7 +87,7 @@ void hexBlock::setHandedness() if (blockHandedness_ == noPoints) { - WarningIn("hexBlock::readPoints(const bool, Istream&)") + WarningIn("hexBlock::hexBlock::setHandedness()") << "Cannot determine orientation of block." << " Continuing as if right handed." << endl; blockHandedness_ = right; @@ -105,35 +105,67 @@ hexBlock::hexBlock(const label nx, const label ny, const label nz) zDim_(nz - 1), blockHandedness_(noPoints), points_((xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1)) -{ - Pout<< "xDim:" << nx << " yDim:" << ny << " zDim:" << nz << endl; -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void hexBlock::readPoints(const bool readBlank, Istream& is) +void hexBlock::readPoints +( + const bool readBlank, + const scalar twoDThicknes, + Istream& is +) { scalar iBlank; - forAll (points_, i) + label nPoints = points_.size(); + + if (twoDThicknes > 0) + { + nPoints /= 2; + } + + Info<< "Reading " << nPoints << " x coordinates..." << endl; + for (label i=0; i < nPoints; i++) { is >> points_[i].x(); } - forAll (points_, i) + Info<< "Reading " << nPoints << " y coordinates..." << endl; + for (label i=0; i < nPoints; i++) { is >> points_[i].y(); } - forAll (points_, i) + if (twoDThicknes > 0) { - is >> points_[i].z(); + Info<< "Extruding " << nPoints << " points in z direction..." << endl; + // Duplicate points + for (label i=0; i < nPoints; i++) + { + points_[i+nPoints] = points_[i]; + } + for (label i=0; i < nPoints; i++) + { + points_[i].z() = 0; + points_[i+nPoints].z() = twoDThicknes; + } } + else + { + Info<< "Reading " << nPoints << " z coordinates..." << endl; + for (label i=0; i < nPoints; i++) + { + is >> points_[i].z(); + } + } + if (readBlank) { - forAll (points_, i) + Info<< "Reading " << nPoints << " blanks..." << endl; + for (label i=0; i < nPoints; i++) { is >> iBlank; } diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.H b/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.H index 2adfe841ef..38763c8e93 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.H +++ b/applications/utilities/mesh/conversion/plot3dToFoam/hexBlock.H @@ -145,7 +145,14 @@ public: //- Read block points either with or without blanking after every block. - void readPoints(const bool readBlank, Istream&); + // If twoDThickness > 0 reads (half) the points and extrudes the + // points in z direction. + void readPoints + ( + const bool readBlank, + const scalar twoDThicknes, + Istream& + ); }; diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C index 0c7254b2a0..4c503a932a 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C +++ b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C @@ -23,11 +23,12 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Plot3d mesh (ascii format) converter. + Plot3d mesh (ascii/formatted format) converter. Work in progress! Handles ascii multiblock (and optionally singleBlock) format. By default expects blanking. Use -noBlank if none. + Use -2D if 2D. Niklas Nordin has experienced a problem with lefthandedness of the blocks. The code should detect this automatically - see hexBlock::readPoints but if this goes wrong just set the blockHandedness_ variable to 'right' @@ -59,6 +60,7 @@ int main(int argc, char *argv[]) argList::validOptions.insert("scale", "scale factor"); argList::validOptions.insert("noBlank", ""); argList::validOptions.insert("singleBlock", ""); + argList::validOptions.insert("2D", "thickness"); argList args(argc, argv); @@ -75,6 +77,13 @@ int main(int argc, char *argv[]) bool readBlank = !args.options().found("noBlank"); bool singleBlock = args.options().found("singleBlock"); + scalar twoDThicknes = -1; + if (args.options().found("2D")) + { + twoDThicknes = readScalar(IStringStream(args.options()["2D"])()); + Info<< "Reading 2D case by extruding points by " << twoDThicknes + << " in z direction." << nl << endl; + } # include "createTime.H" @@ -95,7 +104,7 @@ int main(int argc, char *argv[]) plot3dFile >> nblock; } - Info << "Reading " << nblock << " blocks" << endl; + Info<< "Reading " << nblock << " blocks" << endl; PtrList blocks(nblock); @@ -104,20 +113,32 @@ int main(int argc, char *argv[]) forAll (blocks, blockI) { - plot3dFile >> nx >> ny >> nz; + if (twoDThicknes > 0) + { + // Fake second set of points (done in readPoints below) + plot3dFile >> nx >> ny; + nz = 2; + } + else + { + plot3dFile >> nx >> ny >> nz; + } + + Info<< "block " << blockI << " nx:" << nx + << " ny:" << ny << " nz:" << nz << endl; blocks.set(blockI, new hexBlock(nx, ny, nz)); } } - Info << "Reading block points" << endl; + Info<< "Reading block points" << endl; label sumPoints(0); label nMeshCells(0); forAll (blocks, blockI) { - Info << "block " << blockI << ":" << nl; - blocks[blockI].readPoints(readBlank, plot3dFile); + Info<< "block " << blockI << ":" << nl; + blocks[blockI].readPoints(readBlank, twoDThicknes, plot3dFile); sumPoints += blocks[blockI].nBlockPoints(); nMeshCells += blocks[blockI].nBlockCells(); Info<< nl; @@ -136,7 +157,6 @@ int main(int argc, char *argv[]) } } - // From old to new master point labelList oldToNew; pointField newPoints; @@ -151,13 +171,17 @@ int main(int argc, char *argv[]) newPoints ); + Info<< "Merged points within " << SMALL << " distance. Merged from " + << oldToNew.size() << " down to " << newPoints.size() + << " points." << endl; + // Scale the points if (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL) { newPoints *= scaleFactor; } - Info << "Creating cells" << endl; + Info<< "Creating cells" << endl; cellShapeList cellShapes(nMeshCells); @@ -190,7 +214,7 @@ int main(int argc, char *argv[]) } } - Info << "Creating boundary patches" << endl; + Info<< "Creating boundary patches" << endl; faceListList boundary(0); wordList patchNames(0); @@ -220,10 +244,10 @@ int main(int argc, char *argv[]) // Set the precision of the points data to 10 IOstream::defaultPrecision(10); - Info << "Writing polyMesh" << endl; + Info<< "Writing polyMesh" << endl; pShapeMesh.write(); - Info << "End\n" << endl; + Info<< "End\n" << endl; return 0; } diff --git a/applications/utilities/mesh/manipulation/Optional/setSet/setSet.C b/applications/utilities/mesh/manipulation/Optional/setSet/setSet.C index 2df4dd88ae..64dd8c1ca7 100644 --- a/applications/utilities/mesh/manipulation/Optional/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/Optional/setSet/setSet.C @@ -42,6 +42,7 @@ Description #include "demandDrivenData.H" #include "writePatch.H" #include "writePointSet.H" +#include "IOobjectList.H" #include @@ -233,8 +234,10 @@ void writeVTK void printHelp(Ostream& os) { - os << "Please type 'help', 'quit', 'time ddd'" + os << "Please type 'help', 'list', 'quit', 'time ddd'" << " or a set command after prompt." << endl + << "'list' will show all current cell/face/point sets." << endl + << "'time ddd' will change the current time." << endl << endl << "A set command should be of the following form" << endl << endl @@ -272,6 +275,47 @@ void printHelp(Ostream& os) } +void printAllSets(const polyMesh& mesh, Ostream& os) +{ + IOobjectList objects + ( + mesh, + mesh.pointsInstance(), + polyMesh::meshSubDir/"sets" + ); + IOobjectList cellSets(objects.lookupClass(cellSet::typeName)); + if (cellSets.size() > 0) + { + os << "cellSets:" << endl; + forAllConstIter(IOobjectList, cellSets, iter) + { + cellSet set(*iter()); + os << '\t' << set.name() << "\tsize:" << set.size() << endl; + } + } + IOobjectList faceSets(objects.lookupClass(faceSet::typeName)); + if (faceSets.size() > 0) + { + os << "faceSets:" << endl; + forAllConstIter(IOobjectList, faceSets, iter) + { + faceSet set(*iter()); + os << '\t' << set.name() << "\tsize:" << set.size() << endl; + } + } + IOobjectList pointSets(objects.lookupClass(pointSet::typeName)); + if (pointSets.size() > 0) + { + os << "pointSets:" << endl; + forAllConstIter(IOobjectList, pointSets, iter) + { + pointSet set(*iter()); + os << '\t' << set.name() << "\tsize:" << set.size() << endl; + } + } + os << endl; +} + // Read command and execute. Return true if ok, false otherwise. bool doCommand @@ -531,6 +575,12 @@ commandStatus parseType return INVALID; } + else if (setType == "list") + { + printAllSets(mesh, Pout); + + return INVALID; + } else if (setType == "time") { scalar time = readScalar(is); @@ -612,8 +662,9 @@ commandStatus parseType ( "commandStatus parseType(Time&, polyMesh&, const word&" ", IStringStream&)" - ) << "Illegal set type " << setType << endl - << "Should be one of 'cellSet' 'faceSet' 'pointSet'" + ) << "Illegal command " << setType << endl + << "Should be one of 'help', 'list', 'time' or a set type :" + << " 'cellSet', 'faceSet', 'pointSet'" << endl; return INVALID; diff --git a/applications/utilities/mesh/manipulation/couplePatches/FoamX/couplePatches.cfg b/applications/utilities/mesh/manipulation/couplePatches/FoamX/couplePatches.cfg deleted file mode 100644 index 4265e8f37d..0000000000 --- a/applications/utilities/mesh/manipulation/couplePatches/FoamX/couplePatches.cfg +++ /dev/null @@ -1,27 +0,0 @@ -/*---------------------------------------------------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.0 | -| \\ / A nd | Web: http://www.openfoam.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -// couplePatches tool definition - -description "Utility to reorder face numbering for cyclic and processor patches"; - -couplePatchesDict -{ - type dictionary; - description "couplePatches control dictionary"; - dictionaryPath "system"; - - entries - { - arguments - { - type rootCaseArguments; - } - } -} - -// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/couplePatches/Make/files b/applications/utilities/mesh/manipulation/couplePatches/Make/files deleted file mode 100644 index a5f95c1a12..0000000000 --- a/applications/utilities/mesh/manipulation/couplePatches/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -couplePatches.C - -EXE = $(FOAM_APPBIN)/couplePatches diff --git a/applications/utilities/mesh/manipulation/couplePatches/Make/options b/applications/utilities/mesh/manipulation/couplePatches/Make/options deleted file mode 100644 index 73f34b0f85..0000000000 --- a/applications/utilities/mesh/manipulation/couplePatches/Make/options +++ /dev/null @@ -1,7 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/dynamicMesh/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -EXE_LIBS = \ - -ldynamicMesh \ - -lmeshTools diff --git a/applications/utilities/mesh/manipulation/couplePatches/couplePatches.C b/applications/utilities/mesh/manipulation/couplePatches/couplePatches.C deleted file mode 100644 index 004e44adb3..0000000000 --- a/applications/utilities/mesh/manipulation/couplePatches/couplePatches.C +++ /dev/null @@ -1,160 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - Utility to reorder cyclic and processor patches. - - Uses dummy morph to sort things out. - - Is bit of hack since polyMesh constructor already checks for coupled - face areas so might bomb out. You might need to compile in a local - processorPolyPatch that gives a warning instead to make this utility - complete. - -\*---------------------------------------------------------------------------*/ - -#include "argList.H" -#include "polyMesh.H" -#include "Time.H" -#include "polyTopoChange.H" -#include "mapPolyMesh.H" -#include "OFstream.H" -#include "coupledPolyPatch.H" -#include "PstreamReduceOps.H" - -using namespace Foam; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Main program: - -int main(int argc, char *argv[]) -{ -# include "setRootCase.H" -# include "createTime.H" -# include "createPolyMesh.H" - - Info<< "Using geometry to calculate face correspondence across" - << " coupled boundaries (processor, cyclic)" << nl - << "This will only work for cyclics if they are parallel or" - << " their rotation is defined across the origin" << nl - << endl; - - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - bool hasCoupled = false; - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - hasCoupled = true; - - break; - } - } - - reduce(hasCoupled, orOp()); - - if (hasCoupled) - { - Info<< "Mesh has coupled patches ..." << nl << endl; - - // Dummy topo changes container - polyTopoChange meshMod(mesh); - - // Do all changes - Info<< "Doing dummy mesh morph to correct face ordering ..." - << endl; - - runTime++; - - faceList oldFaces(mesh.faces()); - - autoPtr morphMap = meshMod.changeMesh(mesh, false); - - // Update fields - mesh.updateMesh(morphMap); - - // Move mesh (since morphing does not do this) - if (morphMap().hasMotionPoints()) - { - mesh.movePoints(morphMap().preMotionPoints()); - } - - // Find out if anything changed. - // Problem is that - if the topo change is only rotation - - // face::operator= does not detect a change so use labelList::operator= - bool meshChanged = false; - - if (mesh.faces().size() != oldFaces.size()) - { - meshChanged = true; - } - else - { - forAll(mesh.faces(), faceI) - { - const labelList& f = mesh.faces()[faceI]; - const labelList& oldF = oldFaces[faceI]; - - if (f != oldF) - { - meshChanged = true; - break; - } - } - } - - reduce(meshChanged, orOp