/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright held by original author \\/ 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 Create polyMesh from cell and patch shapes \*---------------------------------------------------------------------------*/ #include "polyMesh.H" #include "Time.H" #include "primitiveMesh.H" #include "DynamicList.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::labelListList Foam::polyMesh::cellShapePointCells ( const cellShapeList& c ) const { List > pc(points().size()); // For each cell forAll(c, i) { // For each vertex const labelList& labels = c[i]; forAll(labels, j) { // Set working point label label curPoint = labels[j]; DynamicList& curPointCells = pc[curPoint]; // Enter the cell label in the point's cell list curPointCells.append(i); } } labelListList pointCellAddr(pc.size()); forAll (pc, pointI) { pointCellAddr[pointI].transfer(pc[pointI].shrink()); } return pointCellAddr; } Foam::labelList Foam::polyMesh::facePatchFaceCells ( const faceList& patchFaces, const labelListList& pointCells, const faceListList& cellsFaceShapes, const label patchID ) const { register bool found; labelList FaceCells(patchFaces.size()); forAll(patchFaces, fI) { found = false; const face& curFace = patchFaces[fI]; const labelList& facePoints = patchFaces[fI]; forAll(facePoints, pointI) { const labelList& facePointCells = pointCells[facePoints[pointI]]; forAll(facePointCells, cellI) { faceList cellFaces = cellsFaceShapes[facePointCells[cellI]]; forAll(cellFaces, cellFace) { if (cellFaces[cellFace] == curFace) { // Found the cell corresponding to this face FaceCells[fI] = facePointCells[cellI]; found = true; } if (found) break; } if (found) break; } if (found) break; } if (!found) { FatalErrorIn ( "polyMesh::facePatchFaceCells(const faceList& patchFaces," "const labelListList& pointCells," "const faceListList& cellsFaceShapes," "const label patchID)" ) << "face " << fI << " in patch " << patchID << " does not have neighbour cell" << " face: " << patchFaces[fI] << abort(FatalError); } } return FaceCells; } Foam::polyMesh::polyMesh ( const IOobject& io, const pointField& points, const cellShapeList& cellsAsShapes, const faceListList& boundaryFaces, const wordList& boundaryPatchNames, const wordList& boundaryPatchTypes, const word& defaultBoundaryPatchName, const word& defaultBoundaryPatchType, const wordList& boundaryPatchPhysicalTypes, const bool syncPar ) : objectRegistry(io), primitiveMesh(), allPoints_ ( IOobject ( "points", instance(), meshSubDir, *this, IOobject::NO_READ, IOobject::AUTO_WRITE ), points ), // To be re-sliced later. HJ, 19/oct/2008 points_(allPoints_, allPoints_.size()), allFaces_ ( IOobject ( "faces", instance(), meshSubDir, *this, IOobject::NO_READ, IOobject::AUTO_WRITE ), 0 ), faces_(allFaces_, allFaces_.size()), owner_ ( IOobject ( "owner", instance(), meshSubDir, *this, IOobject::NO_READ, IOobject::AUTO_WRITE ), 0 ), neighbour_ ( IOobject ( "neighbour", instance(), meshSubDir, *this, IOobject::NO_READ, IOobject::AUTO_WRITE ), 0 ), clearedPrimitives_(false), boundary_ ( IOobject ( "boundary", instance(), meshSubDir, *this, IOobject::NO_READ, IOobject::AUTO_WRITE ), *this, boundaryFaces.size() + 1 // add room for a default patch ), bounds_(allPoints_, syncPar), directions_(Vector