Skip to content

Crash during isoInterface.update() in controlDict functions{} #41

Closed as not planned

Description

@Ananth-Narayan-IITM

During blastAMR load balancing the issue was with isoInterface.update(); such that solver crashes. This has been systematically verified. There is an alternate way is that to create the functionObject called aspectRatio such that once simulation is over, reconstructParMesh and reconstructPar the files then run the postProcess -func as,

postProcess -dict system/aspectRatio -func bubblepproc -latestTime

This generates the data on the terminal which can be post processed

// File Name: aspectRatio
 /*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2406                                  |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    arch        "LSB;label=32;scalar=64";
    class       dictionary;
    location    "system";
    object      aspectRatio;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
functions
{

// **************************************************** //
// **** coded functionObject for bubble processing **** //
// **************************************************** //
bubblepproc
{
    // Load the library containing the 'coded' functionObject
    libs (utilityFunctionObjects);
    type coded;
    writeControl    writeTime;
    // Name of on-the-fly generated functionObject
    name bubblepproc;
    // List of include search directories
    codeOptions
    #{
        -I$(LIB_SRC)/sampling/lnInclude \
        -I$(LIB_SRC)/dynamicMesh/lnInclude \
        -I$(LIB_SRC)/surfMesh/lnInclude
    #};
    // List of libraries to link with
    codeLibs
    #{
        -lsampling \
        -ldynamicMesh \
        -lsurfMesh
    #};
    // List of include files
    codeInclude
    #{
        #include "sampledIsoSurface.H"
        #include "vtkSurfaceWriter.H"
    #};
    // Code
    codeWrite
    #{
        Info << "----------bubblepproc----------" << endl;

        // // Lookup velocity field U
        // const volVectorField& U = mesh().lookupObject<volVectorField>("U");

        // Lookup liquid fraction alpha_liquid
        // const volScalarField& alphaLiquid = mesh().lookupObject<volScalarField>("alpha.phase1");

        // // Compute weight (= gas fraction)
        // volScalarField weight
        // (
        //     IOobject
        //     (
        //         "weight",
        //         mesh().time().timeName(),
        //         U.mesh(),
        //         IOobject::NO_READ,
        //         IOobject::NO_WRITE
        //     ),
        //     (1-alphaLiquid)
        // );

        // Compute isosurface alpha=0.5
        dictionary isoSurfDict;
        isoSurfDict.add("type","isoSurface");
        isoSurfDict.add("isoField","alpha.phase1");
        isoSurfDict.add("isoValue",0.5);
        isoSurfDict.add("regularise","diagcell");
        isoSurfDict.add("snap","off");
        sampledIsoSurface isoInterface("isoInterface", mesh(), isoSurfDict);
        isoInterface.update();

        // // Compute bubble volume
        // dimensionedScalar bubbleVolume = fvc::domainIntegrate(weight); // This is integral of "weight" over the volume
        // Info << "bubble volume     = " << bubbleVolume.value() << endl;

        // // Compute bubble center
        // dimensionedVector Cb = fvc::domainIntegrate(weight*mesh().C())/bubbleVolume;
        // Info << "bubble centroid   = " << Cb.value() << endl;

        // // Compute rising velocity
        // dimensionedVector Ub = fvc::domainIntegrate(weight*U)/bubbleVolume;
        // Info << "bubble velocity   = " << Ub.value() << endl;

        // --------------------------------------------------
        // Compute deformation factor
        // --------------------------------------------------

        const pointField& pts = isoInterface.points();

        scalar xmin = GREAT;
        scalar xmax = -GREAT;

        scalar ymin = GREAT;
        scalar ymax = -GREAT;

        forAll(pts,i)
        {
            xmin = min(xmin, pts[i].x());
            xmax = max(xmax, pts[i].x());

            ymin = min(ymin, pts[i].y());
            ymax = max(ymax, pts[i].y());
        }


        // Parallel reduction (important if running MPI)

        reduce(xmin, minOp<scalar>());
        reduce(xmax, maxOp<scalar>());

        reduce(ymin, minOp<scalar>());
        reduce(ymax, maxOp<scalar>());


        scalar lx = (xmax - xmin);
        scalar ly = ymax - ymin;

        scalar aspectRatio = lx/ly;

        Info << "Aspect Ratio = " << aspectRatio << endl;

        Info << "----------bubblepproc----------\n" << endl;

    #};
}
}
// ************************************************************************* //

The only problem is this cannot lookup files in the director making it hard to post process the terminal velocity and so on (which has been commented for reference)

I feel this problem is similar to #39. I prefer to have this functionObjects inside the controlDict so that I can postProcess from the log.<Solver>.

Let me know in case of any details.

Thanks
Ananth Narayan

Activity

  1. changed the title [-]Crash during `isoInterface.update()` in controlDict functions[/-] [+]Crash during `isoInterface.update()` in controlDict `functions{}`[/+] on Jun 2, 2026
  2. Ananth-Narayan-IITM commented on Jun 10, 2026

    @Ananth-Narayan-IITM
    Author

    Seems like this problem is in the core of OpenFOAM, I just saw this discussion thread (#18) and hence shall close this issue. I hope that I or some experts come up with an solution

    The problem I feel is that for postProcess,we should store lot of data or automate this postProcess in batches while simulation is running. Both solutions cannot be scaled to fast and lengthy simulations.

    Let me try to solve this at my free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions