/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2010-2010 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 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 "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& firstLayerDisp, const scalar expansionRatio, const label nLayers, const labelList& topPatchID, const labelList& bottomPatchID, const labelListList& extrudeEdgePatches, polyTopoChange& meshMod ) { if (firstLayerDisp.size() != regionPoints_.size()) { FatalErrorIn("createShellMesh::setRefinement(..)") << "nRegions:" << regionPoints_.size() << " firstLayerDisp:" << firstLayerDisp.size() << exit(FatalError); } if ( topPatchID.size() != patch_.size() && bottomPatchID.size() != patch_.size() ) { FatalErrorIn("createShellMesh::setRefinement(..)") << "nFaces:" << patch_.size() << " topPatchID:" << topPatchID.size() << " bottomPatchID:" << bottomPatchID.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