|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Giorgio
Join Date: Mar 2023
Posts: 57
Rep Power: 3 ![]() |
Dear all,
I am using Openfoam 2312. I am trying to develop a custom function object that compute a linear combination of an area average (at runtime). Seems complicated but it is just computing something like Output = (0.9-Area_average)/(0.9-0.5) where Area_average can be computed with the function object "surfaceFieldValue". In other words, I want to apply an expression to the output of a function object before printing. I know that I could compile a new function object but I guess there is a simpler approach? Moreover I need it for just one test case. Thanks in advance Last edited by giorgianig; November 26, 2024 at 06:43. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,255
Rep Power: 29 ![]() ![]() |
Hello Giorgio,
It looks like a job for the exprField function object! https://doc.openfoam.com/2312/tools/...eld/exprField/ Cheers, Yan |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
Member
Giorgio
Join Date: Mar 2023
Posts: 57
Rep Power: 3 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Giorgio
Join Date: Mar 2023
Posts: 57
Rep Power: 3 ![]() |
It seems that function objects create fields that can be stored for later use. From the documentation:
"Many function objects create fields that can be stored for later use. To avoid potential name clashes in the database, the useNamePrefix entry can be used to prepend the name of the function object to the name of the output field, e.g. applied to a fieldAverage function object, a velocity mean field could be named fieldAverage1:UMean." It is not clear which function objects are able to do so, and how to practically do it. I wrote a first function object: HTML Code:
cuttingPlane001 { type surfaceFieldValue; libs (fieldFunctionObjects); enabled yes; writeControl timeStep; writeInterval 1; writeFields no; writeToFile no; //interpolationScheme cellPoint; regionType sampledSurface; name z-0.01; sampledSurfaceDict { type cuttingPlane; planeType pointAndNormal; pointAndNormalDict { basePoint (0 0 0.01); normalVector (0 0 1); } source cells; // sample cells or boundaryFaces interpolate true; } operation areaAverage; fields ( alpha.SA ); result ctp001; } HTML Code:
expr001 { type exprField; libs (fieldFunctionObjects); name expr001; expression "(0.9-ctp001)/0.4"; dimensions [ ]; } HTML Code:
functions { #include "cuttingPlane001" #include "expr001" } HTML Code:
--> FOAM FATAL IO ERROR: (openfoam-2312 patch=240220) Entry 'field' not found in dictionary "/home/giorgio/tutorials/combustion/reactingFoam/RAS/TEST_liquid/lockExchange/system/controlDict/functions/expr001" file: system/controlDict/functions/expr001 at line 10 to 14. |
|
![]() |
![]() |
![]() |
![]() |
#5 | |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,255
Rep Power: 29 ![]() ![]() |
Hello Giorgio,
Quote:
However, I did not pay enough attention to the details: surfaceFieldValue will output a single value rather than a field, and I think exprField needs a field to work with. It would need to have a closer look, but surfaceFieldValue does not seem to store anything to the object registry in order to be used afterward in another function object. There is an inherited writeFields switch, but it does not seem to do anything here. |
||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error in enabling the python wrapper | Jinn | SU2 Installation | 2 | April 23, 2022 14:52 |
[Other] mesh airfoil NACA0012 | anand_30 | OpenFOAM Meshing & Mesh Conversion | 13 | March 7, 2022 18:22 |
Custom field function object from wallHeatFlux | HorstvanGrass | OpenFOAM Post-Processing | 1 | August 3, 2021 13:28 |
[blockMesh] non-orthogonal faces and incorrect orientation? | nennbs | OpenFOAM Meshing & Mesh Conversion | 7 | April 17, 2013 06:42 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10:56 |