CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Coefficient of Pressure (Cp) for NACA 0012 (https://www.cfd-online.com/Forums/openfoam-post-processing/214435-coefficient-pressure-cp-naca-0012-a.html)

badwalgurpreet January 31, 2019 02:24

Coefficient of Pressure (Cp) for NACA 0012
 
4 Attachment(s)
Hi OpenFOAM Users,

I was trying to validate my NACA 0012 simulation case using OpenFOAM (Version 5.0x). I created Mesh on Pointwise and successfully run this simulation and compared results of (Coefficient of Lift and Drag ) with experimental results that I got from NAS Technical Report: NAS-2016-01.

The Inputs parameters were as follow:

(1): Free Stream Velocity = 45 m/s
(2): Mach Number = 0.13
(3): Free Stream Pressure ( (101325 pa) and Temperature (300 k )
(4): Density of air = 1.225
(5): Kinematic Viscosity = 1.4607*10^-5
(6): Reynolds Number = 3.0807 *10^6
(7): Turbulence model used: Spalart-Allmaras
(8): Solver : simpleFoam

I was trying to calculate the Coefficient of Pressure (Cp) by adding a function in the controlDict file. The solver runs perfectly without any error. But when I plot the results for Cp, I am getting this type of graph (Attached here.). The Cp values do not look correct. I tried it in many ways but the Cp results are same.

Can anybody give me their valuable suggestion where I am doing a mistake?

(2): Second thing I would like to find that when I use a function that I placed in the controlDict file to find Cl and Cd and the solver runs and putting all the values of Lift and Drag coefficients in the postProcess Folder. But in this case when I am adding lines in the controlDict file to calculate Cp. It is only putting a new text file in each time directory having name static(p)_coeff, meaning that it's not creating any postProcess folder as I have before for calculating the Cl and Cd.


I am attaching here the controlDict, Boundary conditions, and Residual graph.

I will be very thankful to you.



Attachment 68089

Attachment 68090

Attachment 68091

Attachment 68092

badwalgurpreet February 1, 2019 00:05

Can anybody give their valuable suggestion on this topic. I will really appreciate you as I am still learning OpenFOAM.

tomf February 1, 2019 08:14

Hi,

For next time, please put the contents of P U and controlDict between CODE tags, than people do not have to download and unzip files. Takes much less time.

I copied your functions part here:

Code:

functions
  {
      pressure1
      {
                type        pressure;
                functionObjectLibs ("libfieldFunctionObjects.so");
                //source                wall;
                //sourceName        airfoil;
                patch      ("airfoil")
                log                yes;
               
                outputControl        outputTime;
                outputInterval        1;
               
                enabled        yes;
                calcTotal        no;
                calcCoeff        yes;
                pRef                0;
                rhoInf                1.125;
                pInf                101325;
                UInf                (52 0 0);               
      }
  }


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

In your p file you correctly used 0 kinematic pressure. You also need that for the pressure functionObject. For details look at the c++ guide online, which states that you need a Freestream density, pressure and velocity for coefficient computation. I would think that this should be the magnitude of the velocity and the pressure at the outlet as used in the simulation.

I think this may work to get reasonable results:
Code:

functions
  {
      pressure1
      {
                type        pressure;
                functionObjectLibs ("libfieldFunctionObjects.so");
                log                yes;
               
                outputControl        outputTime;
                outputInterval        1;
               
                enabled        yes;
                calcTotal        no;
                calcCoeff        yes;
                pRef                0;
                rhoInf                1.125;
                pInf                0;
                UInf                52;               
      }
  }


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

The reason you have no result in postProcessing is that this functionObject writes out a field in every time folder (as you found out).

badwalgurpreet February 3, 2019 01:33

Thanks a lot, Tom for your quick reply. I will keep your suggestions in mind when I will ask any question so that it will take less time to read and respond.

I inserted this function and it works. I still have few doubts about using this function that you corrected in the last message.

(1) : As you told me that the function will not create any postProcess Folder as it will create the new file name "static(p)_coeff" in each time directory. This "static(p)_coeff" file has Cp for all the boundaries that I defined in the p and U files. I need Cp values only for the Airfoil patch, though this file has the Cp values for the airfoil. Is there any way I can define the patch over which I want to find out the Cp values lets say Airfoil.

(2) : Why did we define (pInf = 0 ) insted of (pInf = 101325) ?

(3): How can I plot the data from the last time directory for the Cp values for the AirfoilUpper and AirfoilLower patch?

(4) : Is it possible to add more than one functionObject in the controlDict file as I was trying to calculate the Cp and (Cl, Cd). But I was only getting the values of the Cp not for Cl and Cd.

I am attching my P, U and controlDict files here.

badwalgurpreet February 3, 2019 01:36

functions
{
pressure1
{
type pressure;
functionObjectLibs ("libfieldFunctionObjects.so");
log yes;

writeControl timeStep;
writeInterval 50;
//outputControl outputTime;
//outputInterval 1;

enabled yes;
calcTotal no;
calcCoeff yes;
pRef 0;
rhoInf 1.125;
pInf 0;
UInf (52 0 0);
}

forces
{
type forceCoeffs;
libs ("libforces.so");
writeControl timeStep;
writeInterval 1;

patches ("airfoil");
rho rhoInf;
log true;
rhoInf 1.225;
liftDir (-0.1736 0.9848 0);
dragDir (0.9848 0.1736 0);
CofR (0.25 0 0);
pitchAxis (0 0 1);
magUInf 52;
lRef 1;
Aref 1;

}

}

badwalgurpreet February 3, 2019 01:37

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

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

internalField uniform 0;

boundaryField
{
airfoilLower
{
type zeroGradient;
}
airfoilUpper
{
type zeroGradient;
}
farfield
{
type freestreamPressure;
value uniform 0;
}
frontAndback
{
type empty;
}
}


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

badwalgurpreet February 3, 2019 01:39

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

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

internalField uniform (51.21 9.0297 0);

boundaryField
{
airfoilLower
{
type noSlip;
}
airfoilUpper
{
type noSlip;
}
farfield
{
type freestream;
freestreamValue uniform (51.21 9.0297 0);
value uniform (51.21 9.0297 0);
}
frontAndback
{
type empty;
}
}


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

tomf February 4, 2019 11:07

Hi,

Next time please also use CODE TAGS (the # symbol in the toolbar when editing) and put everything in one message so we do not need to scroll through everything.

Please re-read my original answer as some of the questions you give are already answered there.

Quote:

(1) : As you told me that the function will not create any postProcess Folder as it will create the new file name "static(p)_coeff" in each time directory. This "static(p)_coeff" file has Cp for all the boundaries that I defined in the p and U files. I need Cp values only for the Airfoil patch, though this file has the Cp values for the airfoil. Is there any way I can define the patch over which I want to find out the Cp values lets say Airfoil.
Not without programming your own functionObject.

Quote:

(2) : Why did we define (pInf = 0 ) insted of (pInf = 101325) ?
Because this is what you put in the boundary conditions (see my original reply)

Quote:

(3): How can I plot the data from the last time directory for the Cp values for the AirfoilUpper and AirfoilLower patch?
Use Extract Block and plot On Intersection Curve filters in ParaView.

Quote:

(4) : Is it possible to add more than one functionObject in the controlDict file as I was trying to calculate the Cp and (Cl, Cd). But I was only getting the values of the Cp not for Cl and Cd.
Yes:
Code:

Functions
{
    object1
    {
        type X;
    }   
    object2
    {
        type Y;
    }
}

As before, see: c++ documentation


All times are GMT -4. The time now is 01:12.