label addCellZone(const polyMesh& mesh, const word& name) { label zoneID = mesh.cellZones().findZoneID(name); if (zoneID != -1) { Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name() << " at index " << zoneID << endl; } else { cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh).cellZones(); zoneID = cellZones.size(); Info<< "Adding cellZone " << name << " at index " << zoneID << endl; cellZones.setSize(zoneID+1); cellZones.set ( zoneID, new cellZone ( name, labelList(0), zoneID, cellZones ) ); } return zoneID; }
Foam::sampledPlane::sampledPlane ( const word& name, const polyMesh& mesh, const dictionary& dict ) : sampledSurface(name, mesh, dict), cuttingPlane(plane(dict)), zoneKey_(keyType::null), triangulate_(dict.lookupOrDefault("triangulate", true)), needsUpdate_(true) { // Make plane relative to the coordinateSystem (Cartesian) // allow lookup from global coordinate systems if (dict.found("coordinateSystem")) { coordinateSystem cs(mesh, dict.subDict("coordinateSystem")); point base = cs.globalPosition(planeDesc().refPoint()); vector norm = cs.globalVector(planeDesc().normal()); // Assign the plane description static_cast<plane&>(*this) = plane(base, norm); } dict.readIfPresent("zone", zoneKey_); if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) { Info<< "cellZone " << zoneKey_ << " not found - using entire mesh" << endl; } }
Foam::sampledIsoSurface::sampledIsoSurface ( const word& name, const polyMesh& mesh, const dictionary& dict ) : sampledSurface(name, mesh, dict), isoField_(dict.lookup("isoField")), isoVal_(readScalar(dict.lookup("isoValue"))), mergeTol_(dict.lookupOrDefault("mergeTol", 1e-6)), regularise_(dict.lookupOrDefault("regularise", true)), average_(dict.lookupOrDefault("average", false)), zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()), exposedPatchName_(word::null), surfPtr_(NULL), facesPtr_(NULL), prevTimeIndex_(-1), storedVolFieldPtr_(NULL), volFieldPtr_(NULL), storedPointFieldPtr_(NULL), pointFieldPtr_(NULL) { if (!sampledSurface::interpolate()) { FatalIOErrorIn ( "sampledIsoSurface::sampledIsoSurface" "(const word&, const polyMesh&, const dictionary&)", dict ) << "Non-interpolated iso surface not supported since triangles" << " span across cells." << exit(FatalIOError); } if (zoneID_.index() != -1) { dict.lookup("exposedPatchName") >> exposedPatchName_; if (mesh.boundaryMesh().findPatchID(exposedPatchName_) == -1) { FatalIOErrorIn ( "sampledIsoSurface::sampledIsoSurface" "(const word&, const polyMesh&, const dictionary&)", dict ) << "Cannot find patch " << exposedPatchName_ << " in which to put exposed faces." << endl << "Valid patches are " << mesh.boundaryMesh().names() << exit(FatalIOError); } if (debug && zoneID_.index() != -1) { Info<< "Restricting to cellZone " << zoneID_.name() << " with exposed internal faces into patch " << exposedPatchName_ << endl; } }
Foam::sampledPlane::sampledPlane ( const word& name, const polyMesh& mesh, const plane& planeDesc, const keyType& zoneKey ) : sampledSurface(name, mesh), cuttingPlane(planeDesc), zoneKey_(zoneKey), needsUpdate_(true) { if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) { Info<< "cellZone " << zoneKey_ << " not found - using entire mesh" << endl; } }
Foam::sampledPlane::sampledPlane ( const word& name, const polyMesh& mesh, const plane& planeDesc, const word& zoneName ) : sampledSurface(name, mesh), cuttingPlane(planeDesc), zoneName_(zoneName), needsUpdate_(true) { if (debug && zoneName_.size()) { if (mesh.cellZones().findZoneID(zoneName_) < 0) { Info<< "cellZone \"" << zoneName_ << "\" not found - using entire mesh" << endl; } } }
Foam::sampledPlane::sampledPlane ( const word& name, const polyMesh& mesh, const dictionary& dict ) : sampledSurface(name, mesh, dict), cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))), zoneName_(word::null), needsUpdate_(true) { // make plane relative to the coordinateSystem (Cartesian) // allow lookup from global coordinate systems if (dict.found("coordinateSystem")) { coordinateSystem cs(dict, mesh); point base = cs.globalPosition(planeDesc().refPoint()); vector norm = cs.globalVector(planeDesc().normal()); // assign the plane description static_cast<plane&>(*this) = plane(base, norm); } dict.readIfPresent("zone", zoneName_); if (debug && zoneName_.size()) { if (mesh.cellZones().findZoneID(zoneName_) < 0) { Info<< "cellZone \"" << zoneName_ << "\" not found - using entire mesh" << endl; } } }
void Foam::meshReader::addCellZones(polyMesh& mesh) const { cellTable_.addCellZones(mesh, cellTableId_); warnDuplicates("cellZones", mesh.cellZones().names()); }
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) { Info<< "Mesh stats" << nl << " points: " << returnReduce(mesh.points().size(), sumOp<label>()) << nl; label nInternalPoints = returnReduce ( mesh.nInternalPoints(), sumOp<label>() ); if (nInternalPoints != -Pstream::nProcs()) { Info<< " internal points: " << nInternalPoints << nl; if (returnReduce(mesh.nInternalPoints(), minOp<label>()) == -1) { WarningIn("Foam::printMeshStats(const polyMesh&, const bool)") << "Some processors have their points sorted into internal" << " and external and some do not." << endl << "This can cause problems later on." << endl; } } if (allTopology && nInternalPoints != -Pstream::nProcs()) { label nEdges = returnReduce(mesh.nEdges(), sumOp<label>()); label nInternalEdges = returnReduce ( mesh.nInternalEdges(), sumOp<label>() ); label nInternal1Edges = returnReduce ( mesh.nInternal1Edges(), sumOp<label>() ); label nInternal0Edges = returnReduce ( mesh.nInternal0Edges(), sumOp<label>() ); Info<< " edges: " << nEdges << nl << " internal edges: " << nInternalEdges << nl << " internal edges using one boundary point: " << nInternal1Edges-nInternal0Edges << nl << " internal edges using two boundary points: " << nInternalEdges-nInternal1Edges << nl; } label nFaces = returnReduce(mesh.faces().size(), sumOp<label>()); label nIntFaces = returnReduce(mesh.faceNeighbour().size(), sumOp<label>()); label nCells = returnReduce(mesh.cells().size(), sumOp<label>()); Info<< " faces: " << nFaces << nl << " internal faces: " << nIntFaces << nl << " cells: " << nCells << nl << " faces per cell: " << scalar(nFaces + nIntFaces)/max(1, nCells) << nl << " boundary patches: " << mesh.boundaryMesh().size() << nl << " point zones: " << mesh.pointZones().size() << nl << " face zones: " << mesh.faceZones().size() << nl << " cell zones: " << mesh.cellZones().size() << nl << endl; // Construct shape recognizers hexMatcher hex; prismMatcher prism; wedgeMatcher wedge; pyrMatcher pyr; tetWedgeMatcher tetWedge; tetMatcher tet; // Counters for different cell types label nHex = 0; label nWedge = 0; label nPrism = 0; label nPyr = 0; label nTet = 0; label nTetWedge = 0; label nUnknown = 0; Map<label> polyhedralFaces; for (label cellI = 0; cellI < mesh.nCells(); cellI++) { if (hex.isA(mesh, cellI)) { nHex++; } else if (tet.isA(mesh, cellI)) { nTet++; } else if (pyr.isA(mesh, cellI)) { nPyr++; } else if (prism.isA(mesh, cellI)) { nPrism++; } else if (wedge.isA(mesh, cellI)) { nWedge++; } else if (tetWedge.isA(mesh, cellI)) { nTetWedge++; } else { nUnknown++; polyhedralFaces(mesh.cells()[cellI].size())++; } } reduce(nHex,sumOp<label>()); reduce(nPrism,sumOp<label>()); reduce(nWedge,sumOp<label>()); reduce(nPyr,sumOp<label>()); reduce(nTetWedge,sumOp<label>()); reduce(nTet,sumOp<label>()); reduce(nUnknown,sumOp<label>()); Info<< "Overall number of cells of each type:" << nl << " hexahedra: " << nHex << nl << " prisms: " << nPrism << nl << " wedges: " << nWedge << nl << " pyramids: " << nPyr << nl << " tet wedges: " << nTetWedge << nl << " tetrahedra: " << nTet << nl << " polyhedra: " << nUnknown << endl; if (nUnknown > 0) { Pstream::mapCombineGather(polyhedralFaces, plusEqOp<label>()); Info<< " Breakdown of polyhedra by number of faces:" << nl << " faces" << " number of cells" << endl; const labelList sortedKeys = polyhedralFaces.sortedToc(); forAll(sortedKeys, keyI) { const label nFaces = sortedKeys[keyI]; Info<< setf(std::ios::right) << setw(13) << nFaces << " " << polyhedralFaces[nFaces] << nl; } }