Friday, July 10, 2015

How to use topoSet to generate a circular inlet patch with OpenFOAM

Allrun script


#!/bin/sh
cd ${0%/*} || exit 1    # run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

   rm log.*
   rm 0 -r
   cp 0.org 0 -r
    # And execute
    runApplication blockMesh
 
    runApplication topoSet
    runApplication createPatch -overwrite
  
    runApplication decomposePar -force
    runParallel `getApplication` 4
    runApplication reconstructPar

# ----------------------------------------------------------------- end-of-file


topoSetDict


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

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

actions
(
    {
        name    jetCells;
        type    cellSet;
        action  new;
         source cylinderToCell;
    sourceInfo
    {
       p1       (0 0 0); // start point on cylinder axis
       p2       (0 .051 0);   // end point on cylinder axis
       radius   .008;
    }


    }

{
        name    f0;
        type    faceSet;
        action  new;
        source  cellToFace;
        sourceInfo
        {
            set     jetCells;
            option  all;
        }
    }

{
        name    f0;
        type    faceSet;
        action  subset;
      source boxToFace;
     sourceInfo
     {
        box  (-.1 0.024 -.1) (.1 .026 .1);
       //boxes   ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
     }
}
);

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


createPatchDict


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

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

// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
//   a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
//   is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.

// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
//   and centre to make matching easier
// - always create both halves in one invocation with correct 'neighbourPatch'
//   setting.
// - optionally pointSync true to guarantee points to line up.

// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
//  "face 0 area does not match neighbour 2 by 0.0100005%"
//  " -- possible face ordering problem."
// - in polyMesh/boundary file:
//      - loosen matchTolerance of all cyclics to get case to load
//      - or change patch type from 'cyclic' to 'patch'
//        and regenerate cyclic as above


// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
//       with transformations (i.e. cyclics).
pointSync false;

// Patches to create.
patches
(
    {
        // Name of new patch
        name inlet;

        // Type of new patch
        patchInfo
        {
            type patch;
        }

        // How to construct: either from 'patches' or 'set'
        constructFrom set;

        // If constructFrom = patches : names of patches. Wildcards allowed.
        patches ("periodic.*");

        // If constructFrom = set : name of faceSet
        set f0;
    }
);

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

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. when doing this it doesn't select all the cells within the specified bounding boxToFace. The new patch skips some cells from the original patch. How can we solve this?
    Thanks

    ReplyDelete