In OpenFOAM, functionObjects are code snippets that can be loaded into any solver during run-time. This enables each solver to be coupled with some additional functionality, that is independent from the flow model. All functionObjects have to be included in system/controlDict like the following:
functions { <name> { type <type>; functionObjectLibs ("<lib>"); writeControl timeStep; outputInterval 1; // Specific parameters for the functionObject } }
functions { inletFlux { type surfaceFieldValue; libs ("libfieldFunctionObjects.so"); writeControl timeStep; log true; // Output field values as well writeFields false; regionType patch; name inlet; operation sum; fields ( rhoPhi ); } outletFlux { $inletFlux; name outlet; } atmosphereFlux { $inletFlux; name atmosphere; } }
surfaceInterpolate
Description Linearly interpolates volume fields to generate surface fields. Fields are stored - every time step the field is updated with new values - at output it writes the fields This functionObject can either be used - to calculate a new field as a post-processing step or - since the fields are registered, used in another functionObject Example of function object specification:
functions { // Interpolate the pressure field to the faces surfacep { type surfaceInterpolate; libs ("libfieldFunctionObjects.so"); fields ((p surfacep)); writeControl none; }
// Average the surface pressure field over the centre faceZone #includeFunc faceZoneAverage(name=centre, surfacep) }
时间平均
functions { field_average { type fieldAverage; // fieldAverage 是时间平均 functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; writeControl outputTime; fields ( U { mean on; prime2Mean on; base time; } k { mean on; prime2Mean off; base time; } ); } }
functions { minMax { // Type of functionObject type fieldMinMax; // Where to load it from (if not already in solver) functionObjectLibs ("libfieldFunctionObjects.so"); // Function object enabled flag enabled true; // Log to output (default: false) log false; // Write information to file (default: true) write true; location no; // Fields to be monitored - runTime modifiable fields (U p T); //fields (T); writeControl timeStep; writeInterval 2; } }
functions { streamLines { type streamLine; // Where to load it from (if not already in solver) libs ("libfieldFunctionObjects.so"); // Output every writeControl writeTime; // writeInterval 10; setFormat vtk; //gnuplot;//xmgr;//raw;//jplot;//csv;//ensight; // Tracked forwards (+U) or backwards (-U) trackForward true; // Names of fields to sample. Should contain above velocity field! fields (p k U); // Steps particles can travel before being removed lifeTime 10000; // Number of steps per cell (estimate). Set to 1 to disable subcycling. nSubCycle 5; // Cloud name to use cloudName particleTracks; // Seeding method. seedSampleSet { type uniform; axis x; //distance; start (-0.02050.0010.00001); end (-0.02050.02510.00001); nPoints 10; } } }
MachNo
functions { libs ("libfieldFunctionObjects.so"); Ma { type MachNo; executeControl writeTime; writeControl writeTime; } }
functions { writeFields // name of the function object { type writeObjects; libs ( "libutilityFunctionObjects.so" );
objects ( T U rho // list of fields/variables to be written );
// E.g. write every 1e-5 seconds of simulation time only the specified fields writeControl runTime; writeInterval 1e-5; // write every 1e-5 seconds
writeOption autoWrite;// noWrite anyWrite } }
You can also define multiple function objects in order to write different subsets of fields at different times. You can also use wildcards in the list of fields- for example, in order to write out all fields starting with “RR_” you can add