Obtaining forces/moments during runtime
Hi,
Is there a way to obtain forces and moments on an object in a simulation directly in the solver (eg myCustomSolver.C). I know I can generate them using ForceCoeffs and output them in a .dat file or a log file, but I would like to obtain the most recent moment/force as a variable in myCustomSolver.C during runtime directly (instead of trying to read it from the log/dat files, which might be slower. Is this possible? Thanks. |
The latest developments of OpenFOAM v2112 has to feature to sent the data of any FO to other FO. Hence, it should be stored in the db() and hence, you should be able to access it in your own solver directly without reading it from any file.
|
Quote:
Hi Tobi, This is good to know! I am still relatively new to openfoam, how would one practically access this value? I am unfamiliar with db() (for now). Say I wish to access the moment coefficient of the patch "obstacle" along the axis (0 0 1) as one might define in this example forceCoeffs file: Code:
forceCoeffs1 Adrian |
https://www.openfoam.com/documentati...ce.html#l00234
Here we have the setResults() functionality which stores (need to check further) the data in the database. So what we might need is: Code:
const scalar cd = this->db().lookupObject<scalar>("Cd"); However, if that one is not stored in the db() you should get an error and a list of objects which are stored there :). Probably, we first need to access the FO itself and then we have access to the values. |
I got the hint from the developers, that the results are stored in the functionObjectProperties which is owned by Time. So you should have access in that way.
|
Quote:
Excellent, thank you, I will be testing this shortly. I need to have boundary conditions that depend on certain runtime field quantities (the moment potentially being one of them). This would be very useful for runtime control systems (such as simulating a 2d "rocket" landing and trying to keep itself upright with either small jets or fins like the SpaceX Falcon 9, but in OpenFOAM. codedFixedValue boundary conditions come to mind but I'll have to see how they work. |
Hi everyone,
I also need to obtain the forces to modify my custom inlet boundary condition using codedFixedValue. Currently, I need to filter the force output file, and then read in to get the value. It works but it's slow and ugly! I tried to use the mtd suggested by Tobi: Code:
const scalar cd = this->db().lookupObject<scalar>("Cd"); Code:
Creating new library in "dynamicCode/u_6dof_change/platforms/linux64GccDPInt32Opt/lib/libu_6dof_change_a2f851b6065ae560f5bda633cf2c3064fa5c7783.so" PS: Btw, I can access the deltaT using : Code:
delta_time = this->db().time().deltaTValue(); |
Hi,
I realised that I can get the force thru: Code:
const vector force = this->db().lookupObject<vector>("force"); However, when I run my case and I tried to print the force value: Code:
Info << "drag from force " << force[0] << endl; Code:
FOAM parallel run exiting Thanks. |
All times are GMT -4. The time now is 13:08. |