fixed: do not assert conditions guaranteed by unsigned

This commit is contained in:
Arne Morten Kvarving 2021-06-18 13:26:57 +02:00
parent eab6faeea3
commit 44267fd206
10 changed files with 19 additions and 20 deletions

View File

@ -203,7 +203,7 @@ public:
*/
void globalPhaseStorage(EqVector& storage, unsigned phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
assert(phaseIdx < numPhases);
storage = 0;

View File

@ -91,7 +91,6 @@ public:
*/
int localToGlobalDof(unsigned localDofIdx) const
{
assert(0 <= localDofIdx);
assert(localDofIdx < numDofs());
return dofOffset_ + localDofIdx;
}

View File

@ -409,7 +409,7 @@ public:
const IntensiveQuantities& intensiveQuantities(unsigned dofIdx, unsigned timeIdx) const
{
#ifndef NDEBUG
assert(0 <= dofIdx && dofIdx < numDof(timeIdx));
assert(dofIdx < numDof(timeIdx));
if (enableStorageCache_ && timeIdx != 0 && problem().recycleFirstIterationStorage())
throw std::logic_error("If caching of the storage term is enabled, only the intensive quantities "
@ -429,7 +429,7 @@ public:
*/
const IntensiveQuantities *thermodynamicHint(unsigned dofIdx, unsigned timeIdx) const
{
assert(0 <= dofIdx && dofIdx < numDof(timeIdx));
assert(dofIdx < numDof(timeIdx));
return dofVars_[dofIdx].thermodynamicHint[timeIdx];
}
/*!
@ -437,7 +437,7 @@ public:
*/
IntensiveQuantities& intensiveQuantities(unsigned dofIdx, unsigned timeIdx)
{
assert(0 <= dofIdx && dofIdx < numDof(timeIdx));
assert(dofIdx < numDof(timeIdx));
return dofVars_[dofIdx].intensiveQuantities[timeIdx];
}
@ -451,7 +451,7 @@ public:
*/
PrimaryVariables& primaryVars(unsigned dofIdx, unsigned timeIdx)
{
assert(0 <= dofIdx && dofIdx < numDof(timeIdx));
assert(dofIdx < numDof(timeIdx));
return dofVars_[dofIdx].priVars[timeIdx];
}
/*!
@ -459,7 +459,7 @@ public:
*/
const PrimaryVariables& primaryVars(unsigned dofIdx, unsigned timeIdx) const
{
assert(0 <= dofIdx && dofIdx < numDof(timeIdx));
assert(dofIdx < numDof(timeIdx));
return dofVars_[dofIdx].priVars[timeIdx];
}
@ -488,7 +488,7 @@ public:
*/
void stashIntensiveQuantities(unsigned dofIdx)
{
assert(0 <= dofIdx && dofIdx < numDof(/*timeIdx=*/0));
assert(dofIdx < numDof(/*timeIdx=*/0));
intensiveQuantitiesStashed_ = dofVars_[dofIdx].intensiveQuantities[/*timeIdx=*/0];
priVarsStashed_ = dofVars_[dofIdx].priVars[/*timeIdx=*/0];

View File

@ -311,7 +311,7 @@ public:
*/
unsigned globalSpaceIndex(unsigned dofIdx) const
{
assert(0 <= dofIdx && dofIdx < numDof());
assert(dofIdx < numDof());
return static_cast<unsigned>(elementMapper_.index(element(dofIdx)));
}
@ -331,7 +331,7 @@ public:
*/
const Element& element(unsigned dofIdx) const
{
assert(0 <= dofIdx && dofIdx < numDof());
assert(dofIdx < numDof());
return elements_[dofIdx];
}

View File

@ -1070,7 +1070,7 @@ public:
const SubControlVolume& subControlVolume(unsigned scvIdx) const
{
assert(0 <= scvIdx && scvIdx < numDof());
assert(scvIdx < numDof());
return subContVol[scvIdx];
}
@ -1092,7 +1092,7 @@ public:
*/
unsigned globalSpaceIndex(unsigned dofIdx) const
{
assert(0 <= dofIdx && dofIdx < numDof());
assert(dofIdx < numDof());
return static_cast<unsigned>(vertexMapper_.subIndex(element_, static_cast<int>(dofIdx), /*codim=*/dim));
}

View File

@ -350,7 +350,7 @@ public:
#ifndef NDEBUG
unsigned compIdx = eqIdx - Indices::conti0EqIdx;
assert(0 <= compIdx && compIdx <= numPhases);
assert(compIdx <= numPhases);
#endif
// make all kg equal

View File

@ -400,7 +400,7 @@ public:
else if (fugacity0Idx <= pvIdx && pvIdx < fugacity0Idx + numComponents) {
// component fugacity
unsigned compIdx = pvIdx - fugacity0Idx;
assert(0 <= compIdx && compIdx <= numComponents);
assert(compIdx <= numComponents);
Opm::Valgrind::CheckDefined(minActivityCoeff_[globalDofIdx][compIdx]);
static const Scalar fugacityBaseWeight =
@ -414,7 +414,7 @@ public:
else {
#ifndef NDEBUG
unsigned phaseIdx = pvIdx - saturation0Idx;
assert(0 <= phaseIdx && phaseIdx < numPhases - 1);
assert(phaseIdx < numPhases - 1);
#endif
// saturation
@ -444,7 +444,7 @@ public:
// a mass conservation equation
unsigned compIdx = eqIdx - Indices::conti0EqIdx;
assert(0 <= compIdx && compIdx <= numComponents);
assert(compIdx <= numComponents);
// make all kg equal
return FluidSystem::molarMass(compIdx);

View File

@ -165,7 +165,7 @@ public:
*/
DataType& operator[](size_t i)
{
assert(0 <= i && i < dataSize_);
assert(i < dataSize_);
return data_[i];
}
@ -174,7 +174,7 @@ public:
*/
const DataType& operator[](size_t i) const
{
assert(0 <= i && i < dataSize_);
assert(i < dataSize_);
return data_[i];
}

View File

@ -424,7 +424,7 @@ public:
return tmp;
unsigned compIdx = eqIdx - Indices::conti0EqIdx;
assert(0 <= compIdx && compIdx <= numComponents);
assert(compIdx <= numComponents);
// make all kg equal
return FluidSystem::molarMass(compIdx);

View File

@ -347,7 +347,7 @@ public:
Scalar eqWeight(unsigned globalDofIdx OPM_UNUSED, unsigned OPM_OPTIM_UNUSED eqIdx) const
{
unsigned OPM_OPTIM_UNUSED compIdx = eqIdx - Indices::contiEqIdx;
assert(0 <= compIdx && compIdx <= FluidSystem::numPhases);
assert(compIdx <= FluidSystem::numPhases);
// make all kg equal
return 1.0;