Skip to content

flowrate(Inlet/Outlet)velocity division by zero

Summary

the flow rate can be zero resulting in a division by zero

relevant files:

  • flowRateOutletVelocityFvPatchVectorField.C
  • flowRateInletVelocityFvPatchVectorField.C
template<class RhoType>
void Foam::flowRateInletVelocityFvPatchVectorField::updateValues:

const scalar flowRate = flowRate_->value(t);
const scalar estimatedFlowRate = -gSum(rho*(this->patch().magSf()*nUp));

if (estimatedFlowRate/flowRate > 0.5) // division by zero possible
{
    nUp *= (mag(flowRate)/mag(estimatedFlowRate));
}

Possible fixes

flowRateDivisionByZero.patch

scalar flowRate = stabilize(flowRate_->value(t),SMALL);

Would be the "cleaner" coding option compared to:

scalar flowRate = flowRate_->value(t);
if (flowRate == 0)
{
    flowRate = SMALL
}

But the flowrate might be tiny in the same region as SMALL (e.g. micro scale simulation) and this might be problematic to debug by the user

Edited by Henning Scheufler