CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Source Code: Calculation of Drag

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   October 17, 2017, 09:29
Default Source Code: Calculation of Drag
Join Date: Jun 2017
Posts: 73
Rep Power: 9
Friendly is on a distinguished road

I try to understand how OpenFOAM calculates the drag forces and coefficients. In the sourceCode of forceCoeffs.C I have found the following exression:

bool Foam::functionObjects::forceCoeffs::write()

    if (Pstream::master())

        scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;

        Field<vector> totForce(force_[0] + force_[1] + force_[2]);
        Field<vector> totMoment(moment_[0] + moment_[1] + moment_[2]);

        List<Field<scalar>> coeffs(3);

        // lift, drag and moment
        coeffs[0] = (totForce & liftDir_)/(Aref_*pDyn);
        coeffs[1] = (totForce & dragDir_)/(Aref_*pDyn);
        coeffs[2] = (totMoment & pitchAxis_)/(Aref_*lRef_*pDyn);

        scalar Cl = sum(coeffs[0]);
        scalar Cd = sum(coeffs[1]);
        scalar Cm = sum(coeffs[2]);
Nothing special here, everything is more or less as expected. I just need to find out how the force [0],[1] and [2] are calculated. I have found out that 0 is the normal, 1 the tangential and 2 the porous force. But what is a porous force? I have never read such thing before.

Looking in forces.C I have found:

if (directForceDensity_)
        const volVectorField& fD = obr_.lookupObject<volVectorField>(fDName_);

        const fvMesh& mesh = fD.mesh();

        const surfaceVectorField::Boundary& Sfb =

        forAllConstIter(labelHashSet, patchSet_, iter)
            label patchi = iter.key();

            vectorField Md
                mesh.C().boundaryField()[patchi] - coordSys_.origin()

            scalarField sA(mag(Sfb[patchi]));

            // Normal force = surfaceUnitNormal*(surfaceNormal & forceDensity)
            vectorField fN
                    Sfb[patchi] & fD.boundaryField()[patchi]

            // Tangential force (total force minus normal fN)
            vectorField fT(sA*fD.boundaryField()[patchi] - fN);

            //- Porous force
            vectorField fP(Md.size(), Zero);

            applyBins(Md, fN, fT, fP, mesh.C().boundaryField()[patchi]);
So forces are calculated via a forceDensity, but how does the calculation of the forceDensity work?

Does anyone know how OpenFOAM calculates the forces and coefficients? I would be very thankfull for any help.

Friendly is offline   Reply With Quote


coefficients, drag, force, source code

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[] Patches to compile OpenFOAM 2.2 on Mac OS X gschaider OpenFOAM Installation 136 October 10, 2017 17:25
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 09:07
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 17:18
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51

All times are GMT -4. The time now is 00:10.