From 0d16e1a7c68aa0ba652197ba686d8cc87fd3883b Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Wed, 6 Dec 2023 14:49:33 +0000 Subject: [PATCH] ENH: variableHeightFlowRateInletVelocity BC - update for moving meshes. See #3012 Dynamic mesh updates trigger a velocity field update. For [this] BC the update can fail if the dependent alpha field has not already been updated. --- ...tFlowRateInletVelocityFvPatchVectorField.C | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C index 7318a394af..cc709fe383 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C @@ -101,18 +101,29 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField -::updateCoeffs() +void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField::updateCoeffs() { if (updated()) { return; } - scalarField alphap - ( - patch().lookupPatchField(alphaName_) - ); + const auto& mesh = patch().boundaryMesh().mesh(); + auto& alpha = mesh.lookupObjectRef(alphaName_); + + // Update alpha boundary (if needed) due to mesh changes + if (!mesh.upToDatePoints(alpha)) + { + auto& alphabf = alpha.boundaryFieldRef(); + + if (!alphabf[patch().index()].updated()) + { + DebugInfo<< "Updating alpha BC due to mesh changes" << endl; + alphabf.evaluateSelected(labelList({ patch().index() })); + } + } + + scalarField alphap(alpha.boundaryField()[patch().index()]); alphap = max(alphap, scalar(0)); alphap = min(alphap, scalar(1));