[8735fe]: Examples / FunkyPythonPostproc / correlatePressureAndPlace Maximize Restore History

Download this file

correlatePressureAndPlace    95 lines (84 with data), 2.5 kB

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.7.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Test the python-postprocessing utility

preloadFields (
    p
    U
);

python {
    startFile "correlatePressureAndPlaceStart.py";
    executeFile "correlatePressureAndPlaceExecute.py";
    endFile "correlatePressureAndPlaceEnd.py";
    //    startCode "import sys;print sys.path";
    //    startCode "print dir()";
    //    startCode "import scipy.stats";
    // endCode "import IPython;IPython.embed(header='OpenFOAM',config='pylab')";
    // executeCode $endCode;
    //    endCode "print positions.shape";
    //     executeCode $endCode;

    swakToPythonNamespaces (
        fieldData
    );

    useNumpy true;
    useIPython true;
    //    useIPython false;

    //    interactiveAfterExecute true;
    interactiveAfterException true;
}

functions {
    gradField {
        type expressionField;
        outputControl timeStep;
        outputInterval 1;
        fieldName gradP;
        expression "grad(p)";
        autowrite true;
    }
    toGlobalNamespace {
        type calculateGlobalVariables;
        outputControl timeStep;
        outputInterval 1;

        valueType internalField;
        toGlobalNamespace fieldData;
        toGlobalVariables (
            positions
            velocity
            pressure
            gradPressure
        );
        variables (
            "velocity=U;"
            "positions=pos();"
            "pressure=p;"
            "gradPressure=gradP;"
        );
    }
    checkFields {
        type volumeMinMax;
        verbose true;
        outputControlMode timeStep;
        outputInterval 1;
        fields (
            p
            U
        );
    }
}

libs (
    "libswakFunctionObjects.so"
);

// ************************************************************************* //