How to create my own functionObject ?
Dear all,
I use functionObjedt like following: functions { extraction { type surfaces; functionObjectLibs ("libsampling.so"); enabled true; outputControl timeStep; outputInterval 5; surfaceFormat foamFile; interpolationScheme cellPointFace; fields ( U T ); surfaces ( aplane { type plane; basePoint (-0.4 0 0.5); normalVector (1.0 0 0); } ); } } my purpose is to extract a plane data of internal domain in every time step. But the file directory is not what I want. I copy src/sampling ,and modify a little ,create another called libmysampling.so. but when using, it displays: --> FOAM Warning : From function dlLibraryTable::open(const dictionary& dict, const word& libsEntry, const TablePtr tablePtr) in file lnInclude/dlLibraryTableTemplates.C at line 68 library "libmysampling.so" did not introduce any new entries It seems that my own libmysampling.so doesn't take effect. Could any one tell me how to create functionObject type ? Thanks. |
I want to modify surfaces functionObject, I found it belongs to sampling,
So I copy src/sampling directory to another position. I changed the name to LIB = $(FOAM_USER_LIBBIN)/libmysampling. in sampling\sampledSurface\sampledSurfaces, I found 2 places had name "surfaces", *.H file: public: //- Runtime type information TypeName("surfaces"); *.C文file: PtrList<sampledSurface> newList ( dict.lookup("surfaces"), sampledSurface::iNew(mesh_) ); I changed these "surfaces" to "mysurfaces", and compiled, no problem. but when I used, had the following mistake, Starting time loop --> FOAM Warning : From function dlLibraryTable::open(const dictionary& dict, const word& libsEntry, const TablePtr tablePtr) in file lnInclude/dlLibraryTableTemplates.C at line 68 library "libmysampling.so" did not introduce any new entries Unknown function type mysurfaces Valid functions are : 5 ( surfaces fieldAverage fieldMinMax sets probes ) From function functionObject::New(const word& name, const Time&, const dictionary&) in file db/functionObjects/functionObject/functionObject.C at line 89. FOAM exiting It seems that my modified name haven't been registed in functionObject. Could anyone can give me some help ? Thanks. I am using like this in my controlDict file: extraction { type mysurfaces; functionObjectLibs ("libmysampling.so"); enabled true; outputControl timeStep; outputInterval 1; surfaceFormat foamFile; interpolationScheme cellPointFace; fields ( U T ); mysurfaces ( aplane { type plane; basePoint (-0.4 0 0.5); normalVector (1.0 0 0); } ); } |
Not able to use newly created library
I have created a library successfully, but I am not able to use it, It is giving error like below. Any help or input would be greatly appreciated..
Type of Error --> FOAM Warning : From function dlLibraryTable::open(const dictionary& dict, const word& libsEntry, const TablePtr tablePtr) in file lnInclude/dlLibraryTableTemplates.C at line 68 library "monitor.so" did not introduce any new entries Unknown function type monitor Table of functionObjects is empty From function functionObject::New(const word& functionType, const Time&, const dictionary&) in file db/functionObject/functionObject.C at line 75. FOAM exiting functionObject in ControlDict functions ( monitor { type monitor; functionObjectLibs ("monitor.so"); inletPatches (VolImp); outletPatches (Outflow); rhoInf 998.0; } ); My Inputs/Findings/Observations I searched over OpenFOAM forums, there were few discussion regarding this, which say if OpenFOAM-1.6 is being used then it might causing because some parameters in functionobject are missing in controlDict file. It also says error messages displayed for this problem in OpenFOAM-1.6 and OpenFOAM-1.5 are different, OpenFOAM-1.6 says as above but OpenFOAM-1.5 says "parameters are missing". Since I am using OpenFOAM-1.5 there must be another reason for this error.. |
Quote:
If you try with Code:
functionObjectLibs ("libmonitor.so"); Note the 'lib' prefix when specifying the library to load. Actually, it could be a good RFE to automatically add the 'lib' prefix and the '.so' suffix. I just don't know how this might look on other systems though. |
Thank you Olesen for suggestion..
According to your suggestion, I created a new library called libmonitor.so and loaded it in controlDict by using functionObjectLibs ("libmonitor.so"); but it is giving the same error with new library name. Below is error produced by simpleFoam. Please note when I changed functionObjectLibs ("monitor.so"); to functionObjectLibs ("libmonitor.so"); in controlDict then OpenFOAM asked for missing library so I created by name of libmonitor.so instead of monitor.so What would you suggest in this case, should I debug simpleFoam code ??? I do not know what help I could get by debuging but since I am a software engineer I know this way only. Type of Error Starting time loop --> FOAM Warning : From function dlLibraryTable::open(const dictionary& dict, const word& libsEntry, const TablePtr tablePtr) in file lnInclude/dlLibraryTableTemplates.C at line 68 library "libmonitor.so" did not introduce any new entries Unknown function type monitor Table of functionObjects is empty From function functionObject::New(const word& functionType, const Time&, const dictionary&) in file db/functionObject/functionObject.C at line 75. FOAM exiting |
I finally managed to create a library which works well.
Solution of the problem : updateMesh(const mapPolyMesh&) movePoints(const pointField&) Above virtual functions have to be overridden and FuctionObjects header file and C files need to be included. |
All times are GMT -4. The time now is 04:26. |