Appending to controlDict


Appending to controlDict

OpenFOAM allows the user to carry out a variety of calculations at run-time, that is, while the simulation is progressing. A typical example of this might be calculating the lift and drag forces on a building and dumping this to a data file.

These additional functions are defined by appending a "function" object to the controlDict file. ODS allows you to append arbitrary text to the end of your controlDict by creating a text-file in Blender and naming it "controlDict.append".

Example: Calculating the lift and drag on a building at run-time

  1. Set up your model boundary conditions and mesh parameters as defined in earlier tutorials
  2. Open a new Blender panel and change it to type "Text Editor"
  3. Press the button labelled "New" at the bottom of the text editor window and change the name of the new text file to "controlDict.append"
  4. Copy-paste the text below re-naming "Building" to whatever you have named your building object in Blender. To correctly calculate lift and drag coefficients you will also need to modify the values for fields magUInf (the far-field velocity), lRef (the building length scale which is generally the diameter) and Aref (the building area facing the wind).
  5. Continue with the simulation as normal. Two new folders will be created in your foam case directory: "forces" and "forceCoeffs". Look in the "0/foces.dat" file to find a list of the lift and drag forces at all calculated timesteps. This data can be imported into a spreadsheet program such as OpenOffice Calc and plotted.

Text to add to your controlDict.append text file in the Blender text editor:

functions
{
    forces
    {
        type forces;
        functionObjectLibs ("libforces.so");
        outputControl timeStep;
        outputInterval 1;
        patches ( "Building" );
        pName p;
        UName U;
        rhoName rhoInf;
        log true;
        rhoInf 1.2;      // Reference density, fluid
        CofR (0 0 0);  // Origin for moment calculations
    }

    forceCoeffs
    {
        type forceCoeffs;
        functionObjectLibs ( "libforces.so" );
        outputControl timeStep;
        outputInterval 1;

        patches     ( "Building" );
        pName       p;
        UName       U;
        rhoName     rhoInf;      // Indicates incompressible
        rhoInf      1.2;            // Reference density, fluid
        log         true;
        liftDir     (0 0 1);
        dragDir     (0 1 0);
        CofR        (0 0 0);     // Axle midpoint on ground
        pitchAxis   (0 1 0);
        magUInf     20;
        lRef        30;            // Diameter of cylinder
        Aref        9000;          // Ref. Area = cross sectional area
    }
}