Examples of Cylindrical Flow Around OpenFOAM

Cylindrical flow around a cylinder is one of the most classical examples in fluid mechanics and is favored by many scholars.Beyond cavity and pipe flow, CFD beginners first come into contact with the flow of a cylinder. Cylindrical flow reflects all kinds of conditions when fluid flows through an obstacle: the transition of layer flow to turbulent flow, the shear and separation of fluid, boundary layer, Carmen Vortex Street phenomena, etc. It is an important example to understand the flow mechanism in depth. Because it is often necessary to calculate the flow around a cylinder, make some notes here.Record and record some details in case you forget them later. This time, do Re=200 cylindrical bypass flow example, draw grid using ICEM, CFD using open source software OpenFOAM, and post processing using tecplot. The example file can be set as follows, or you can find the uploaded package on my home page.

1.Preprocessing: Draw grid

Draw the grid using ICEM. The cylindrical diameter D=1m, the calculated field is 30D round. Because it is a laminar grid, there is no strict limit on the height of the first layer grid, the number of grids is 160x160. I uploaded it at station b Video process for grid drawing , you can search chansFoam for attention. The process is not detailed here.

2.OpenFOAM Computing

2.1 Loading grids and modifying boundary types

Find a template example in OpenFOAM. First copy the just drawn grid msh file into the case folder:

In terminal input:

fluentMeshToFoam cylinder2d.msh -2D 1

This allows you to convert fluent's grid format to something that OpenFOAM can use. The latter -2D directive sets the z-direction thickness because it's a two-dimensional grid, but there are only three examples in OpenFOAM, so you get a layer stretched in the z-direction. I set the height of this layer to 1. Next, open constant/polyMesh/boundary, modify the boundary condition type, and:

Change to:

The reason for this is that when you finish drawing the grid in ICEM to set the boundary conditions, it is more convenient to set all the boundaries as wall s first, which only needs to be modified uniformly in OpenFOAM.

2.2 Setting initial values and boundary conditions

Open folder 0 and set the U and p files as follows:

U:

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

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (17 0 0);

boundaryField
{
    IN
    {

        type            fixedValue;
        value           uniform (17 0 0);
    }

    OUT
    {
        type            zeroGradient;
    }

    CYLINDER
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }


    frontAndBackPlanes
    {
        type            empty;
    }

}

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

 p:

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

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    IN
    {
        type            zeroGradient;
    }

    OUT
    {
        type            fixedValue;
        value			uniform 0;
    }

    CYLINDER
    {
        type            zeroGradient;
    }

    frontAndBackPlanes
    {
        type            empty;
    }

}

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

These are very standard boundary conditions. At the initial value, the pressure is set to 0 and the speed is 17m/s (Ma=0.05).

2.3 Kinematic Viscosity

Open constant/transportProperties to modify the value of nu. When Re is 200, nu=17*1/200=0.085.

2.4 Numeric Format

Open system/fvSchemes and modify as follows:

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

gradSchemes
{
    default 	     Gauss linear;
}

divSchemes
{
    default         none;
    div(phi,U)      Gauss linearUpwind grad(U);
}

laplacianSchemes
{
    default         Gauss linear limited 1;
}

interpolationSchemes
{
    default         linear corrected;
}

snGradSchemes
{
   default           corrected;
}

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

It is worth mentioning that the convection term format. A second-order upwind is used here. If a first-order upwind is used, instead of Karman Vortex Street, it converges to the following situation: the velocity cloud in the x direction on the left and the pressure cloud in the right. The resistance coefficient tends to stabilize, and the lift factor fluctuates above and below 0 (equivalent to constant).

Setup of 2.5 Solution Equation

stay icoFoam algorithm Within the framework of (SIMPLE), once the numerical format is set, the program constructs a very large sparse matrix. The next step is to unravel this system of linear equations:

OpenFO A M has many b uilt-in tools for solving equations, which are set in system/fvSolution:

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

solvers
{

    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance       1e-07;
        relTol          0;

    }

    pFinal
    {
        $p;
        relTol          0;
    }

    U
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance       1e-08;
        relTol          0;
    }

}

PISO
{
    nCorrectors     2;
    nNonOrthogonalCorrectors 2;
    pRefCell        0;
    pRefValue       0;
}

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

Traditionally, I use PCG more for pressure matrices than GAMG. PBiCG is also used for velocity matrices. What are these? There are problems with algorithms, so you can read some books without going into details here. Note that the following nCorrectors and nNonOrthogonal Correctors represent the number of PISO algorithm corrections and the number of non-orthogonal corrections, respectively. The cylindrical flow around the grid just drawn is strictly speakingNot orthogonal, set here twice.

2.6 Calculation Settings

Open system/controlDict for some settings on the calculation, including time step, time to start and end, how many steps to output once, and output some information for post-processing.

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

application     icoFoam;

//startFrom       startTime;
startFrom       latestTime;

startTime       0;

stopAt          endTime;
//stopAt	  writeNow;

endTime         6;
//endTime         500;

//deltaT          0.005;
//deltaT          0.01;
//deltaT          0.02;
deltaT          0.0005;

writeControl    runTime;
/*
adjustableRunTime
clockTime
cpuTime
runTime
timeStep
*/

writeInterval   0.5;

/*
secondaryWriteControl    cpuTime;
secondaryWriteInterval   1000; 
secondaryPurgeWrite      1; 
*/

purgeWrite      20;

writeFormat     ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

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

functions
{

    fieldAverage
    {
        type            fieldAverage;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl   outputTime;

	//writeControl   timeStep;
	//writeInterval  100;

	//cleanRestart true;

	//timeStart       20;
	//timeEnd         200;

        fields
        (
            p
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
            
        );
    }
    forceCoeffs
    {
         type forceCoeffs;
         functionObjectLibs ("libforces.so"); 
         patches (CYLINDER); 
         log true; 
         rho rhoInf;
         rhoInf 1;
         CofR (0 0 0);
         liftDir (0 1 0); 
         dragDir (1 0 0); 
         pitchAxis (0 0 1);
         magUInf 17; 
         lRef 1;
         Aref 1; 
         writeControl    timeStep;
         writeInterval   1;
     }
};

The calculation step and total time are specified here. Setting the calculation step is best to make the maximum Coulomb number (CFL) available for calculation.Less than 1. Although SIMPLE is a semi-implicit solution and the implicit format is unconditionally stable, we still want the flow field calculations to be more stable. Set deltaT to 0.0005 and max CFL to around 0.5. The total time is 6s, which is about 20 cycles. The calculation process is as follows:

First consider the dimensionless frequency St number of flow around a cylinder:

In general, the St of the flow around a cylinder is about 0.2, f is the frequency of actual eddy shedding, and the time of one eddy shedding cycle is calculated by taking the inverse of F:

For example, the mean field, perturbation field and lift resistance factor are considered in the cylindrical flow around a cylinder, which are set in functions behind the control Dict and are not detailed here.

2.7 Beginning of calculation

If you want to be parallel, you need to set decomposeParDict and then compute with mpi instructions. This is done on a single core only, with direct input at the terminal:

icoFoam

The calculation starts. The calculation time depends on the performance of the calculation.

3.Post-processing to see results

After calculating, open postProcessing/forceCoeffs/0 with tecplot to see the upward resistance coefficient curve:

 

It can be seen that the latter half of the section is entering a relatively stable stage, with Carmen Vortex Street appearing in the flow field and the lift resistance coefficient changing periodically. From the lift coefficient estimation to St=0.235, the average resistance coefficient is 1.35. Some literatures are compared:

There are still some inconsistencies and differences between them. The specific reasons are grid resolution, numerical format, calculation method and so on. It is a big topic to pick up a single one here and master it slowly. After slowly modifying it yourself, it will not be shown here. After that, some flow field diagrams will be shown:

Flow Average Velocity Cloud:

Mean Pressure Cloud Map:

There are also vorticity graphs, so the calculation of vorticity can see what I've done before video.

 

Of course, you also need to extract the stream field variables on a line and compare them with the literature. There is too much information in this article now, so I'll put it down later.

summary

The Reynolds number 200 cylindrical flow around a cylinder is simulated completely on OpenFOAM, including grid drawing, setting up, calculation and post-processing comparison results. CFD computational fluid dynamics is a subject that covers a wide range of subjects and requires you to be proficient in each one, because improper handling of one link can affect the whole simulation result, packageBut not limited to grid resolution, selection of numeric format, selection of calculation method, setup of solution equation, etc. Everything needs to be done carefully. Fortunately, CFD is a tool to use a computer to simulate hydrodynamics in the form of a program, which has the reusability of knowledge, can also be stored in the device, and is also convenient for everyone to exchange and share.

 

 

 

 

Tags: cfd

Posted on Wed, 08 Sep 2021 15:53:04 -0400 by Dumps