Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 420
    • Issues 420
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #2025
Closed
Open
Issue created Mar 11, 2021 by Henning Scheufler@Henning86

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 Mar 11, 2021 by Henning Scheufler
Assignee
Assign to
Time tracking