void Foam::data::setSolverPerformance ( const word& name, const SolverPerformance<Type>& sp ) const { dictionary& dict = const_cast<dictionary&>(solverPerformanceDict()); // Use a DynamicList to improve performance of the append DynamicList<SolverPerformance<Type>> perfs; const label timeIndex = this->time().subCycling() ? this->time().prevTimeState().timeIndex() : this->time().timeIndex(); if (prevTimeIndex_ != timeIndex) { // Reset solver performance between iterations prevTimeIndex_ = timeIndex; dict.clear(); } else { dict.readIfPresent(name, perfs); } // Append to list perfs.append(sp); dict.set(name, perfs); }
void Foam::regionToFace::markZone ( const indirectPrimitivePatch& patch, const label procI, const label faceI, const label zoneI, labelList& faceZone ) const { // Data on all edges and faces List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges()); List<patchEdgeFaceRegion> allFaceInfo(patch.size()); DynamicList<label> changedEdges; DynamicList<patchEdgeFaceRegion> changedInfo; if (Pstream::myProcNo() == procI) { const labelList& fEdges = patch.faceEdges()[faceI]; forAll(fEdges, i) { changedEdges.append(fEdges[i]); changedInfo.append(zoneI); } }
scalarList splitValuesString ( const string &values ) { DynamicList<scalar> result; std::string::size_type start=0; std::string::size_type end=0; while(start<values.length()) { end=values.find(',',start); if(end==std::string::npos) { end=values.length(); } result.append( readScalar( IStringStream( values.substr( start,end-start ) )() ) ); start=end+1; } result.shrink(); return result; }
void Foam::sampledSets::lineUniform::genSamples() { DynamicList<point> samplingPts; DynamicList<label> samplingCells; DynamicList<label> samplingFaces; DynamicList<label> samplingSegments; DynamicList<scalar> samplingCurveDist; calcSamples ( samplingPts, samplingCells, samplingFaces, samplingSegments, samplingCurveDist ); samplingPts.shrink(); samplingCells.shrink(); samplingFaces.shrink(); samplingSegments.shrink(); samplingCurveDist.shrink(); setSamples ( samplingPts, samplingCells, samplingFaces, samplingSegments, samplingCurveDist ); }
// Collect all topological information about a point on a patch. // (this information is the patch faces using the point and the relative // position of the point in the face) void Foam::globalPoints::addToSend ( const primitivePatch& pp, const label patchPointI, const procPointList& knownInfo, DynamicList<label>& patchFaces, DynamicList<label>& indexInFace, DynamicList<procPointList>& allInfo ) { label meshPointI = pp.meshPoints()[patchPointI]; // Add all faces using the point so we are sure we find it on the // other side. const labelList& pFaces = pp.pointFaces()[patchPointI]; forAll(pFaces, i) { label patchFaceI = pFaces[i]; const face& f = pp[patchFaceI]; patchFaces.append(patchFaceI); indexInFace.append(findIndex(f, meshPointI)); allInfo.append(knownInfo); }
void Foam::faceOnlySet::genSamples() { // Storage for sample points DynamicList<point> samplingPts; DynamicList<label> samplingCells; DynamicList<label> samplingFaces; DynamicList<label> samplingSegments; DynamicList<scalar> samplingCurveDist; calcSamples ( samplingPts, samplingCells, samplingFaces, samplingSegments, samplingCurveDist ); samplingPts.shrink(); samplingCells.shrink(); samplingFaces.shrink(); samplingSegments.shrink(); samplingCurveDist.shrink(); // Copy into *this setSamples ( samplingPts, samplingCells, samplingFaces, samplingSegments, samplingCurveDist ); }
void Foam::functionEntries::ifeqEntry::skipUntil ( DynamicList<filePos>& stack, const dictionary& parentDict, const word& endWord, Istream& is ) { while (!is.eof()) { token t; readToken(t, is); if (t.isWord()) { if (t.wordToken() == "#if" || t.wordToken() == "#ifeq") { stack.append(filePos(is.name(), is.lineNumber())); skipUntil(stack, parentDict, "#endif", is); stack.remove(); } else if (t.wordToken() == endWord) { return; } } } FatalIOErrorInFunction(parentDict) << "Did not find matching " << endWord << exit(FatalIOError); }
bool faForceEquation<T>::getMask(DynamicList<label> &cellIDs,const word &psi) { parse(maskExpression_); if(!resultIsLogical()) { FatalErrorIn("faForceEquation<scalar>::operator()(faMatrix<T> &)") << "Result of " << maskExpression_ << " is not a logical expression" << endl << abort(FatalError); } const areaScalarField &cond=getScalar(); forAll(cond,cellI) { if(cond[cellI]!=0) { cellIDs.append(cellI); } } cellIDs.shrink(); label size=cellIDs.size(); reduce(size,plusOp<label>()); if(size==0) { if(verbose_) { Info << "No cells fixed for field " << psi << endl; } return false; } if(verbose_) { Info << size << " cells fixed for field " << psi << endl; } return true; }
void Foam::uniformSet::genSamples() { // Storage for sample points DynamicList<point> samplingPts; dynamicLabelList samplingCells; dynamicLabelList samplingFaces; dynamicLabelList samplingSegments; DynamicList<scalar> samplingCurveDist; calcSamples ( samplingPts, samplingCells, samplingFaces, samplingSegments, samplingCurveDist ); samplingPts.shrink(); samplingCells.shrink(); samplingFaces.shrink(); samplingSegments.shrink(); samplingCurveDist.shrink(); setSamples ( samplingPts, samplingCells, samplingFaces, samplingSegments, samplingCurveDist ); }
autoPtr<ReaderParticleCloud> ReaderParticleCloud::makeCloudFromVariables( const polyMesh &mesh, const word &cloudName, const wordList & globalNameSpacesToUse, const word &positionVar ) { GlobalVariablesRepository &repo=GlobalVariablesRepository::getGlobalVariables( mesh ); label minSize=pTraits<label>::max; label maxSize=pTraits<label>::min; bool foundPos=false; vectorField positions; DynamicList<word> varNames; forAll(globalNameSpacesToUse,nsI) { const word &nsName=globalNameSpacesToUse[nsI]; GlobalVariablesRepository::ResultTable &ns=repo.getNamespace(nsName); forAllIter(GlobalVariablesRepository::ResultTable,ns,iter) { ExpressionResult &val=*(*iter); const word &name=iter.key(); minSize=min(minSize,val.size()); maxSize=max(maxSize,val.size()); if(name==positionVar) { foundPos=true; positions=val.getResult<vector>(); } else { varNames.append(name); } } }
// Gets all intersections after initial one. Adds smallVec and starts tracking // from there. void Foam::triSurfaceMesh::getNextIntersections ( const indexedOctree<treeDataTriSurface>& octree, const point& start, const point& end, const vector& smallVec, DynamicList<pointIndexHit, 1, 1>& hits ) { const vector dirVec(end-start); const scalar magSqrDirVec(magSqr(dirVec)); // Initial perturbation amount vector perturbVec(smallVec); while (true) { // Start tracking from last hit. point pt = hits.last().hitPoint() + perturbVec; if (((pt-start)&dirVec) > magSqrDirVec) { return; } // See if any intersection between pt and end pointIndexHit inter = octree.findLine(pt, end); if (!inter.hit()) { return; } // Check if already found this intersection bool duplicateHit = false; forAllReverse(hits, i) { if (hits[i].index() == inter.index()) { duplicateHit = true; break; } } if (duplicateHit) { // Hit same triangle again. Increase perturbVec and try again. perturbVec *= 2; } else { // Proper hit hits.append(inter); // Restore perturbVec perturbVec = smallVec; } } }
int ControllerClass::findByType(char* tip) { DynamicList lista; RepositoryClass rep = RepositoryClass::RepositoryClass(); rep.loadFromFlie(lista); for (int pozitia = 0;pozitia < lista.getLength() ;++pozitia) if(strcmp(lista[pozitia].getType(),tip) == 0) return pozitia; return -1; }
void Foam::regionModels::regionModel1D::initialise() { if (debug) { Pout<< "regionModel1D::initialise()" << endl; } // Calculate boundaryFaceFaces and boundaryFaceCells DynamicList<label> faceIDs; DynamicList<label> cellIDs; label localPyrolysisFaceI = 0; const polyBoundaryMesh& rbm = regionMesh().boundaryMesh(); forAll(intCoupledPatchIDs_, i) { const label patchI = intCoupledPatchIDs_[i]; const polyPatch& ppCoupled = rbm[patchI]; forAll(ppCoupled, localFaceI) { label faceI = ppCoupled.start() + localFaceI; label cellI = -1; label nFaces = 0; label nCells = 0; do { label ownCellI = regionMesh().faceOwner()[faceI]; if (ownCellI != cellI) { cellI = ownCellI; } else { cellI = regionMesh().faceNeighbour()[faceI]; } nCells++; cellIDs.append(cellI); const cell& cFaces = regionMesh().cells()[cellI]; faceI = cFaces.opposingFaceLabel(faceI, regionMesh().faces()); faceIDs.append(faceI); nFaces++; } while (regionMesh().isInternalFace(faceI)); boundaryFaceOppositeFace_[localPyrolysisFaceI] = faceI; faceIDs.remove(); //remove boundary face. nFaces--; boundaryFaceFaces_[localPyrolysisFaceI].transfer(faceIDs); boundaryFaceCells_[localPyrolysisFaceI].transfer(cellIDs); localPyrolysisFaceI++; nLayers_ = nCells; } }
/* Functia cauta o cheltuiala dupa numar,daca ea apare ii va return pozitia cheltielii in lista si in caz contrar va returna 0 */ int ControllerClass::findById(int id) { DynamicList lista; RepositoryClass rep = RepositoryClass::RepositoryClass(); rep.loadFromFlie(lista); for (int pozitia = 0;pozitia < lista.getLength(); ++pozitia) if(lista[pozitia].getId() == id) return pozitia; return -1; lista.~DynamicList(); }
Foam::patchInteractionDataList::patchInteractionDataList ( const polyMesh& mesh, const dictionary& dict ) : List<patchInteractionData>(dict.lookup("patches")), patchGroupIDs_(this->size()) { const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); const wordList allPatchNames = bMesh.names(); const List<patchInteractionData>& items = *this; forAllReverse(items, i) { const word& patchName = items[i].patchName(); labelList patchIDs = findStrings(patchName, allPatchNames); if (patchIDs.empty()) { WarningInFunction << "Cannot find any patch names matching " << patchName << endl; } patchGroupIDs_[i].transfer(patchIDs); } // Check that all patches are specified DynamicList<word> badPatches; forAll(bMesh, patchI) { const polyPatch& pp = bMesh[patchI]; if ( !pp.coupled() && !isA<emptyPolyPatch>(pp) && !isA<cyclicAMIPolyPatch>(pp) && applyToPatch(pp.index()) < 0 ) { badPatches.append(pp.name()); } } if (badPatches.size() > 0) { FatalErrorInFunction << "All patches must be specified when employing local patch " << "interaction. Please specify data for patches:" << nl << badPatches << nl << exit(FatalError); } }
void Foam::directAMI<SourcePatch, TargetPatch>::appendToDirectSeeds ( boolList& mapFlag, labelList& srcTgtSeed, DynamicList<label>& srcSeeds, DynamicList<label>& nonOverlapFaces, label& srcFaceI, label& tgtFaceI ) const { const labelList& srcNbr = this->srcPatch_.faceFaces()[srcFaceI]; const labelList& tgtNbr = this->tgtPatch_.faceFaces()[tgtFaceI]; const pointField& srcPoints = this->srcPatch_.points(); const pointField& tgtPoints = this->tgtPatch_.points(); const vectorField& srcCf = this->srcPatch_.faceCentres(); forAll(srcNbr, i) { label srcI = srcNbr[i]; if (mapFlag[srcI] && srcTgtSeed[srcI] == -1) { const face& srcF = this->srcPatch_[srcI]; const vector srcN = srcF.normal(srcPoints); bool found = false; forAll(tgtNbr, j) { label tgtI = tgtNbr[j]; const face& tgtF = this->tgtPatch_[tgtI]; pointHit ray = tgtF.ray(srcCf[srcI], srcN, tgtPoints); if (ray.hit()) { // new match - append to lists found = true; srcTgtSeed[srcI] = tgtI; srcSeeds.append(srcI); break; } } if (!found) { // no match available for source face srcI mapFlag[srcI] = false; nonOverlapFaces.append(srcI); } }
Foam::fileNameList Foam::dlLoaded() { DynamicList<fileName> libs; dl_iterate_phdr(collectLibsCallback, &libs); if (POSIX::debug) { std::cout << "dlLoaded()" << " : determined loaded libraries :" << libs.size() << std::endl; } return libs; }
// Handle (non-processor) coupled faces. void Foam::regionSplit::transferCoupledFaceRegion ( const label faceI, const label otherFaceI, labelList& faceRegion, DynamicList<label>& newChangedFaces ) const { if (faceRegion[faceI] >= 0) { if (faceRegion[otherFaceI] == -1) { faceRegion[otherFaceI] = faceRegion[faceI]; newChangedFaces.append(otherFaceI); } else if (faceRegion[otherFaceI] == -2) { // otherFaceI blocked but faceI is not. Is illegal for coupled // faces, not for explicit connections. } else if (faceRegion[otherFaceI] != faceRegion[faceI]) { FatalErrorIn ( "regionSplit::transferCoupledFaceRegion" "(const label, const label, labelList&, labelList&) const" ) << "Problem : coupled face " << faceI << " on patch " << mesh_.boundaryMesh().whichPatch(faceI) << " has region " << faceRegion[faceI] << " but coupled face " << otherFaceI << " has region " << faceRegion[otherFaceI] << endl << "Is your blocked faces specification" << " synchronized across coupled boundaries?" << abort(FatalError); } } else if (faceRegion[faceI] == -1) { if (faceRegion[otherFaceI] >= 0) { faceRegion[faceI] = faceRegion[otherFaceI]; newChangedFaces.append(faceI); } else if (faceRegion[otherFaceI] == -2) { // otherFaceI blocked but faceI is not. Is illegal for coupled // faces, not for explicit connections. } } }
bool Foam::functionEntries::ifeqEntry::evaluate ( const bool doIf, DynamicList<filePos>& stack, dictionary& parentDict, Istream& is ) { while (!is.eof()) { token t; readToken(t, is); if (t.isWord() && t.wordToken() == "#ifeq") { // Recurse to evaluate execute(stack, parentDict, is); } else if (t.isWord() && t.wordToken() == "#if") { // Recurse to evaluate ifEntry::execute(stack, parentDict, is); } else if ( doIf && t.isWord() && (t.wordToken() == "#else" || t.wordToken() == "#elif") ) { // Now skip until #endif skipUntil(stack, parentDict, "#endif", is); stack.remove(); break; } else if (t.isWord() && t.wordToken() == "#endif") { stack.remove(); break; } else { is.putBack(t); bool ok = entry::New(parentDict, is); if (!ok) { return false; } } } return true; }
void refine ( cellShapeControlMesh& mesh, const conformationSurfaces& geometryToConformTo, const label maxRefinementIterations, const scalar defaultCellSize ) { for (label iter = 0; iter < maxRefinementIterations; ++iter) { DynamicList<point> ptsToInsert; for ( CellSizeDelaunay::Finite_cells_iterator cit = mesh.finite_cells_begin(); cit != mesh.finite_cells_end(); ++cit ) { const point newPoint = topoint ( CGAL::centroid ( cit->vertex(0)->point(), cit->vertex(1)->point(), cit->vertex(2)->point(), cit->vertex(3)->point() ) ); if (geometryToConformTo.inside(newPoint)) { ptsToInsert.append(newPoint); } } Info<< " Adding " << returnReduce(ptsToInsert.size(), sumOp<label>()) << endl; forAll(ptsToInsert, ptI) { mesh.insert ( ptsToInsert[ptI], defaultCellSize, triad::unset, Vb::vtInternal ); } }
/* functia incarca in lista elementele din fisier api cauta in lista cheltuiala dupa numar daca aceasta cheltuiala este gasita atunci se efectuiaza stergerea, daca nu se afiseaza ca elementul nu e in lista */ void ControllerClass::deleteController(int id) { DynamicList lista; RepositoryClass rep = RepositoryClass::RepositoryClass(); rep.loadFromFlie(lista); int cautare = findById(id); if (cautare != -1 ) { lista.deletePosition(cautare); rep.saveInFile(lista); cout << "Stergerea s-a efectuat cu succes" << endl; } else cout << "Cheltuiala respectiva nu se afla in lista" << endl; }
void addAndExtend ( DynamicList<label>& indizes, label celli, label val ) { if (indizes.size() < (celli+1)) { indizes.setSize(celli+1,-1); } indizes[celli] = val; }
Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::NewType ( const fvMesh& mesh, const word& thermoType ) { // get model name, but do not register the dictionary // otherwise it is registered in the database twice const word modelType ( IOdictionary ( IOobject ( "thermophysicalProperties", mesh.time().constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ) ).lookup("thermoType") ); if (modelType.find(thermoType) == string::npos) { wordList allModels = fvMeshConstructorTablePtr_->sortedToc(); DynamicList<word> validModels; forAll(allModels, i) { if (allModels[i].find(thermoType) != string::npos) { validModels.append(allModels[i]); } } FatalErrorIn ( "autoPtr<hCombustionThermo> hCombustionThermo::NewType" "(" "const fvMesh&, " "const word&" ")" ) << "Inconsistent thermo package selected:" << nl << nl << modelType << nl << nl << "Please select a " << "thermo package based on " << thermoType << ". Valid options include:" << nl << validModels << nl << exit(FatalError); }
void ControllerClass::sortAmountController(DynamicList & lista){ DomainClass aux,aux1; RepositoryClass rep = RepositoryClass::RepositoryClass(); rep.loadFromFlie(lista); for (int i = 0;i < lista.getLength()-1; ++i) for(int j = i+1; j < lista.getLength(); ++j) if (lista[i].getAmount() > lista[j].getAmount()) { aux = lista[i]; aux1 = lista[j]; lista.updatePosition(i,aux1); lista.updatePosition(j,aux); } }
void Foam::sampledSets::lineUniform::calcSamples ( DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<label>& samplingSegments, DynamicList<scalar>& samplingCurveDist ) const { label sampleSegmentI = 0, sampleI = 0; scalar sampleT = 0; while (sampleI < nPoints_) { const point pt = (1 - sampleT)*start_ + sampleT*end_; const label sampleCellI = searchEngine().findCell(pt); if (sampleCellI == -1) { if (++ sampleI < nPoints_) { sampleT = scalar(sampleI)/(nPoints_ - 1); } } else { passiveParticle sampleParticle(mesh(), pt, sampleCellI); do { samplingPts.append(sampleParticle.position()); samplingCells.append(sampleParticle.cell()); samplingFaces.append(-1); samplingSegments.append(sampleSegmentI); samplingCurveDist.append(sampleT*mag(end_ - start_)); if (++ sampleI < nPoints_) { sampleT = scalar(sampleI)/(nPoints_ - 1); sampleParticle.track((end_ - start_)/(nPoints_ - 1), 0); } } while (sampleI < nPoints_ && !sampleParticle.onBoundaryFace()); ++ sampleSegmentI; } } }
void Foam::shortEdgeFilter2D::addRegion ( const label regionI, DynamicList<label>& bPointRegions ) const { if (bPointRegions.empty()) { bPointRegions.append(regionI); } else if (findIndex(bPointRegions, regionI) == -1) { bPointRegions.append(regionI); } }
void ControllerClass::sortTypeControllerDesc(DynamicList & lista){ DomainClass aux,aux1; RepositoryClass rep = RepositoryClass::RepositoryClass(); rep.loadFromFlie(lista); for (int i = 0;i <= lista.getLength()-1; ++i) for(int j = i;j < lista.getLength(); ++j) if (strcmp(lista[i].getType(),lista[j].getType()) < 0) { aux = lista[i]; aux1 = lista[j]; lista.updatePosition(i,aux1); lista.updatePosition(j,aux); } }
Foam::label Foam::face::triangles ( const pointField& points, DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces ) const { label triI = triFaces.size(); label quadI = 0; faceList quadFaces; // adjust the addressable size (and allocate space if needed) triFaces.setSize(triI + nTriangles()); return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces); }
void ControllerClass::updateController(int id,int number,float amount,char* type) { DomainClass element; element = DomainClass::DomainClass(id,number,amount,type); DynamicList lista; RepositoryClass rep = RepositoryClass::RepositoryClass(); rep.loadFromFlie(lista); int cautare = findById(id); if (cautare != -1 ) { lista.updatePosition(cautare,element); rep.saveInFile(lista); cout << "Modificarea s-a efectuat cu succes" << endl; } else cout << "Cheltuiala respectiva nu se afla in lista" << endl; }
forAll(refineFaces, i) { if(refineFaces[i]) { refineF.append(i); } }