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.
This commit is contained in:
Andrew Heather 2023-12-06 14:49:33 +00:00
parent 513fe05c21
commit 0d16e1a7c6

View File

@ -101,18 +101,29 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
::updateCoeffs()
void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
scalarField alphap
(
patch().lookupPatchField<volScalarField>(alphaName_)
);
const auto& mesh = patch().boundaryMesh().mesh();
auto& alpha = mesh.lookupObjectRef<volScalarField>(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));