Tip Function Object writeRegisteredObject
In newer versions of OpenFOAM (>=4.0) this function has been superseded by writeObjects:
https://openfoam.org/release/4-0/
https://github.com/OpenFOAM/OpenFOAM-dev/commit/6221186311d7642bbbbca70bfbc36fbd9fe9f1e4
Contents
1 Introduction to writeRegisteredObject
The Function Object writeRegisteredObject gives the user the power to output fields used during simulations that normally aren't outputted into files.
What's this Function Object good for?
- Providing auxiliary debug information about the data being used for the simulation.
- Inferring additional fields or calculations externally to the solver, based on other uncommonly outputted fields. For example: independent cell volumes of integrating data over volume externally to the solver.
- Get more information about the mesh.
2 Usage Description
A Function Object is a library that is included by defining in the system/controlDict file in the simulation case folder, how to load it and how to use it. For writeRegisteredObject this is the base structure:
functions { name4me { type writeRegisteredObject; functionObjectLibs ( "libIOFunctionObjects.so" ); objectNames (); outputControl outputTime; outputInterval 1; } }
Description of details:
- name4me is just the name given for this function on the functions list and it could be any other name.
- The type systemCall is a must, since its what defines this function object to be used.
- functionObjectLibs defines in which library the desired function object is in.
- The word list () has to be defined as a list of quoted field names, separated with spaces (see the Example section).
- outputControl can have one of two internal name values: outputTime or timeStep.
- outputInterval is an integer/scalar value of the same type as controlDict's writeInterval. This parameter is only used when outputControl is set to timeStep.
The resulting outputted fields will be saved accordingly to their types of data. Examples:
- V stands for the volume of each cell and will be saved in all time snapshots.
- weightingFactors are the weights applied to each cell (note from Wyldckat: not sure what they're for) and will be saved only in the constant folder.
- Mesh related data is usually kept in the last folder where the mesh has been saved; usually the folder is constant/polyMesh.
3 Examples
3.1 Getting fields straight from the solver
Add this near the end of the system/controlDict file for any OpenFOAM case:
functions { testing { type writeRegisteredObject; functionObjectLibs ( "libIOFunctionObjects.so" ); objectNames ("bananas"); outputControl outputTime; } }
When in doubt, use the good old bananas trick. This will make the function object output the list of possible fields that can be saved, every time it is called to save the fields. This trick is particularly useful since each solver will have different fields available.
For example, with the tutorial incompressible/icoFoam/cavity, icoFoam outputs the following message:
--> FOAM Warning : From function Foam::writeRegisteredObject::read(const dictionary&) in file writeRegisteredObject/writeRegisteredObject.C at line 108 Object transportPropersties not found in database. Available objects are: 20 ( points neighbour faces differenceFactors_ U_0 U fvSchemes S faceZones fvSolution phi owner phi_0 weightingFactors cellZones boundary p V pointZones transportProperties )
So, lets pick phi_0 and V:
functions { testing { type writeRegisteredObject; functionObjectLibs ( "libIOFunctionObjects.so" ); objectNames ("phi_0" "V"); outputControl outputTime; } }
Also valid format:
functions { testing { type writeRegisteredObject; functionObjectLibs ( "libIOFunctionObjects.so" ); objectNames ( "phi_0" "V" ); outputControl outputTime; } }
3.2 Calculating fields post-mortem
In other words, calculating some additional fields after the simulation is done. This will depend very much on what you are looking for. This particular example will probably not be adaptable to every scenario:
3.3 Force loading fields
This is the opposite to writing, but since there isn't a page yet for forcefully reading field files, here's a quick tip: you can find an example in , in the tutorial incompressible/pisoFoam/les/motorBike/motorBike. The function object used there is this one:
readFields { functionObjectLibs ( "libfieldFunctionObjects.so" ); type readFields; fields ( p U ); }
Source: $FOAM_TUTORIALS/incompressible/pisoFoam/les/motorBike/motorBike/system/controlDict