void Foam::shapeToCell::combine(topoSet& set, const bool add) const { if (type_ == "splitHex") { for (label cellI = 0; cellI < mesh_.nCells(); cellI++) { cellFeatures superCell(mesh_, featureCos, cellI); if (hexMatcher().isA(superCell.faces())) { addOrDelete(set, cellI, add); } } } else { const cellModel& wantedModel = *(cellModeller::lookup(type_)); const cellShapeList& cellShapes = mesh_.cellShapes(); forAll(cellShapes, cellI) { if (cellShapes[cellI].model() == wantedModel) { addOrDelete(set, cellI, add); } } } }
void Foam::badQualityToCell::combine(topoSet& set, const bool add) const { faceSet faces(mesh_, "meshQualityFaces", mesh_.nFaces()/100+1); motionSmoother::checkMesh(false, mesh_, dict_, faces); faces.sync(mesh_); forAllConstIter(faceSet, faces, iter) { label faceI = iter.key(); addOrDelete(set, mesh_.faceOwner()[faceI], add); if (mesh_.isInternalFace(faceI)) { addOrDelete(set, mesh_.faceNeighbour()[faceI], add); } }
void Foam::patchToFace::combine(topoSet& set, const bool add) const { labelHashSet patchIDs = mesh_.boundaryMesh().patchSet ( List<wordRe>(1, patchName_), true, // warn if not found true // use patch groups if available ); forAllConstIter(labelHashSet, patchIDs, iter) { label patchi = iter.key(); const polyPatch& pp = mesh_.boundaryMesh()[patchi]; Info<< " Found matching patch " << pp.name() << " with " << pp.size() << " faces." << endl; for ( label facei = pp.start(); facei < pp.start() + pp.size(); facei++ ) { addOrDelete(set, facei, add); } }
void Foam::surfaceToPoint::combine(topoSet& set, const bool add) const { cpuTime timer; triSurface surf(surfName_); Info<< " Read surface from " << surfName_ << " in = "<< timer.cpuTimeIncrement() << " s" << endl << endl; // Construct search engine on surface triSurfaceSearch querySurf(surf); if (includeInside_ || includeOutside_) { boolList pointInside(querySurf.calcInside(mesh_.points())); forAll(pointInside, pointI) { bool isInside = pointInside[pointI]; if ((isInside && includeInside_) || (!isInside && includeOutside_)) { addOrDelete(set, pointI, add); } }
void Foam::cellToFace::combine(topoSet& set, const bool add) const { // Load the set if (!exists(mesh_.time().path()/topoSet::localPath(mesh_, setName_))) { SeriousError<< "Cannot load set " << setName_ << endl; } cellSet loadedSet(mesh_, setName_); if (option_ == ALL) { // Add all faces from cell for ( cellSet::const_iterator iter = loadedSet.begin(); iter != loadedSet.end(); ++iter ) { label cellI = iter.key(); const labelList& cFaces = mesh_.cells()[cellI]; forAll(cFaces, cFaceI) { addOrDelete(set, cFaces[cFaceI], add); } } }
void Foam::cellToPoint::combine(topoSet& set, const bool add) const { // Load the set cellSet loadedSet(mesh_, setName_); // Add all point from cells in loadedSet for ( cellSet::const_iterator iter = loadedSet.begin(); iter != loadedSet.end(); ++iter ) { label cellI = iter.key(); const labelList& cFaces = mesh_.cells()[cellI]; forAll(cFaces, cFaceI) { const face& f = mesh_.faces()[cFaces[cFaceI]]; forAll(f, fp) { addOrDelete(set, f[fp], add); } } }
void Foam::pointToFace::combine(topoSet& set, const bool add) const { // Load the set pointSet loadedSet(mesh_, setName_); if (option_ == ANY) { // Add faces with any point in loadedSet for ( pointSet::const_iterator iter = loadedSet.begin(); iter != loadedSet.end(); ++iter ) { label pointI = iter.key(); const labelList& pFaces = mesh_.pointFaces()[pointI]; forAll(pFaces, pFaceI) { addOrDelete(set, pFaces[pFaceI], add); } } }
void Foam::expressionToCell::combine(topoSet& set, const bool add) const { fvMesh mesh(set.db()); FieldValueExpressionDriver driver ( mesh.time().timeName(), mesh.time(), mesh, true, // cache stuff true, // search in memory true // search on disc ); if(dict_.valid()) { driver.readVariablesAndTables(dict_()); driver.clearVariables(); } driver.parse(expression_); if(!driver.resultIsTyp<volScalarField>(true)) { FatalErrorIn("Foam::expressionToCell::combine(topoSet& set, const bool add) const") << "Expression " << expression_ << " does not evaluate to a logical expression" << endl << exit(FatalError); } const volScalarField &condition=driver.getResult<volScalarField>(); forAll(condition, cellI) { if (condition[cellI]) { addOrDelete(set, cellI, add); } } }
void Foam::nearestToCell::combine(topoSet& set, const bool add) const { // Construct search engine withouth tet decomposition. meshSearch queryMesh(mesh_, false); forAll(points_, pointI) { addOrDelete(set, queryMesh.findNearestCell(points_[pointI]), add); }
void Foam::boxToPoint::combine(topoSet& set, const bool add) const { const pointField& pts = mesh_.points(); forAll(pts, pointI) { if (bb_.contains(pts[pointI])) { addOrDelete(set, pointI, add); } } }
void Foam::boxToCell::combine(topoSet& set, const bool add) const { const pointField& ctrs = mesh_.cellCentres(); forAll(ctrs, cellI) { if (bb_.contains(ctrs[cellI])) { addOrDelete(set, cellI, add); } } }
void Foam::boundaryToFace::combine(topoSet& set, const bool add) const { for ( label facei = mesh().nInternalFaces(); facei < mesh().nFaces(); facei++ ) { addOrDelete(set, facei, add); } }
void Foam::boxToFace::combine(topoSet& set, const bool add) const { const pointField& ctrs = mesh_.faceCentres(); forAll(ctrs, faceI) { if (bb_.contains(ctrs[faceI])) { addOrDelete(set, faceI, add); } } }
void Foam::faceToPoint::combine(topoSet& set, const bool add) const { // Load the set faceSet loadedSet(mesh_, setName_); // Add all points from faces in loadedSet forAllConstIter(faceSet, loadedSet, iter) { const face& f = mesh_.faces()[iter.key()]; forAll(f, fp) { addOrDelete(set, f[fp], add); } }
forAll(ctrs, cellI) { bool inside = true; forAll(boxFaces, i) { const face& f = boxFaces[i]; if (((ctrs[cellI] - boxPoints[f[0]]) & boxFaceNormals[i]) > 0) { inside = false; break; } } if (inside) { addOrDelete(set, cellI, add); } }
void Foam::faceToPoint::combine(topoSet& set, const bool add) const { // Load the set faceSet loadedSet(mesh_, setName_); // Add all points from faces in loadedSet for ( faceSet::const_iterator iter = loadedSet.begin(); iter != loadedSet.end(); ++iter ) { const face& f = mesh_.faces()[iter.key()]; forAll(f, fp) { addOrDelete(set, f[fp], add); } }
void Foam::cylinderToCell::combine(topoSet& set, const bool add) const { const vector axis = p2_ - p1_; const scalar rad2 = sqr(radius_); const scalar magAxis2 = magSqr(axis); const pointField& ctrs = mesh_.cellCentres(); forAll(ctrs, celli) { vector d = ctrs[celli] - p1_; scalar magD = d & axis; if ((magD > 0) && (magD < magAxis2)) { scalar d2 = (d & d) - sqr(magD)/magAxis2; if (d2 < rad2) { addOrDelete(set, celli, add); } } }
forAll(points_, pointI) { const pointField& pts = mesh_.points(); if (pts.size()) { label minPointI = 0; scalar minDistSqr = magSqr(pts[minPointI] - points_[pointI]); for (label i = 1; i < pts.size(); i++) { scalar distSqr = magSqr(pts[i] - points_[pointI]); if (distSqr < minDistSqr) { minDistSqr = distSqr; minPointI = i; } } addOrDelete(set, minPointI, add); } }
forAll(labels_, labelI) { addOrDelete(set, labels_[labelI], add); }
void Foam::regionToCell::combine(topoSet& set, const bool add) const { label cellI = mesh_.findCell(insidePoint_); // Load the subset of cells boolList blockedFace(mesh_.nFaces(), false); { Info<< "Loading subset " << setName_ << " to delimit search region." << endl; cellSet subSet(mesh_, setName_); boolList inSubset(mesh_.nCells(), false); forAllConstIter(cellSet, subSet, iter) { inSubset[iter.key()] = true; } if (cellI != -1 && inSubset[cellI]) { Pout<< "Point " << insidePoint_ << " is inside cellSet " << setName_ << endl << "Collecting all cells connected to " << cellI << " and inside cellSet " << setName_ << endl; } else { Pout<< "Point " << insidePoint_ << " is outside cellSet " << setName_ << endl << "Collecting all cells connected to " << cellI << " and outside cellSet " << setName_ << endl; } // Get coupled cell status label nInt = mesh_.nInternalFaces(); boolList neiSet(mesh_.nFaces()-nInt, false); for (label faceI = nInt; faceI < mesh_.nFaces(); faceI++) { neiSet[faceI-nInt] = inSubset[mesh_.faceOwner()[faceI]]; } syncTools::swapBoundaryFaceList(mesh_, neiSet, false); // Find faces inbetween subSet and non-subset. for (label faceI = 0; faceI < nInt; faceI++) { bool ownInSet = inSubset[mesh_.faceOwner()[faceI]]; bool neiInSet = inSubset[mesh_.faceNeighbour()[faceI]]; blockedFace[faceI] = (ownInSet != neiInSet); } for (label faceI = nInt; faceI < mesh_.nFaces(); faceI++) { bool ownInSet = inSubset[mesh_.faceOwner()[faceI]]; bool neiInSet = neiSet[faceI-nInt]; blockedFace[faceI] = (ownInSet != neiInSet); } } // Find connected regions without crossing boundary of the cellset. regionSplit regions(mesh_, blockedFace); // Get the region containing the insidePoint label regionI = -1; if (cellI != -1) { // On processor that has found cell. regionI = regions[cellI]; } reduce(regionI, maxOp<label>()); if (regionI == -1) { WarningIn ( "regionToCell::combine(topoSet&, const bool) const" ) << "Point " << insidePoint_ << " is not inside the mesh." << nl << "Bounding box of the mesh:" << mesh_.globalData().bb() << endl; return; } // Pick up the cells of the region const labelList regionCells(findIndices(regions, regionI)); forAll(regionCells, i) { addOrDelete(set, regionCells[i], add); }
void Foam::faceToCell::combine(topoSet& set, const bool add) const { // Load the set faceSet loadedSet(mesh_, setName_); // Handle owner/neighbour/any selection forAllConstIter(faceSet, loadedSet, iter) { const label faceI = iter.key(); if ((option_ == OWNER) || (option_ == ANY)) { const label cellI = mesh_.faceOwner()[faceI]; addOrDelete(set, cellI, add); } if (mesh_.isInternalFace(faceI)) { if ((option_ == NEIGHBOUR) || (option_ == ANY)) { const label cellI = mesh_.faceNeighbour()[faceI]; addOrDelete(set, cellI, add); } } } // Handle all selection. if (option_ == ALL) { // Count number of selected faces per cell. Map<label> facesPerCell(loadedSet.size()); forAllConstIter(faceSet, loadedSet, iter) { const label faceI = iter.key(); const label own = mesh_.faceOwner()[faceI]; Map<label>::iterator fndOwn = facesPerCell.find(own); if (fndOwn == facesPerCell.end()) { facesPerCell.insert(own, 1); } else { fndOwn()++; } if (mesh_.isInternalFace(faceI)) { label nei = mesh_.faceNeighbour()[faceI]; Map<label>::iterator fndNei = facesPerCell.find(nei); if (fndNei == facesPerCell.end()) { facesPerCell.insert(nei, 1); } else { fndNei()++; } } } // Include cells that are referenced as many times as they have faces // -> all faces in set. forAllConstIter(Map<label>, facesPerCell, iter) { const label cellI = iter.key(); if (iter() == mesh_.cells()[cellI].size()) { addOrDelete(set, cellI, add); } } }