From 06d2dc9e4cb6960c5ed4c8ec144f715baf661c2c Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 17 Mar 2010 11:17:17 +0000 Subject: [PATCH] ENH: application to extrude a faceZone into a separate region mesh Extrudes either internal faces to inflate a baffle or extrudes boundary faces to create separate mesh. Inserts directMappedWall between the two meshes. --- .../generation/extrudeToRegionMesh/Make/files | 7 + .../extrudeToRegionMesh/Make/options | 14 + .../extrudeToRegionMesh/createShellMesh.C | 592 ++++++++ .../extrudeToRegionMesh/createShellMesh.H | 177 +++ .../extrudeToRegionMesh/extrudeToRegionMesh.C | 1334 +++++++++++++++++ .../patchPointEdgeCirculator.C | 68 + .../patchPointEdgeCirculator.H | 206 +++ .../patchPointEdgeCirculatorI.H | 309 ++++ 8 files changed, 2707 insertions(+) create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/Make/files create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/Make/options create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/createShellMesh.C create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/createShellMesh.H create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/extrudeToRegionMesh.C create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/patchPointEdgeCirculator.C create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/patchPointEdgeCirculator.H create mode 100644 applications/utilities/mesh/generation/extrudeToRegionMesh/patchPointEdgeCirculatorI.H diff --git a/applications/utilities/mesh/generation/extrudeToRegionMesh/Make/files b/applications/utilities/mesh/generation/extrudeToRegionMesh/Make/files new file mode 100644 index 0000000000..62431e23d4 --- /dev/null +++ b/applications/utilities/mesh/generation/extrudeToRegionMesh/Make/files @@ -0,0 +1,7 @@ +patchPointEdgeCirculator.C +createShellMesh.C +extrudeToRegionMesh.C + +EXE = $(FOAM_APPBIN)/extrudeToRegionMesh + + diff --git a/applications/utilities/mesh/generation/extrudeToRegionMesh/Make/options b/applications/utilities/mesh/generation/extrudeToRegionMesh/Make/options new file mode 100644 index 0000000000..dbf50a9b09 --- /dev/null +++ b/applications/utilities/mesh/generation/extrudeToRegionMesh/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + /* -I$(LIB_SRC)/surfMesh/lnInclude */ \ + /* -I$(LIB_SRC)/lagrangian/basic/lnInclude */ \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + /* -lsurfMesh */ \ + /* -llagrangian */ \ + -lmeshTools \ + -ldynamicMesh + diff --git a/applications/utilities/mesh/generation/extrudeToRegionMesh/createShellMesh.C b/applications/utilities/mesh/generation/extrudeToRegionMesh/createShellMesh.C new file mode 100644 index 0000000000..da1fc43066 --- /dev/null +++ b/applications/utilities/mesh/generation/extrudeToRegionMesh/createShellMesh.C @@ -0,0 +1,592 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +\*---------------------------------------------------------------------------*/ + +#include "createShellMesh.H" +#include "polyTopoChange.H" +#include "meshTools.H" +#include "mapPolyMesh.H" +#include "polyAddPoint.H" +#include "polyAddFace.H" +#include "polyModifyFace.H" +#include "polyAddCell.H" +#include "patchPointEdgeCirculator.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::createShellMesh, 0); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::createShellMesh::calcPointRegions +( + const primitiveFacePatch& patch, + const PackedBoolList& nonManifoldEdge, + faceList& pointRegions, + labelList& regionPoints +) +{ + pointRegions.setSize(patch.size()); + forAll(pointRegions, faceI) + { + const face& f = patch.localFaces()[faceI]; + pointRegions[faceI].setSize(f.size(), -1); + } + + label nRegions = 0; + + forAll(pointRegions, faceI) + { + const face& f = patch.localFaces()[faceI]; + + forAll(f, fp) + { + if (pointRegions[faceI][fp] == -1) + { + // Found unassigned point. Distribute current region. + label pointI = f[fp]; + label edgeI = patch.faceEdges()[faceI][fp]; + + patchPointEdgeCirculator circ + ( + patch, + nonManifoldEdge, + edgeI, + findIndex(patch.edgeFaces()[edgeI], faceI), + pointI + ); + + for + ( + patchPointEdgeCirculator iter = circ.begin(); + iter != circ.end(); + ++iter + ) + { + label face2 = iter.faceID(); + + if (face2 != -1) + { + const face& f2 = patch.localFaces()[face2]; + label fp2 = findIndex(f2, pointI); + label& region = pointRegions[face2][fp2]; + if (region != -1) + { + FatalErrorIn + ( + "createShellMesh::calcPointRegions(..)" + ) << "On point " << pointI + << " at:" << patch.localPoints()[pointI] + << " found region:" << region + << abort(FatalError); + } + region = nRegions; + } + } + + nRegions++; + } + } + } + + + // From region back to originating point (many to one, a point might + // have multiple regions though) + regionPoints.setSize(nRegions); + forAll(pointRegions, faceI) + { + const face& f = patch.localFaces()[faceI]; + + forAll(f, fp) + { + regionPoints[pointRegions[faceI][fp]] = f[fp]; + } + } + + + if (debug) + { + const labelListList& pointFaces = patch.pointFaces(); + forAll(pointFaces, pointI) + { + label region = -1; + const labelList& pFaces = pointFaces[pointI]; + forAll(pFaces, i) + { + label faceI = pFaces[i]; + const face& f = patch.localFaces()[faceI]; + label fp = findIndex(f, pointI); + + if (region == -1) + { + region = pointRegions[faceI][fp]; + } + else if (region != pointRegions[faceI][fp]) + { + Pout<< "Non-manifold point:" << pointI + << " at " << patch.localPoints()[pointI] + << " region:" << region + << " otherRegion:" << pointRegions[faceI][fp] + << endl; + + } + } + } + } +} + + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::createShellMesh::createShellMesh +( + const primitiveFacePatch& patch, + const faceList& pointRegions, + const labelList& regionPoints +) +: + patch_(patch), + pointRegions_(pointRegions), + regionPoints_(regionPoints) +{ + if (pointRegions_.size() != patch_.size()) + { + FatalErrorIn("createShellMesh::createShellMesh(..)") + << "nFaces:" << patch_.size() + << " pointRegions:" << pointRegions.size() + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +void Foam::createShellMesh::setRefinement +( + const pointField& thickness, + const labelList& extrudeMasterPatchID, + const labelList& extrudeSlavePatchID, + const labelListList& extrudeEdgePatches, + polyTopoChange& meshMod +) +{ + if (thickness.size() != regionPoints_.size()) + { + FatalErrorIn("createShellMesh::setRefinement(..)") + << "nRegions:" << regionPoints_.size() + << " thickness:" << thickness.size() + << exit(FatalError); + } + + if + ( + extrudeMasterPatchID.size() != patch_.size() + && extrudeSlavePatchID.size() != patch_.size() + ) + { + FatalErrorIn("createShellMesh::setRefinement(..)") + << "nFaces:" << patch_.size() + << " extrudeMasterPatchID:" << extrudeMasterPatchID.size() + << " extrudeSlavePatchID:" << extrudeSlavePatchID.size() + << exit(FatalError); + } + + if (extrudeEdgePatches.size() != patch_.nEdges()) + { + FatalErrorIn("createShellMesh::setRefinement(..)") + << "nEdges:" << patch_.nEdges() + << " extrudeEdgePatches:" << extrudeEdgePatches.size() + << exit(FatalError); + } + + + + // From cell to patch (trivial) + DynamicList