Friday 23 May 2014

Paraviewing a decomposed case

I seem to recall that it was once possible to load an unreconstructed case directly with paraFoam, but that doesn't seem to work anymore.  However, Paraview's OpenFOAM reader can deal with a decomposed case, so the answer is to simply start up Paraview (as opposed to paraFoam), change "Reconstructed Case" to "Decomposed Case" and there you go.  OK, how do you load an OpenFOAM case?  It turns out that you simply need any file with the extension "foam" in your case directory, and this is the file that you load, either from the command line when starting Paraview or from the File menu once in Paraview.  Someone once suggested always creating a file called bananas.foam, which makes it easy to remember and unlikely to clash with anything meaningful.  So touch bananas.foam followed by paraview bananas.foam is the obvious and natural way of loading an OpenFOAM case into Paraview.

Thursday 22 May 2014

Fans, actuator disks & snappyHexMesh

Meshing

Dear old snappy offers the ability these days of generating a baffle in one swell foop.  Makes life much easier if you want to generate a mesh with an actuator disk, no?  Just add the following bits in the refinementSurfaces section of snappyHexMeshDict (assuming that you have of course generated and imported the appropriate stl surface)

        disk
        {
        level (6 6);
        faceZone disk;
        faceType baffle;
        }


and Robert will be your mother's proverbial brother.  Well, yes and no.  This will indeed generate a baffle, with the necessary wall-related information for two boundaries, disk and disk_slave, in the boundary file.  If what you wanted was a baffle, this would be fine.  But if what you really wanted was a set of cyclic patches with a pressure jump, this does not work.  There are two steps that need to be taken to set up the cyclic patches, and these won't work with two matching baffle surfaces.

It turns out that the simple answer here is simply to remove the faceType baffle; statement, so that you are left with:
        disk
        {
        level (6 6);
        faceZone disk;
        }


This will mesh to the disk surface, but not assign any boundary faces, although disk and disk_slave will still show up in the boundary file.

createPatch

The above snappyHexMesh process will, with a bit of luck, have provided a faceZone called disk, and this can be used to create the cyclic patches.  However, you first need to clean up the boundary file with createPatch -overwrite, and for this you also need a createPatchDict:

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

pointSync true;

// Patches to create. An empty patch list just removes patches with zero
// faces from $FOAM_CASE/constant/polyMesh/boundary.
patches
(
);

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


createBaffles

Yeah.  Baffles is exactly what we don't want to create, but the necessary directives are included in the following createBafflesDict:

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

internalFacesOnly true;

baffles
{
    cyclicFaces
    {
        type        faceZone;
        zoneName    disk;

        patches
        {
            master
            {
                name            fan01;
                type            cyclic;
                neighbourPatch  fan02;
           
            }
            slave
            {
                type            cyclic;
                name            fan02;
                neighbourPatch  fan01;
            }
        }
    }
}

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


Now run createBaffles -overwrite and take a look at the boundary file.  With a bit of luck and alignment of heavenly bodies, the necessary cyclic patches should appear, and can be used as cyclic boundary conditions.

Why bother?

Indeed?  Why does the world need yet another OpenFOAM blog?  The short answer is that it doesn't.  In the proudest tradition of software documentation, this blog will serve purely as a reminder to myself.