zzhang777 / paralleled_cdugksFoam

Optimized version of dugksFoam with hybrid parallelization strategy and conserved algorithm.
Other
8 stars 3 forks source link

farfield boundary condition for external flow problems (flow around bodies) #1

Open lwjetmann opened 2 years ago

lwjetmann commented 2 years ago

Hi, everyone!

Problem description

I want to use dugksFoam to calculate the low-speed incompressible flow passing a micro-cylinder. I found cases like internal flow problems (only wall boundary condition is needed) and supersonic flow around a body in the user guide and published papers using dugksFoam, so I decided to try a supersonic-flow-around-a-2-D-cylinder case first. The case appears in Discrete unified gas kinetic scheme on unstructured meshes.

However, the description of the farfield BC in the user guide is a bit vague, which reads: "To specify such a boundary type, just set the boundary types as fixedValue, and provide the free-stream flow condition as the boundary values in 0/rho, 0/U and 0/T." If the velocity on the whole outer boundary is set to fixedValue, how can the flow field adjust to a steady state? I tried setting the BC as the user guide suggested, but the solving soon diverged. I changed fixedValue to farField; the solving has not diverged yet but the result is weird.

So, how should I specify the farfield BC? Can dugksFoam be used to calculate the incompresible external flow problem?

Details of the settings

fvDVMparas
{
    xiMax       xiMax [0 1 -1 0 0 0 0]    5.053155000000000e+03;
    xiMin       xiMin [0 1 -1 0 0 0 0]   -5.053155000000000e+03;
    nDV               89;       // Number of discrete velocity, shoud be 4*Z + 1 if using compound N-C quardrature
}

gasProperties
{
    R            R [0 2 -2 -1 0 0 0] 207.85; // Specific gas constant
    omega        0.81;              // VHS viscosity ~ Temperature index
    Tref         Tref [0 0 0 1 0 0 0] 273.0; // Reference temperature
    muRef        muRef [1 -1 -1 0 0 0 0] 2.117e-5;
    Pr           0.6667; // Prantl number
}

0/U

boundaryField
{
    cylinder
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    farfield
    {
        type            farField;
        value       uniform (1538.73 0 0);        
    }
    frontAndBack
    {
        type            empty;
    }
}

0/T

boundaryField
{
    cylinder
    {
        type            fixedValue;
        value           uniform 273;
    }
    farfield
    {
        type            farField;
        value           uniform 273;
    }
    frontAndBack
    {
        type            empty;
    }
}

0/rho

boundaryField
{
    cylinder
    {
        type            calculatedMaxwell;
        value           uniform 8.598e-5;  // dummy
    }
    farfield
    {
        type            farField;
        value           uniform 8.598e-5;
    }
    frontAndBack
    {
        type            empty;
    }
}

Result

The solution time interval is about 2e-8, and the flow fields of U, T, and rho at 3e-4

zzhang777 commented 2 years ago

The farfield BC should be set as fixedValue. In the code implementation, the incoming flow is in an equilibrium state, and the outgoing flow is calculated by interpolation. Don't use the farField keyword. I met the same problem before. When simulating supersonic flow, some tricks are needed. Like the quality of physical/velocity mesh and the value of the initial field.

lwjetmann commented 2 years ago

Thanks for your reply! But unfortunately, I still have some problems.

The farfield BC should be set as fixedValue. In the code implementation, the incoming flow is in an equilibrium state, and the outgoing flow is calculated by interpolation.

I suppose the fixedValue is the built-in BC in OpenFOAM. So, once the farfield is specified as fixedValue, the value won't change. How come the outgoing flow will be calculated by interpolation? But, anyway, I agree that as long as the field is large enough, fixedValue can give proper results. I tried this with simpleFoam. The result is slightly non-physical in the farfield outlet area, but otherwise quite good.

u

Don't use the farField keyword. I met the same problem before.

I used fixedValue for the farfield BC, but the result was no better.

When simulating supersonic flow, some tricks are needed. Like the quality of physical/velocity mesh and the value of the initial field.

I tried first calculating with simpleFoam, then using the converged U field as the initial field in dugksFoam. However, the calculation still went in the wrong way.

u_initial

u_after2000steps

I wondered if dugksFoam can be used to calculate the incompressible external flow problem, since in my case, Ma is only 0.01 (Kn=0.1, Re=0.148). Can you kindly send me an external flow case that can give proper results?

zzhang777 commented 2 years ago

For boundary conditions, OpenFOAM only deals with macro variables, such as rho, U, and T. In DUGKS, the boundary conditions of distribution functions are calculated manually. First, decide the boundary condition for distribution functions according to the boundary condition of the density field. The rho B.C. is configured in file 0/rho. In the code implementation, use the if-else statement when updating distribution functions. The source code is in fvDVM/discreteVelocity/discreteVelocity.C, here are some code snippets:

//line 275, decide the boundary condition for distribution functions
bcMap["fixedValue"] = "mixed"; // For supersonic out boundary only

//line 564, updateGHbarSurf on boundary faces
else if (type == "mixed")
{
//check each boundary face in the patch
    forAll(gSurfPatch, facei)
    {
        //out or in ?
        if ((xii & SfPatch[facei]) > 0) // outgoing
        {
            gSurfPatch[facei] = iGbarPvol[faceCells[facei]]
                + ((iGbarPgrad[faceCells[facei]])
                    & (CfPatch[facei] - C[faceCells[facei]] - 0.5 * xii * dt));
            hSurfPatch[facei] = iHbarPvol[faceCells[facei]]
                + ((iHbarPgrad[faceCells[facei]])
                    & (CfPatch[facei] - C[faceCells[facei]] - 0.5 * xii * dt));
            //incoming and parallel to face, not changed.
        }
    }
}

For other questions, you can contact me on WeChat. My WeChat ID is echo_m987. I'm more familiar with the dugksFoam source code and HPC, not CFD.