Description: Drop variables that are set but never read GCC 16 rejects them under -Wunused-but-set-variable, which is fatal here because of -Werror. Author: Anton Gladky Forwarded: no Last-Update: 2026-08-11 Index: yade/lib/triangulation/KinematicLocalisationAnalyser.cpp =================================================================== --- yade.orig/lib/triangulation/KinematicLocalisationAnalyser.cpp +++ yade/lib/triangulation/KinematicLocalisationAnalyser.cpp @@ -631,15 +631,12 @@ namespace CGT { n_persistent = 0; n_new = 0; n_lost = 0; - long lost_in_state0 = 0; - for (int i = 0; i < Nc0; ++i) { + for (int i = 0; i < Nc0; ++i) TS0->contacts[i]->visited = false; - if (TS0->contacts[i]->status == TriaxialState::Contact::LOST) ++lost_in_state0; - } for (int i = 0; i < Nc1; ++i) TS1->contacts[i]->visited = false; - //cerr << "Nc1 "<contacts[i]->status != TriaxialState::Contact::LOST) { Index: yade/pkg/common/InsertionSortCollider.cpp =================================================================== --- yade.orig/pkg/common/InsertionSortCollider.cpp +++ yade/pkg/common/InsertionSortCollider.cpp @@ -296,7 +296,6 @@ void InsertionSortCollider::action() } // Handle erased bodies - int countNoBound = 0; if (nErased > 0) { for (const auto& id : erased) if (3 * (id + 1) <= (int)minima.size()) @@ -315,7 +314,6 @@ void InsertionSortCollider::action() if (idxTarget < idx) BBi[idxTarget] = BBi[idx]; idxTarget++; } else { - if (i == 0 and Body::byId(id, scene) and not Body::byId(id, scene)->isBounded()) countNoBound++; continue; } } Index: yade/pkg/dem/CapillaryStressRecorder.cpp =================================================================== --- yade.orig/pkg/dem/CapillaryStressRecorder.cpp +++ yade/pkg/dem/CapillaryStressRecorder.cpp @@ -99,7 +99,7 @@ void CapillaryStressRecorder::action() Real V = (triaxialCompressionEngine->height) * (triaxialCompressionEngine->width) * (triaxialCompressionEngine->depth); /// Solid volume - Real Vs = 0, Rbody = 0, SR = 0; + Real Vs = 0, Rbody = 0; for (const auto& b : *bodies) { if (b->shape->getClassIndex() != Sphere::getClassIndexStatic()) continue; @@ -107,7 +107,6 @@ void CapillaryStressRecorder::action() if (sphere) { Rbody = sphere->radius; - SR += Rbody; Vs += 1.333 * Mathr::PI * (Rbody * Rbody * Rbody); } } Index: yade/pkg/dem/TesselationWrapper.cpp =================================================================== --- yade.orig/pkg/dem/TesselationWrapper.cpp +++ yade/pkg/dem/TesselationWrapper.cpp @@ -84,7 +84,6 @@ void build_triangulation_with_ids(const Body::id_t Ng = 0; Body::id_t& MaxId = Tes.maxId; TW.mean_radius = 0; - int nonSpheres = 0; shared_ptr sph(new Sphere); int Sph_Index = sph->getClassIndexStatic(); Scene* scene = Omega::instance().getScene().get(); @@ -102,8 +101,7 @@ void build_triangulation_with_ids(const Ng++; TW.mean_radius += rad; MaxId = max(MaxId, bi->getId()); - } else - ++nonSpheres; + } } TW.mean_radius /= Ng; TW.rad_divided = true; Index: yade/pkg/openfoam/FoamCoupling.cpp =================================================================== --- yade.orig/pkg/openfoam/FoamCoupling.cpp +++ yade/pkg/openfoam/FoamCoupling.cpp @@ -437,7 +437,6 @@ void FoamCoupling::verifyParticleDetecti if (unFoundSharedIds.size() > 0) { for (const auto& idPair : sharedIdsMapIndx) { const auto& bodyId = idPair.first; - int foundCount = 0; //const int mpSz = idPair.second.size(); bool found = false; for (const auto& fdIndx : idPair.second) { @@ -446,7 +445,6 @@ void FoamCoupling::verifyParticleDetecti if (vt.first == flbox->domainRank) { if (vt.second[fdIndx.second] > 0) { found = true; - ++foundCount; // uncomment me for debugging.. // std::cout << "foundcount for bId = " << idPair.first << " " << foundCount << std::endl; // std::cout << "totsize for bId = " << idPair.first << " " << idPair.second.size() << std::endl; Index: yade/pkg/pfv/FlowBoundingSphere.ipp =================================================================== --- yade.orig/pkg/pfv/FlowBoundingSphere.ipp +++ yade/pkg/pfv/FlowBoundingSphere.ipp @@ -102,13 +102,11 @@ namespace CGT { if (noCache && T[!currentTes].Max_id() <= 0) return; RTriangulation& Tri = lastSolution().Triangulation(); Point posAvFacet; - int numCells = 0; Real facetFlowRate = 0; FiniteCellsIterator cellEnd = Tri.finite_cells_end(); for (FiniteCellsIterator cell = Tri.finite_cells_begin(); cell != cellEnd; cell++) { if (cell->info().isGhost or cell->info().isAlpha) continue; cell->info().averageVelocity() = CGAL::NULL_VECTOR; - numCells++; Real totFlowRate = 0; //used to acount for influxes in elements where pressure is imposed for (int i = 0; i < 4; i++) if (!Tri.is_infinite(cell->neighbor(i))) { @@ -302,15 +300,11 @@ namespace CGT { template Real FlowBoundingSphere::averagePressure() { RTriangulation& Tri = lastSolution().Triangulation(); - Real P = 0.f, Ppond = 0.f, Vpond = 0.f; - int n = 0; + Real Ppond = 0.f, Vpond = 0.f; for (FiniteCellsIterator cell = Tri.finite_cells_begin(); cell != Tri.finite_cells_end(); cell++) { - P += cell->info().p(); - n++; Ppond += cell->info().p() * math::abs(cell->info().volume()); Vpond += math::abs(cell->info().volume()); } - P /= n; Ppond /= Vpond; return Ppond; } @@ -1076,7 +1070,7 @@ namespace CGT { reApplyBoundaryConditions(); RTriangulation& Tri = T[currentTes].Triangulation(); int j = 0; - Real m, n, dp_max, p_max, sum_p, p_moy, dp, sum_dp; + Real m, n, dp_max, p_max, sum_p, p_moy, dp; Real compFlowFactor = 0; vector previousP; previousP.resize(Tri.number_of_finite_cells()); @@ -1111,7 +1105,6 @@ namespace CGT { p_max = 0; p_moy = 0; sum_p = 0; - sum_dp = 0; #ifdef GS_OPEN_MP cell2 = numCells; for (int ii = 0; ii < num_threads; ii++) @@ -1124,7 +1117,7 @@ namespace CGT { t_sum_dp[ii] = 0; int kk = 0; const int numCells2 = numCells; -#pragma omp parallel for private(dp, m, n, kk) shared(tolerance, t_sum_dp, t_dp_max, sum_p, sum_dp, cells_its, j, Tri, relax) schedule(dynamic, 1000) +#pragma omp parallel for private(dp, m, n, kk) shared(tolerance, t_sum_dp, t_dp_max, sum_p, cells_its, j, Tri, relax) schedule(dynamic, 1000) for (kk = 0; kk < numCells2; kk++) { const FiniteCellsIterator& cell = cells_its[kk]; { @@ -1190,7 +1183,6 @@ namespace CGT { dp_max = max(dp_max, math::abs(dp)); p_max = max(p_max, math::abs(cell->info().p())); sum_p += math::abs(cell->info().p()); - sum_dp += math::abs(dp); #endif } } @@ -1202,8 +1194,6 @@ namespace CGT { dp_max = max(dp_max, t_dp_max[ii]); for (int ii = 0; ii < num_threads; ii++) sum_p += t_sum_p[ii]; - for (int ii = 0; ii < num_threads; ii++) - sum_dp += t_sum_dp[ii]; #endif p_moy = sum_p / cell2; Index: yade/pkg/pfv/PartialSatClayEngine.cpp =================================================================== --- yade.orig/pkg/pfv/PartialSatClayEngine.cpp +++ yade/pkg/pfv/PartialSatClayEngine.cpp @@ -464,14 +464,12 @@ void PartialSatClayEngine::setPorosityWi } std::vector gridCoords; std::vector porosities; - int l = 0; Real x, y, z, porosity2; while (file >> x >> y >> z >> porosity2) { gridCoords.push_back(Vector3r(x, y, z)); //gridCoords[l][1] = y; //gridCoords[l][2] = z; porosities.push_back(porosity2); - l++; } cout << "finished creating coords vec and porosities" << endl; Tesselation& Tes = flow.T[flow.currentTes]; Index: yade/pkg/pfv/PeriodicFlow.hpp =================================================================== --- yade.orig/pkg/pfv/PeriodicFlow.hpp +++ yade/pkg/pfv/PeriodicFlow.hpp @@ -481,7 +481,7 @@ namespace CGT { { RTriangulation& Tri = T[currentTes].Triangulation(); int j = 0; - Real m, n, dp_max, p_max, sum_p, dp, sum_dp; + Real m, n, dp_max, p_max, dp; Real compFlowFactor = 0; vector previousP; previousP.resize(Tri.number_of_finite_cells()); @@ -495,16 +495,12 @@ namespace CGT { t_sum_p.resize(num_threads); FiniteCellsIterator cellEnd = Tri.finite_cells_end(); do { - int cell2 = 0; dp_max = 0; p_max = 0; - sum_p = 0; - sum_dp = 0; int bb = -1; for (FiniteCellsIterator cell = Tri.finite_cells_begin(); cell != cellEnd; cell++) { bb++; if (!cell->info().Pcondition && !cell->info().isGhost) { - cell2++; if (compressible && j == 0) previousP[bb] = cell->info().shiftedP(); m = 0, n = 0; for (int j2 = 0; j2 < 4; j2++) { @@ -547,8 +543,6 @@ namespace CGT { dp -= cell->info().p(); dp_max = math::max(dp_max, math::abs(dp)); p_max = math::max(p_max, math::abs(cell->info().shiftedP())); - sum_p += cell->info().shiftedP(); - sum_dp += math::abs(dp); } } j++; @@ -556,14 +550,6 @@ namespace CGT { if (j >= 40000) cerr << "\r GS not converged after 40k iterations, break"; } while ((dp_max / p_max) > tolerance && j < 40000 /*&& ( dp_max > tolerance )*/ /* &&*/ /*( j<50 )*/); - - int cel = 0; - Real Pav = 0; - for (FiniteCellsIterator cell = Tri.finite_cells_begin(); cell != cellEnd; cell++) { - cel++; - Pav += cell->info().shiftedP(); - } - Pav /= cel; } template void PeriodicFlow<_Tesselation>::displayStatistics() Index: yade/pkg/pfv/TwoPhaseFlowEngine.cpp =================================================================== --- yade.orig/pkg/pfv/TwoPhaseFlowEngine.cpp +++ yade/pkg/pfv/TwoPhaseFlowEngine.cpp @@ -2564,7 +2564,7 @@ void TwoPhaseFlowEngine::updateDeformati { RTriangulation& tri = solver->T[solver->currentTes].Triangulation(); FiniteCellsIterator cellEnd = tri.finite_cells_end(); - Real dv = 0.0, summ = 0.0, summBC = 0.0, summMC = 0.0, SolidVolume = 0.0, dvSwelling = 0.0; + Real dv = 0.0, dvSwelling = 0.0; if (!imposeDeformationFluxTPFSwitch) { setPositionsBuffer(true); @@ -2593,9 +2593,6 @@ void TwoPhaseFlowEngine::updateDeformati - cell->info().dv(); if (cell->info().isNWRes || listOfPores[cell->info().poreId]->info().isNWRes) { cell->info().dvSwelling = 0.0; } cell->info().dv() = (volume - cell->info().poreBodyVolume) * invTime; - SolidVolume += solidVol; - summ += cell->info().dv(); - summBC += cell->info().dv(); } } } @@ -2613,7 +2610,6 @@ void TwoPhaseFlowEngine::updateDeformati listOfPores[i]->info().accumulativeDV = dv; listOfPores[i]->info().accumulativeDVSwelling = dvSwelling; - summMC += dv; } if (swelling) { Index: yade/pkg/potential/Gl1_PotentialBlock.cpp =================================================================== --- yade.orig/pkg/potential/Gl1_PotentialBlock.cpp +++ yade/pkg/potential/Gl1_PotentialBlock.cpp @@ -437,7 +437,6 @@ void PotentialBlockVTKRecorder::action() blockId->SetName("id"); // bodyId ############################################################## //#endif - int countID = 0; vtkSmartPointer textArray2[scene->bodies->size()]; vtkSmartPointer txtMapper[scene->bodies->size()]; vtkSmartPointer extrude[scene->bodies->size()]; @@ -501,7 +500,6 @@ void PotentialBlockVTKRecorder::action() //polydata->DeleteCells(); #endif - countID++; } //vtkSmartPointer function = ImpFuncPB::New(); vtkSmartPointer boolFunction = vtkSmartPointer::New(); @@ -526,13 +524,11 @@ void PotentialBlockVTKRecorder::action() function->k = pb->k; //Matrix3r directionCos = b->state->ori.conjugate().toRotationMatrix(); //FIXME Matrix3r rotation = b->state->ori.conjugate().toRotationMatrix(); //*pb->oriAabb.conjugate(); - int count = 0; function->clump = false; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { //function->rotationMatrix[count] = directionCos(j,i); function->rotationMatrix(i, j) = rotation(i, j); //input is actually direction cosine? - count++; } } Index: yade/pkg/potential/Gl1_PotentialParticle.cpp =================================================================== --- yade.orig/pkg/potential/Gl1_PotentialParticle.cpp +++ yade/pkg/potential/Gl1_PotentialParticle.cpp @@ -361,7 +361,6 @@ void PotentialParticleVTKRecorder::actio blockId->SetNumberOfComponents(1); blockId->SetName("id"); // bodyId ############################################################## - int countID = 0; vtkSmartPointer textArray2[scene->bodies->size()]; vtkSmartPointer txtMapper[scene->bodies->size()]; vtkSmartPointer extrude[scene->bodies->size()]; @@ -381,7 +380,6 @@ void PotentialParticleVTKRecorder::actio pid[0] = pbPosID->InsertNextPoint(pos); pbIdCells->InsertNextCell(1, pid); - countID++; } //vtkSmartPointer function = ImpFunc::New(); function->a = pb->a; @@ -392,12 +390,10 @@ void PotentialParticleVTKRecorder::actio function->r = pb->r; function->k = pb->k; Matrix3r directionCos = b->state->ori.conjugate().toRotationMatrix(); - int count = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { //function->rotationMatrix[count] = directionCos(j,i); function->rotationMatrix(i, j) = directionCos(j, i); - count++; } } Index: yade/pkg/potential/Ig2_PB_PB_ScGeom.cpp =================================================================== --- yade.orig/pkg/potential/Ig2_PB_PB_ScGeom.cpp +++ yade/pkg/potential/Ig2_PB_PB_ScGeom.cpp @@ -304,7 +304,7 @@ bool Ig2_PB_PB_ScGeom::go( /* Real JRC1=0.0, JRC2=0.0, JSC1=0.0, JSC2=0.0, sigmaC1=0.0, sigmaC2=0.0, asperity1=0.0, asperity2=0.0; */ /* Real lambda01=0.0, lambda02=0.0, heatCapacity1=0.0, heatCapacity2=0.0, hwater1 = 0.0, hwater2 = 0.0; */ - Real f1 = evaluatePhys( + evaluatePhys( cm1, state1, Vector3r(0, 0, 0), @@ -316,7 +316,7 @@ bool Ig2_PB_PB_ScGeom::go( /* lambda01, heatCapacity1, hwater1, */ intactRock1, noActive1, jointType1); - Real f2 = evaluatePhys( + evaluatePhys( cm2, state2, shift2, @@ -329,8 +329,7 @@ bool Ig2_PB_PB_ScGeom::go( noActive2, jointType2); - f1 += 0; - f2 += 0; //FIXME: These two statements are added to mute compiler warnings for unused parameters f1, f2. To be amended soon, by changing the type of evaluatePhys to "void", instead of "Real" + //FIXME: evaluatePhys() should return "void", its result is never used. if (s1->isBoundary == true) { phys->phi_b = phi_b1; @@ -1575,7 +1574,7 @@ Vector3r Ig2_PB_PB_ScGeom::getNormal(con ////////////////////////////// assembling potential planes particle 1////////////////////////////// int planeNo = s1->a.size(); vector p; - Real pSum2 = 0.0, plane; + Real plane; bool isSphere = true; int minNo = 0; Real closestDistance = pow(10, 12); @@ -1603,7 +1602,6 @@ Vector3r Ig2_PB_PB_ScGeom::getNormal(con } //if the contactPoint is not fully inside the inner PP, isSphere=false and the contact normal is calculated as the normal of the plane closest to the contactPoint; to be revised @vsangelidakis p.push_back( plane); //FIXME: Instead of saving the value of "plane" inside the vector "p" and iterate through "p[i]" in a different loop below, we can calculate pdxSum, pdySum, pdzSum directly here, and avoid storing all this information in the vector "p". In this way, we don't need "p" - pSum2 += pow(p[i], 2); } //Real r = s1->r; Real R = s1->R; Real k = s1->k; /* Additional sphere */ Index: yade/pkg/potential/Ig2_PP_PP_ScGeom.cpp =================================================================== --- yade.orig/pkg/potential/Ig2_PP_PP_ScGeom.cpp +++ yade/pkg/potential/Ig2_PP_PP_ScGeom.cpp @@ -565,12 +565,11 @@ Vector3r Ig2_PP_PP_ScGeom::getNormal(con ////////////////////////////// assembling potential planes particle 1////////////////////////////// int planeNo = s1->a.size(); vector p; - Real pSum2 = 0.0, plane; + Real plane; for (int i = 0; i < planeNo; i++) { plane = s1->a[i] * x + s1->b[i] * y + s1->c[i] * z - s1->d[i]; if (plane < pow(10, -15)) { plane = 0.0; } p.push_back(plane); - pSum2 += pow(p[i], 2); } Real r = s1->r; Real R = s1->R; @@ -679,7 +678,6 @@ bool Ig2_PP_PP_ScGeom::customSolve( PotentialParticle* s1 = static_cast(cm1.get()); PotentialParticle* s2 = static_cast(cm2.get()); Vector3r xGlobal(0.0, 0.0, 0.0); - int iter = 0; int totalIter = 0; /* Parameters for particles A and B */ @@ -1543,7 +1541,6 @@ bool Ig2_PP_PP_ScGeom::customSolve( return true; } t = math::min(t * mu, (2.0 * m + 1.0) / tol); - iter = 0; totalIter = totalIter + 1; } if (totalIter > 100) { @@ -1557,7 +1554,6 @@ bool Ig2_PP_PP_ScGeom::customSolve( return false; //break; } - iter++; totalIter++; //timingDeltas->checkpoint("complete"); Index: yade/pkg/potential/PotentialBlock.cpp =================================================================== --- yade.orig/pkg/potential/PotentialBlock.cpp +++ yade/pkg/potential/PotentialBlock.cpp @@ -431,7 +431,7 @@ void PotentialBlock::calculateInertia(Ve { Vector3r pointInside(0, 0, 0), vertex, planeNormal, oriNormal(0, 0, 1), crossProd, rotatedCoord; Vector3r pt1, pt2, pt3, baseOnPolygon, oriBaseOnPolygon, centroidPyramid, centroidTetra, tempVert1, tempVert2, tempVert3, tempVert4; - Real totalVolume = 0.0, /*plane,*/ det, area, height, vol, areaPyramid, volumePyramid, heightTetra, tempArea, areaTri, tetraVol; + Real totalVolume = 0.0, /*plane,*/ det, area, height, vol, heightTetra, tempArea, areaTri, tetraVol; Real detJ, x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4; Quaternionr Qp; unsigned int h, kk, m, counter; @@ -554,9 +554,7 @@ void PotentialBlock::calculateInertia(Ve totalVolume += vol; //std::cout<<"orderedVerticesOnPlane.size(): "<