void Foam::KinematicCloud<CloudType>::info() const { vector linearMomentum = linearMomentumOfSystem(); reduce(linearMomentum, sumOp<vector>()); scalar linearKineticEnergy = linearKineticEnergyOfSystem(); reduce(linearKineticEnergy, sumOp<scalar>()); scalar rotationalKineticEnergy = rotationalKineticEnergyOfSystem(); reduce(rotationalKineticEnergy, sumOp<scalar>()); Info<< "Cloud: " << this->name() << nl << " Current number of parcels = " << returnReduce(this->size(), sumOp<label>()) << nl << " Current mass in system = " << returnReduce(massInSystem(), sumOp<scalar>()) << nl << " Linear momentum = " << linearMomentum << nl << " |Linear momentum| = " << mag(linearMomentum) << nl << " Linear kinetic energy = " << linearKineticEnergy << nl << " Rotational kinetic energy = " << rotationalKineticEnergy << nl; this->injection().info(Info); this->surfaceFilm().info(Info); this->patchInteraction().info(Info); }
Foam::swirlFlowRateInletVelocityFvPatchVectorField:: swirlFlowRateInletVelocityFvPatchVectorField ( const fvPatch& p, const DimensionedField<vector, volMesh>& iF, const dictionary& dict ) : fixedValueFvPatchField<vector>(p, iF, dict), phiName_(dict.lookupOrDefault<word>("phi", "phi")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")), origin_ ( dict.lookupOrDefault ( "origin", returnReduce(patch().size(), maxOp<label>()) ? gSum(patch().Cf()*patch().magSf())/gSum(patch().magSf()) : Zero ) ), axis_ ( dict.lookupOrDefault ( "axis", returnReduce(patch().size(), maxOp<label>()) ? -gSum(patch().Sf())/gSum(patch().magSf()) : Zero ) ), flowRate_(Function1<scalar>::New("flowRate", dict)), rpm_(Function1<scalar>::New("rpm", dict)) {}
void Foam::InjectionModel<CloudType>::postInjectCheck ( const label parcelsAdded, const scalar massAdded ) { const label allParcelsAdded = returnReduce(parcelsAdded, sumOp<label>()); if (allParcelsAdded > 0) { Info<< nl << "--> Cloud: " << owner_.name() << nl << " Added " << allParcelsAdded << " new parcels" << nl << endl; } // Increment total number of parcels added parcelsAddedTotal_ += allParcelsAdded; // Increment total mass injected massInjected_ += returnReduce(massAdded, sumOp<scalar>()); // Update time for start of next injection time0_ = owner_.db().time().value(); // Increment number of injections nInjections_++; // Write current state to properties file writeProps(); }
void Foam::StandardWallInteraction<CloudType>::info(Ostream& os) { label npe0 = this->template getBaseProperty<scalar>("nEscape"); label npe = npe0 + returnReduce(nEscape_, sumOp<label>()); scalar mpe0 = this->template getBaseProperty<scalar>("massEscape"); scalar mpe = mpe0 + returnReduce(massEscape_, sumOp<scalar>()); label nps0 = this->template getBaseProperty<scalar>("nStick"); label nps = nps0 + returnReduce(nStick_, sumOp<label>()); scalar mps0 = this->template getBaseProperty<scalar>("massStick"); scalar mps = mps0 + returnReduce(massStick_, sumOp<scalar>()); os << " Parcel fate (number, mass)" << nl << " - escape = " << npe << ", " << mpe << nl << " - stick = " << nps << ", " << mps << nl; if (this->outputTime()) { this->setModelProperty("nEscape", npe); // nEscape_ = 0; this->setModelProperty("massEscape", mpe); // massEscape_ = 0.0; this->setModelProperty("nStick", nps); // nStick_ = 0; this->setModelProperty("massStick", mps); // massStick_ = 0.0; } }
void phaseChangeModel::info(Ostream& os) const { const scalar massPCRate = returnReduce(latestMassPC_, sumOp<scalar>()) /owner_.time().deltaTValue(); os << indent << "mass phase change = " << returnReduce(totalMassPC_, sumOp<scalar>()) << nl << indent << "vapourisation rate = " << massPCRate << nl; }
void phaseChangeModel::info(Ostream& os) const { const scalar massPCRate = returnReduce(latestMassPC_, sumOp<scalar>()) /filmModel_.time().deltaTValue(); scalar phaseChangeMass = getModelProperty<scalar>("phaseChangeMass"); phaseChangeMass += returnReduce(totalMassPC_, sumOp<scalar>()); os << indent << "mass phase change = " << phaseChangeMass << nl << indent << "vapourisation rate = " << massPCRate << nl; }
void Foam::KinematicCloud<ParcelType>::info() const { Info<< "Cloud: " << this->name() << nl << " Total number of parcels added = " << this->injection().parcelsAddedTotal() << nl << " Total mass introduced = " << this->injection().massInjected() << nl << " Current number of parcels = " << returnReduce(this->size(), sumOp<label>()) << nl << " Current mass in system = " << returnReduce(massInSystem(), sumOp<scalar>()) << nl; }
void Foam::StandardWallInteraction<CloudType>::info(Ostream& os) const { label npe = returnReduce(nEscape_, sumOp<label>()) + nEscape0_; scalar mpe = returnReduce(massEscape_, sumOp<scalar>()) + massEscape0_; label nps = returnReduce(nStick_, sumOp<label>()) + nStick0_; scalar mps = returnReduce(massStick_, sumOp<scalar>()) + massStick0_; os << " Parcel fates:" << nl << " - escape = " << npe << ", " << mpe << nl << " - stick = " << nps << ", " << mps << nl; writeProps(npe, mpe, nps, mps); }
Foam::label Foam::checkMeshQuality ( const polyMesh& mesh, const dictionary& dict ) { label noFailedChecks = 0; { faceSet faces(mesh, "meshQualityFaces", mesh.nFaces()/100+1); motionSmoother::checkMesh(false, mesh, dict, faces); label nFaces = returnReduce(faces.size(), sumOp<label>()); if (nFaces > 0) { noFailedChecks++; Info<< " <<Writing " << nFaces << " faces in error to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); } } return noFailedChecks; }
void phaseChangeModel::correct ( const scalar dt, scalarField& availableMass, volScalarField& dMass, volScalarField& dEnergy ) { if (!active()) { return; } correctModel ( dt, availableMass, dMass, dEnergy ); latestMassPC_ = sum(dMass.primitiveField()); totalMassPC_ += latestMassPC_; availableMass -= dMass; dMass.correctBoundaryConditions(); if (writeTime()) { scalar phaseChangeMass = getModelProperty<scalar>("phaseChangeMass"); phaseChangeMass += returnReduce(totalMassPC_, sumOp<scalar>()); setModelProperty<scalar>("phaseChangeMass", phaseChangeMass); totalMassPC_ = 0.0; } }
label meshOptimizer::findLowQualityFaces ( labelHashSet& badFaces, const boolList& changedFace ) const { badFaces.clear(); polyMeshGenChecks::checkFaceDotProduct ( mesh_, false, 70.0, &badFaces ); polyMeshGenChecks::checkFaceSkewness ( mesh_, false, 2.0, &badFaces ); const label nBadFaces = returnReduce(badFaces.size(), sumOp<label>()); return nBadFaces; }
Foam::scalar Foam::getRefCellValue ( const volScalarField& field, const label refCelli ) { scalar refCellValue = (refCelli >= 0 ? field[refCelli] : 0.0); return returnReduce(refCellValue, sumOp<scalar>()); }
// Calculate geometrically collocated points, Requires PackedList to be // sized and initalised! Foam::label Foam::autoSnapDriver::getCollocatedPoints ( const scalar tol, const pointField& points, PackedBoolList& isCollocatedPoint ) { labelList pointMap; label nUnique = mergePoints ( points, // points tol, // mergeTol false, // verbose pointMap ); bool hasMerged = (nUnique < points.size()); if (!returnReduce(hasMerged, orOp<bool>())) { return 0; } // Determine which merged points are referenced more than once label nCollocated = 0; // Per old point the newPoint. Or -1 (not set yet) or -2 (already seen // twice) labelList firstOldPoint(nUnique, -1); forAll(pointMap, oldPointI) { label newPointI = pointMap[oldPointI]; if (firstOldPoint[newPointI] == -1) { // First use of oldPointI. Store. firstOldPoint[newPointI] = oldPointI; } else if (firstOldPoint[newPointI] == -2) { // Third or more reference of oldPointI -> non-manifold isCollocatedPoint.set(oldPointI, 1u); nCollocated++; } else { // Second reference of oldPointI -> non-manifold isCollocatedPoint.set(firstOldPoint[newPointI], 1u); nCollocated++; isCollocatedPoint.set(oldPointI, 1u); nCollocated++; // Mark with special value to save checking next time round firstOldPoint[newPointI] = -2; } }
// Find position in values so between minIndex and this position there // are wantedSize elements. void Foam::hierarchGeomDecomp::findBinary ( const label sizeTol, const List<scalar>& values, const label minIndex, // index of previous value const scalar minValue, // value at minIndex const scalar maxValue, // global max of values const scalar wantedSize, // wanted size label& mid, // index where size of bin is // wantedSize (to within sizeTol) scalar& midValue // value at mid ) { label low = minIndex; scalar lowValue = minValue; scalar highValue = maxValue; // (one beyond) index of highValue label high = values.size(); //while (low <= high) while (true) { label size = returnReduce(mid-minIndex, sumOp<label>()); if (debug) { Pout<< "low:" << low << " lowValue:" << lowValue << " high:" << high << " highValue:" << highValue << " mid:" << mid << " midValue:" << midValue << nl << "globalSize:" << size << " wantedSize:" << wantedSize << " sizeTol:" << sizeTol << endl; } if (wantedSize < size - sizeTol) { high = mid; highValue = midValue; } else if (wantedSize > size + sizeTol) { low = mid; lowValue = midValue; } else { break; } // Update mid, midValue midValue = 0.5*(lowValue+highValue); mid = findLower(values, midValue, low, high); } }
void Foam::fieldValues::cellSource::setCellZoneCells() { switch (source_) { case stCellZone: { label zoneId = mesh().cellZones().findZoneID(sourceName_); if (zoneId < 0) { FatalErrorIn("cellSource::cellSource::setCellZoneCells()") << "Unknown cell zone name: " << sourceName_ << ". Valid cell zones are: " << mesh().cellZones().names() << nl << exit(FatalError); } cellId_ = mesh().cellZones()[zoneId]; nCells_ = returnReduce(cellId_.size(), sumOp<label>()); break; } case stAll: { cellId_ = identity(mesh().nCells()); nCells_ = returnReduce(cellId_.size(), sumOp<label>()); break; } default: { FatalErrorIn("cellSource::setCellZoneCells()") << "Unknown source type. Valid source types are:" << sourceTypeNames_ << nl << exit(FatalError); } } if (debug) { Pout<< "Selected source size = " << cellId_.size() << endl; } }
void Foam::DevolatilisationModel<CloudType>::info(Ostream& os) { const scalar mass0 = this->template getBaseProperty<scalar>("mass"); const scalar massTotal = mass0 + returnReduce(dMass_, sumOp<scalar>()); Info<< " Mass transfer devolatilisation = " << massTotal << nl; if (this->outputTime()) { this->setBaseProperty("mass", massTotal); dMass_ = 0.0; } }
label meshOptimizer::findBadFaces ( labelHashSet& badFaces, const boolList& changedFace ) const { badFaces.clear(); polyMeshGenChecks::checkFacePyramids ( mesh_, false, VSMALL, &badFaces, &changedFace ); polyMeshGenChecks::checkFaceFlatness ( mesh_, false, 0.8, &badFaces, &changedFace ); polyMeshGenChecks::checkCellPartTetrahedra ( mesh_, false, VSMALL, &badFaces, &changedFace ); polyMeshGenChecks::checkFaceAreas ( mesh_, false, VSMALL, &badFaces, &changedFace ); const label nBadFaces = returnReduce(badFaces.size(), sumOp<label>()); return nBadFaces; }
bool Foam::layerAdditionRemoval::validCollapse() const { // Check for valid layer collapse // - no boundary-to-boundary collapse if (debug) { Pout<< "Checking layer collapse for object " << name() << endl; } // Grab the face collapse mapping const polyMesh& mesh = topoChanger().mesh(); const labelList& ftc = facesPairing(); const labelList& mf = mesh.faceZones()[faceZoneID_.index()]; label nBoundaryHits = 0; forAll(mf, facei) { if ( !mesh.isInternalFace(mf[facei]) && !mesh.isInternalFace(ftc[facei]) ) { nBoundaryHits++; } } if (debug) { Pout<< "Finished checking layer collapse for object " << name() <<". Number of boundary-on-boundary hits: " << nBoundaryHits << endl; } if (returnReduce(nBoundaryHits, sumOp<label>()) > 0) { return false; } else { return true; } }
void kinematicSingleLayer::info() { Info<< "\nSurface film: " << type() << endl; const scalarField& deltaInternal = delta_; const vectorField& Uinternal = U_; scalar addedMassTotal = 0.0; outputProperties().readIfPresent("addedMassTotal", addedMassTotal); addedMassTotal += returnReduce(addedMassTotal_, sumOp<scalar>()); Info<< indent << "added mass = " << addedMassTotal << nl << indent << "current mass = " << gSum((deltaRho_*magSf())()) << nl << indent << "min/max(mag(U)) = " << gMin(mag(Uinternal)) << ", " << gMax(mag(Uinternal)) << nl << indent << "min/max(delta) = " << gMin(deltaInternal) << ", " << gMax(deltaInternal) << nl << indent << "coverage = " << gSum(alpha_.primitiveField()*magSf())/gSum(magSf()) << nl; injection_.info(Info); transfer_.info(Info); }
bool workflowControls::stopAfterCurrentStep() const { setStepCompleted(); if( exitAfterCurrentStep() ) { bool writeSuccess(true); try { Info << "Saving mesh generated after step " << currentStep_ << endl; mesh_.write(); } catch(...) { writeSuccess = false; } returnReduce(writeSuccess, minOp<bool>()); if( !writeSuccess ) FatalErrorIn ( "bool workflowControls::stopAfterCurrentStep() const" ) << "Mesh was not written on disk" << exit(FatalError); std::string message("Stopping after step "); message += currentStep_; throw message; return true; } return false; }
bool Foam::outputFilterOutputControl::output() { switch (outputControl_) { case ocTimeStep: { return ( (outputInterval_ <= 1) || !(time_.timeIndex() % outputInterval_) ); break; } case ocOutputTime: { if (time_.outputTime()) { outputTimeLastDump_ ++; return !(outputTimeLastDump_ % outputInterval_); } break; } case ocRunTime: case ocAdjustableTime: { label outputIndex = label ( ( (time_.value() - time_.startTime().value()) + 0.5*time_.deltaTValue() ) / writeInterval_ ); if (outputIndex > outputTimeLastDump_) { outputTimeLastDump_ = outputIndex; return true; } break; } case ocCpuTime: { label outputIndex = label ( returnReduce(time_.elapsedCpuTime(), maxOp<double>()) / writeInterval_ ); if (outputIndex > outputTimeLastDump_) { outputTimeLastDump_ = outputIndex; return true; } break; } case ocClockTime: { label outputIndex = label ( returnReduce(label(time_.elapsedClockTime()), maxOp<label>()) / writeInterval_ ); if (outputIndex > outputTimeLastDump_) { outputTimeLastDump_ = outputIndex; return true; } break; } default: { // this error should not actually be possible FatalErrorIn("bool Foam::outputFilterOutputControl::output()") << "Undefined output control: " << outputControlNames_[outputControl_] << nl << abort(FatalError); break; } } return false; }
} // Walk PatchEdgeFaceWave < indirectPrimitivePatch, patchEdgeFaceRegion > calc ( mesh_, patch, changedEdges, changedInfo, allEdgeInfo, allFaceInfo, returnReduce(patch.nEdges(), sumOp<label>()) ); forAll(allFaceInfo, faceI) { if (allFaceInfo[faceI].region() == zoneI) { faceZone[faceI] = zoneI; } } } void Foam::regionToFace::combine(topoSet& set, const bool add) const { Info<< " Loading subset " << setName_ << " to delimit search region."
} const cellZone& cZone = mesh().cellZones()[zoneId]; cellId_.setSize(cZone.size()); label count = 0; forAll(cZone, i) { label cellI = cZone[i]; cellId_[count] = cellI; count++; } cellId_.setSize(count); nCells_ = returnReduce(cellId_.size(), sumOp<label>()); if (debug) { Pout<< "Original cell zone size = " << cZone.size() << ", new size = " << count << endl; } } // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void Foam::fieldValues::cellSource::initialise(const dictionary& dict) { switch (source_) {
Foam::polyMesh::polyMesh(const IOobject& io) : objectRegistry(io), primitiveMesh(), points_ ( IOobject ( "points", time().findInstance(meshDir(), "points"), meshSubDir, *this, IOobject::MUST_READ, IOobject::NO_WRITE ) ), faces_ ( IOobject ( "faces", time().findInstance(meshDir(), "faces"), meshSubDir, *this, IOobject::MUST_READ, IOobject::NO_WRITE ) ), owner_ ( IOobject ( "owner", faces_.instance(), meshSubDir, *this, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ) ), neighbour_ ( IOobject ( "neighbour", faces_.instance(), meshSubDir, *this, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ) ), clearedPrimitives_(false), boundary_ ( IOobject ( "boundary", time().findInstance(meshDir(), "boundary"), meshSubDir, *this, IOobject::MUST_READ, IOobject::NO_WRITE ), *this ), bounds_(points_), comm_(UPstream::worldComm), geometricD_(Vector<label>::zero), solutionD_(Vector<label>::zero), tetBasePtIsPtr_(NULL), cellTreePtr_(NULL), pointZones_ ( IOobject ( "pointZones", time().findInstance ( meshDir(), "pointZones", IOobject::READ_IF_PRESENT ), meshSubDir, *this, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), *this ), faceZones_ ( IOobject ( "faceZones", time().findInstance ( meshDir(), "faceZones", IOobject::READ_IF_PRESENT ), meshSubDir, *this, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), *this ), cellZones_ ( IOobject ( "cellZones", time().findInstance ( meshDir(), "cellZones", IOobject::READ_IF_PRESENT ), meshSubDir, *this, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), *this ), globalMeshDataPtr_(NULL), moving_(false), topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { if (exists(owner_.objectPath())) { initMesh(); } else { cellCompactIOList cLst ( IOobject ( "cells", time().findInstance(meshDir(), "cells"), meshSubDir, *this, IOobject::MUST_READ, IOobject::NO_WRITE ) ); // Set the primitive mesh initMesh(cLst); owner_.write(); neighbour_.write(); } // Calculate topology for the patches (processor-processor comms etc.) boundary_.updateMesh(); // Calculate the geometry for the patches (transformation tensors etc.) boundary_.calcGeometry(); // Warn if global empty mesh if (returnReduce(nPoints(), sumOp<label>()) == 0) { WarningIn("polyMesh(const IOobject&)") << "no points in mesh" << endl; } if (returnReduce(nCells(), sumOp<label>()) == 0) { WarningIn("polyMesh(const IOobject&)") << "no cells in mesh" << endl; } // Initialise demand-driven data calcDirections(); }
// Call scotch with options from dictionary. Foam::label Foam::ptscotchDecomp::decompose ( const fileName& meshPath, const label adjncySize, const label adjncy[], const label xadjSize, const label xadj[], const scalarField& cWeights, List<label>& finalDecomp ) const { if (debug) { Pout<< "ptscotchDecomp : entering with xadj:" << xadjSize << endl; } // Dump graph if (decompositionDict_.found("scotchCoeffs")) { const dictionary& scotchCoeffs = decompositionDict_.subDict("scotchCoeffs"); if (scotchCoeffs.lookupOrDefault("writeGraph", false)) { OFstream str ( meshPath + "_" + Foam::name(Pstream::myProcNo()) + ".dgr" ); Pout<< "Dumping Scotch graph file to " << str.name() << endl << "Use this in combination with dgpart." << endl; globalIndex globalCells(xadjSize-1); // Distributed graph file (.grf) label version = 2; str << version << nl; // Number of files (procglbnbr) str << Pstream::nProcs(); // My file number (procloc) str << ' ' << Pstream::myProcNo() << nl; // Total number of vertices (vertglbnbr) str << globalCells.size(); // Total number of connections (edgeglbnbr) str << ' ' << returnReduce(xadj[xadjSize-1], sumOp<label>()) << nl; // Local number of vertices (vertlocnbr) str << xadjSize-1; // Local number of connections (edgelocnbr) str << ' ' << xadj[xadjSize-1] << nl; // Numbering starts from 0 label baseval = 0; // 100*hasVertlabels+10*hasEdgeWeights+1*hasVertWeighs str << baseval << ' ' << "000" << nl; for (label celli = 0; celli < xadjSize-1; celli++) { label start = xadj[celli]; label end = xadj[celli+1]; str << end-start; for (label i = start; i < end; i++) { str << ' ' << adjncy[i]; } str << nl; } } } // Strategy // ~~~~~~~~ // Default. SCOTCH_Strat stradat; check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit"); if (decompositionDict_.found("scotchCoeffs")) { const dictionary& scotchCoeffs = decompositionDict_.subDict("scotchCoeffs"); string strategy; if (scotchCoeffs.readIfPresent("strategy", strategy)) { if (debug) { Info<< "ptscotchDecomp : Using strategy " << strategy << endl; } SCOTCH_stratDgraphMap(&stradat, strategy.c_str()); //fprintf(stdout, "S\tStrat="); //SCOTCH_stratSave(&stradat, stdout); //fprintf(stdout, "\n"); } } // Graph // ~~~~~ List<label> velotab; // Check for externally provided cellweights and if so initialise weights scalar minWeights = gMin(cWeights); scalar maxWeights = gMax(cWeights); if (maxWeights > minWeights) { if (minWeights <= 0) { WarningInFunction << "Illegal minimum weight " << minWeights << endl; } if (cWeights.size() != xadjSize-1) { FatalErrorInFunction << "Number of cell weights " << cWeights.size() << " does not equal number of cells " << xadjSize-1 << exit(FatalError); } } scalar velotabSum = gSum(cWeights)/minWeights; scalar rangeScale(1.0); if (Pstream::master()) { if (velotabSum > scalar(labelMax - 1)) { // 0.9 factor of safety to avoid floating point round-off in // rangeScale tipping the subsequent sum over the integer limit. rangeScale = 0.9*scalar(labelMax - 1)/velotabSum; WarningInFunction << "Sum of weights has overflowed integer: " << velotabSum << ", compressing weight scale by a factor of " << rangeScale << endl; } } Pstream::scatter(rangeScale); if (maxWeights > minWeights) { if (cWeights.size()) { // Convert to integers. velotab.setSize(cWeights.size()); forAll(velotab, i) { velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1; } }
void dynamicRefineFvMesh::calculateProtectedCells ( PackedBoolList& unrefineableCell ) const { if (protectedCell_.empty()) { unrefineableCell.clear(); return; } const labelList& cellLevel = meshCutter_.cellLevel(); unrefineableCell = protectedCell_; // Get neighbouring cell level labelList neiLevel(nFaces()-nInternalFaces()); for (label faceI = nInternalFaces(); faceI < nFaces(); faceI++) { neiLevel[faceI-nInternalFaces()] = cellLevel[faceOwner()[faceI]]; } syncTools::swapBoundaryFaceList(*this, neiLevel, false); while (true) { // Pick up faces on border of protected cells boolList seedFace(nFaces(), false); forAll(faceNeighbour(), faceI) { label own = faceOwner()[faceI]; bool ownProtected = (unrefineableCell.get(own) == 1); label nei = faceNeighbour()[faceI]; bool neiProtected = (unrefineableCell.get(nei) == 1); if (ownProtected && (cellLevel[nei] > cellLevel[own])) { seedFace[faceI] = true; } else if (neiProtected && (cellLevel[own] > cellLevel[nei])) { seedFace[faceI] = true; } } for (label faceI = nInternalFaces(); faceI < nFaces(); faceI++) { label own = faceOwner()[faceI]; bool ownProtected = (unrefineableCell.get(own) == 1); if ( ownProtected && (neiLevel[faceI-nInternalFaces()] > cellLevel[own]) ) { seedFace[faceI] = true; } } syncTools::syncFaceList(*this, seedFace, orEqOp<bool>(), false); // Extend unrefineableCell bool hasExtended = false; for (label faceI = 0; faceI < nInternalFaces(); faceI++) { if (seedFace[faceI]) { label own = faceOwner()[faceI]; if (unrefineableCell.get(own) == 0) { unrefineableCell.set(own, 1); hasExtended = true; } label nei = faceNeighbour()[faceI]; if (unrefineableCell.get(nei) == 0) { unrefineableCell.set(nei, 1); hasExtended = true; } } } for (label faceI = nInternalFaces(); faceI < nFaces(); faceI++) { if (seedFace[faceI]) { label own = faceOwner()[faceI]; if (unrefineableCell.get(own) == 0) { unrefineableCell.set(own, 1); hasExtended = true; } } } if (!returnReduce(hasExtended, orOp<bool>())) { break; } }
Foam::label Foam::scotchDecomp::decompose ( const fileName& meshPath, const List<label>& adjncy, const List<label>& xadj, const scalarField& cWeights, List<label>& finalDecomp ) { if (!Pstream::parRun()) { decomposeOneProc ( meshPath, adjncy, xadj, cWeights, finalDecomp ); } else { if (debug) { Info<< "scotchDecomp : running in parallel." << " Decomposing all of graph on master processor." << endl; } globalIndex globalCells(xadj.size()-1); label nTotalConnections = returnReduce(adjncy.size(), sumOp<label>()); // Send all to master. Use scheduled to save some storage. if (Pstream::master()) { Field<label> allAdjncy(nTotalConnections); Field<label> allXadj(globalCells.size()+1); scalarField allWeights(globalCells.size()); // Insert my own label nTotalCells = 0; forAll(cWeights, cellI) { allXadj[nTotalCells] = xadj[cellI]; allWeights[nTotalCells++] = cWeights[cellI]; } nTotalConnections = 0; forAll(adjncy, i) { allAdjncy[nTotalConnections++] = adjncy[i]; } for (int slave=1; slave<Pstream::nProcs(); slave++) { IPstream fromSlave(Pstream::scheduled, slave); Field<label> nbrAdjncy(fromSlave); Field<label> nbrXadj(fromSlave); scalarField nbrWeights(fromSlave); // Append. //label procStart = nTotalCells; forAll(nbrXadj, cellI) { allXadj[nTotalCells] = nTotalConnections+nbrXadj[cellI]; allWeights[nTotalCells++] = nbrWeights[cellI]; } // No need to renumber xadj since already global. forAll(nbrAdjncy, i) { allAdjncy[nTotalConnections++] = nbrAdjncy[i]; } } allXadj[nTotalCells] = nTotalConnections; Field<label> allFinalDecomp; decomposeOneProc ( meshPath, allAdjncy, allXadj, allWeights, allFinalDecomp ); // Send allFinalDecomp back for (int slave=1; slave<Pstream::nProcs(); slave++) { OPstream toSlave(Pstream::scheduled, slave); toSlave << SubField<label> ( allFinalDecomp, globalCells.localSize(slave), globalCells.offset(slave) ); } // Get my own part (always first) finalDecomp = SubField<label> ( allFinalDecomp, globalCells.localSize() ); }
const label globalCurrentSize, scalarField& sortedWeightedSizes ) { // Evaluate cumulative weights. sortedWeightedSizes[0] = 0; forAll(current, i) { label pointI = current[indices[i]]; sortedWeightedSizes[i + 1] = sortedWeightedSizes[i] + weights[pointI]; } // Non-dimensionalise and multiply by size. scalar globalCurrentLength = returnReduce ( sortedWeightedSizes[current.size()], sumOp<scalar>() ); // Normalise weights by global sum of weights and multiply through // by global size. sortedWeightedSizes *= (globalCurrentSize/globalCurrentLength); } // Find position in values so between minIndex and this position there // are wantedSize elements. void Foam::hierarchGeomDecomp::findBinary ( const label sizeTol, const List<scalar>& values, const label minIndex, // index of previous value
nFaces += pbm[iter.key()].size(); } // Extract a submesh. labelHashSet patchCells(2*nFaces); forAllConstIter(labelHashSet, patchIDs, iter) { const labelUList& fc = pbm[iter.key()].faceCells(); forAll(fc, i) { patchCells.insert(fc[i]); } } label nTotalSeeds = returnReduce(patchCells.size(), sumOp<label>()); label nTotalCells = mesh.globalData().nTotalCells(); const label nLayers = nTotalCells/nTotalSeeds; Info<< type() << " : seeding " << nTotalSeeds << " cells on " << nLayers << " layers" << nl << endl; // Avoid subsetMesh, FaceCellWave going through proc boundaries bool oldParRun = Pstream::parRun(); Pstream::parRun() = false; // Work array. Used here to temporarily store the original-to-ordered
faceSign_[count] = -1; } else { faceSign_[count] = 1; } faceId_[count] = faceId; facePatchId_[count] = facePatchId; count++; } } faceId_.setSize(count); facePatchId_.setSize(count); faceSign_.setSize(count); nFaces_ = returnReduce(faceId_.size(), sumOp<label>()); if (debug) { Pout<< "Original face zone size = " << fZone.size() << ", new size = " << count << endl; } } void Foam::fieldValues::faceSource::setPatchFaces() { label patchId = mesh().boundaryMesh().findPatchID(sourceName_); if (patchId < 0) {