CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to select certains faces to calculate lift coefficient? (https://www.cfd-online.com/Forums/openfoam-solving/194286-how-select-certains-faces-calculate-lift-coefficient.html)

xuankushuocai October 12, 2017 15:20

How to select certains faces to calculate lift coefficient?
 
Hi guys,

I want to calculate the lift coefficient of a model with a fan patch created in OpenFOAM. The problem is that I don't want to calculate the lift force on the fan patch. Who knows how to recognize different types of surfaces or select surfaces to do the calculation? Thanks.

kandelabr October 13, 2017 03:18

If you calculate forces using the forces function object you can choose over which patches to integrate:

https://cpp.openfoam.org/v4/classFoa...s.html#details

jpeter3 October 15, 2017 09:43

You can code it into the solver as follows:

You can access the boundary field using .boundaryField().

That returns an array of fields, one for each patch.

You can identify patchID of your patch by using .findPatchID("nameOfThePatch") that Will be used to acces the one you need.

Looping through boundary field of selected patch you can access data on the faces on that patch to calculate what you want.

Like this:


//Find patch ID for your patch:
label patchID = mesh.boundaryMesh().findPatchID("yourPatchName");

//Store face IDs of your patch:
const polyPatch& cPatch = mesh.boundaryMesh()[patchID];

//Field you want to extract values from:
const someFieldType& yourFieldRef = yourField

//Loop over face IDs of faces that are located on your patch:
forAll(cPatch, facei)
{
//Data you seek:
scalar/vector... data = yourFieldRef.boundaryField()[patchID][facei];
}

xuankushuocai October 16, 2017 12:49

Hi, Nejc and Jaka, thanks a lot. I have figured it out.


All times are GMT -4. The time now is 14:50.