From 8f499e1b7198cf03a264d4582420d8d3b1214899 Mon Sep 17 00:00:00 2001 From: Georgios Koukougkelis Date: Tue, 25 Aug 2026 15:16:22 +0200 Subject: [PATCH] BUG: heightFunction implementation gives wrong results in parallel and with non-uniform mesh heightFunction::correct() used the mesh average cell delta to calculate curvature. This gives wrong results in cases using AMR where the mesh is locally refined. In heightFunction::computeColumns, a return statement was added because the iterator would advance even when the current cell was not local anymore, leading to incomplete column. In case a parallel stencil was found in the primary direction, the code would add it to the parallelStencil list and then continue testing the next direction. A break statement was added to avoid this. Parallel columns would skip calculation of the first cell across the processor boundary. Finally, K_.correctBoundaryConditions() which is needed for correct interpolation of the curvature field on the faces later. --- .../heightFunction/heightFunction.C | 92 ++++++++++++------- 1 file changed, 58 insertions(+), 34 deletions(-) diff --git a/src/surfaceForces/surfaceTensionForceModels/surfaceTensionForceModel/heightFunction/heightFunction.C b/src/surfaceForces/surfaceTensionForceModels/surfaceTensionForceModel/heightFunction/heightFunction.C index 74dd9de4..7b5f5ded 100644 --- a/src/surfaceForces/surfaceTensionForceModels/surfaceTensionForceModel/heightFunction/heightFunction.C +++ b/src/surfaceForces/surfaceTensionForceModels/surfaceTensionForceModel/heightFunction/heightFunction.C @@ -100,7 +100,6 @@ void Foam::heightFunction::computeColumns return; } - scalar avgColVal = 0.5; DynamicField alphaValues(100); // should be big enough avoids resizing for (label i = HFCol.status[orientation].iterI;i<7;i++) // move four times in both direction @@ -132,6 +131,10 @@ void Foam::heightFunction::computeColumns ); } } + else + { + return; + } if (fullColumn(HFCol.status[orientation].avgColVal,columnHeightTol) ) { @@ -319,7 +322,6 @@ void Foam::heightFunction::correct() deltaFunctionModel_->correct(); const fvMesh& mesh = alpha1_.mesh(); - const surfaceVectorField& Sf = mesh.Sf(); reconstructionSchemes& surf = mesh.lookupObjectRef("reconstructionScheme"); @@ -334,8 +336,6 @@ void Foam::heightFunction::correct() boolList nextToInterface(mesh.nCells(),false); - scalar deltaX = mag(mesh_.delta())().average().value(); - volScalarField cellDistField ( IOobject @@ -414,10 +414,22 @@ void Foam::heightFunction::correct() dimensionedScalar("scalar", dimless, 0), "calculated" //alpha1.boundaryField().types() ); - label test = twoDim_ ? 2 : 3; Vector