Get vectorial values Fx / Fy on airfoil

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

 November 28, 2023, 04:06 Get vectorial values Fx / Fy on airfoil #1 New Member   Join Date: Nov 2023 Posts: 6 Rep Power: 2 Hello everyone, For my PhD work, I’m working on a shape optimization project. I’d like to try an “original” way of calculating the gradient J (drag / lift) with respect to the shape (no adjoint). I need the force values Fx/Fy (drag / lift) at each point of the airfoil in a surface /edge of my airfoil. This will allow me to calculate my gradient. I managed to calculate Cd / Cl directly in by changing the ControlDict file with function forces. But I can't figure out how to get the distribution of forces on the wing. Can anyone help me?

 November 28, 2023, 06:29 #2 Senior Member   Yann Join Date: Apr 2012 Location: France Posts: 1,115 Rep Power: 26 Hello, If you are using the OpenCFD branch (openfoam.com), have a look at the forces function object. There is a writeFields flag allowing to write forces as a field so you can get forces on your airfoil surface. https://doc.openfoam.com/2306/tools/...forces/forces/ I don't think this flag is available in the foundation branch (openfoam.org) but maybe there is another way to achieve the same result. I hope this helps, Yann

 November 28, 2023, 07:09 #3 New Member   Join Date: Nov 2023 Posts: 6 Rep Power: 2 Hello, thank you for your reply ! The point is that i'm already using writeFields in my dict file. See below: https://github.com/Extrality/NACA_simulation But it give me the integration around the wing, not point by point...

 November 28, 2023, 08:04 #4 Senior Member   Yann Join Date: Apr 2012 Location: France Posts: 1,115 Rep Power: 26 Hello, I can see you defined it in the forceCoeffs function, but not in the forces function. If you defined writeFields for your forces function, you should have a force variable written in the time step directories. Yann

 November 30, 2023, 03:39 #5 New Member   Join Date: Nov 2023 Posts: 6 Rep Power: 2 Hello, You're right. The point is that it produce me some forces values in x, y, z around the airfoil in a "forceCoeffs" file. Are you sure those forces correspond to my Fx, Fy forces around the airfoil ? forceCoeffs1 { // Mandatory entries type forceCoeffs; libs ("libforces.so"); patches ("aerofoil"); // Optional entries // Field names p p; U U; rho rhoInf; ////Density only for incompressible flows rhoInf 1.184; // Reference pressure [Pa] pRef 0; // Include porosity effects? porosity no; // Store and write volume field representations of forces and moments writeFields yes; writeControl timeStep; writeInterval \$endTime; // Centre of rotation for moment calculations CofR (0 0 0); // Lift direction liftDir (0 1 0); // Drag direction dragDir (1 0 0); // Pitch axis pitchAxis (0 0 1); // Freestream velocity magnitude [m/s] magUInf \$Uinf; // Reference length [m] lRef 1; // Reference area [m2] Aref 1; // Spatial data binning // - extents given by the bounds of the input geometry /*binData { nBin 20; direction (1 0 0); cumulative yes; }*/ }

 November 30, 2023, 03:54 #6 Senior Member   Yann Join Date: Apr 2012 Location: France Posts: 1,115 Rep Power: 26 You are confusing 2 different function objects : forceCoeffs computes forces coefficients (Cd, Cl, Cs, ...) : https://doc.openfoam.com/2306/tools/...s/forceCoeffs/ forces computes... forces (Fx, Fy, Fz): https://doc.openfoam.com/2306/tools/...forces/forces/ The writeField flag in the forces function object (not forceCoeffs) should write a force vector, in Newton.

 November 30, 2023, 04:18 #7 New Member   Join Date: Nov 2023 Posts: 6 Rep Power: 2 Okay, thank you for your answer, i'll deal with that! Have a great day

 November 30, 2023, 04:37 #8 New Member   Join Date: Nov 2023 Posts: 6 Rep Power: 2 It does not seem to work ... I add writeFields yes; to the controldict forces type: forces_object { type forces; libs ("libforces.so"); patches ("aerofoil"); //enabled true; // Field names p p; U U; rho rhoInf; //// Density only for incompressible flows rhoInf 1.1839305888344056; // Store and write volume field representations of forces and moments writeFields yes; writeControl timeStep; writeInterval \$endTime; //// Centre of rotation CofR (0 0 0); } and it returned me the log message: /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : _6e1fca0e-20220610 OPENFOAM=2112 patch=220610 version=2112 Arch : "LSB;label=32;scalar=64" Exec : simpleFoam Date : Nov 30 2023 Time : 10:31:43 Host : ronan-HP-Dragonfly-13-5-inch-G4-Notebook-PC PID : 11619 I/O : uncollated Case : /home/ronan/Bureau/naca/NACA_simulation/Simulations/airFoil2D_SA_0.155_0_0_0_12_shape_0 nProcs : 1 trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 SIMPLE: convergence criteria field p tolerance 0 field U tolerance 0 field nuTilda tolerance 0 field k tolerance 0 field omega tolerance 0 field h tolerance 0 Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Selecting turbulence model type RAS Selecting RAS turbulence model SpalartAllmaras Selecting patchDistMethod meshWave RAS { RASModel SpalartAllmaras; turbulence on; printCoeffs on; sigmaNut 0.666667; kappa 0.41; Cb1 0.1355; Cb2 0.622; Cw2 0.3; Cw3 2; Cv1 7.1; Cs 0.3; } No MRF models present No finite volume options present Starting time loop forces forces_object: p: p U: U rho: rhoInf Freestream density (rhoInf) set to 1.18393 Not including porosity effects Fields will be written forceCoeffs forceCoeffs1: p: p U: U rho: rhoInf Freestream density (rhoInf) set to 1.18393 Reference pressure (pRef) set to 0 Not including porosity effects Fields will be written --> FOAM Warning : From bool Foam::regIOobject::store() in file ./src/OpenFOAM/lnInclude/regIOobjectI.H at line 45 Refuse to store unregistered object: force --> FOAM FATAL ERROR: (openfoam-2112 patch=220610) Failed to store pointer: force. Risk of memory leakage From static Type& Foam::regIOobject::store(Type*) [with Type = Foam::GeometricField, Foam::fvPatchField, Foam::volMesh>] in file ./src/OpenFOAM/lnInclude/regIOobjectI.H at line 67. FOAM aborting #0 Foam::error:rintStack(Foam::Ostream&) at ??:? #1 Foam::error::simpleExit(int, bool) at ??:? #2 Foam::functionObjects::forces::read(Foam::dictiona ry const&) at ??:? #3 Foam::functionObjects::forceCoeffs::read(Foam::dic tionary const&) at ??:? #4 Foam::functionObjects::forceCoeffs::forceCoeffs(Fo am::word const&, Foam::Time const&, Foam::dictionary const&, bool) at ??:? #5 Foam::functionObject::adddictionaryConstructorToTa ble::New(Foam: :word const&, Foam::Time const&, Foam::dictionary const&) at ??:? #6 Foam::functionObject::New(Foam::word const&, Foam::Time const&, Foam::dictionary const&) at ??:? #7 Foam::functionObjects::timeControl::timeControl(Fo am::word const&, Foam::Time const&, Foam::dictionary const&) at ??:? #8 Foam::functionObjectList::read() at ??:? #9 Foam::Time::run() const at ??:? #10 Foam::Time::loop() at ??:? #11 ? in /usr/lib/openfoam/openfoam2112/platforms/linux64GccDPInt32Opt/bin/simpleFoam #12 ? in /lib/x86_64-linux-gnu/libc.so.6 #13 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 #14 ? in /usr/lib/openfoam/openfoam2112/platforms/linux64GccDPInt32Opt/bin/simpleFoam Aborted (core dumped)

 November 30, 2023, 05:01 #9 Senior Member   Yann Join Date: Apr 2012 Location: France Posts: 1,115 Rep Power: 26 Alright, there might be a clash between both functions. Do you need to write the force coefficients on your surface? If not, try removing the writeFields flag from the forceCoeffs function (use it only on the forces function). If you need both, maybe try to use the useNamePrefix flag in both functions. Bug report: https://develop.openfoam.com/Develop.../-/issues/2490 Forces function header (to check the useNamePrefix usage): https://develop.openfoam.com/Develop...orces/forces.H

 November 30, 2023, 08:56 #10 New Member   Join Date: Nov 2023 Posts: 6 Rep Power: 2 Thank you, it's working by removing the other ! Yann likes this.