|
[Sponsors] |
coded functionObjects behaving not as expected |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 26, 2020, 09:21 |
coded functionObjects behaving not as expected
|
#1 |
New Member
Alex Fells
Join Date: Sep 2019
Posts: 5
Rep Power: 7 |
Hi everyone,
I've been experimenting with coded functionObjects in OpenFOAM v7 and have noticed some unusual behaviour, specifically regarding accessing the mesh. I created the following coded functionObject, loosely based on the example outlined in the guide: https://cpp.openfoam.org/v7/classFoa...ionObject.html Code:
functions { test { type coded; libs ("libutilityFunctionObjects.so"); name holdUp; codeWrite #{ Info << "Things that go at the start of the functionObject go here." << endl; const volVectorField& U = mesh().lookupObject<volVectorField>("U"); Info << "Things that go at the end of the functionObject go here." << endl; #}; } } Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ Build : 7-5e743dcea67c Exec : postProcess Date : Oct 26 2020 Time : 13:15:42 Host : "login2.arc4.leeds.ac.uk" PID : 70703 I/O : uncollated Case : /nobackup/pm11af/2D/codedFunctionObject nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 60 Using dynamicCode for functionObject test at line 71 in "/nobackup/pm11af/2D/codedFunctionObject/system/controlDict.functions.test" Creating new library in "dynamicCode/holdUp/platforms/linux64GccDPInt32Opt/lib/libholdUp_3fd58367d4a7b3404ee8e36178d034265336b936.so" Invoking "wmake -s libso /nobackup/pm11af/2D/codedFunctionObject/dynamicCode/holdUp" wmake libso /nobackup/pm11af/2D/codedFunctionObject/dynamicCode/holdUp ln: ./lnInclude wmkdep: functionObjectTemplate.C Ctoo: functionObjectTemplate.C /nobackup/pm11af/2D/codedFunctionObject/system/controlDict.functions.test: In member function ‘virtual bool Foam::holdUpFunctionObject::write()’: /nobackup/pm11af/2D/codedFunctionObject/system/controlDict.functions.test:78:31: warning: unused variable ‘U’ [-Wunused-variable] ld: /nobackup/pm11af/2D/codedFunctionObject/dynamicCode/holdUp/../platforms/linux64GccDPInt32Opt/lib/libholdUp_3fd58367d4a7b3404ee8e36178d034265336b936.so Time = 60 Reading fields: Executing functionObjects Things that go at the start of the functionObject go here. #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in "/lib64/libc.so.6" #3 __dynamic_cast in "/apps/developers/compilers/gnu/6.3.0/1/default/lib64/libstdc++.so.6" #4 Foam::holdUpFunctionObject::mesh() const at ~/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/typeInfo.H:110 #5 Foam::holdUpFunctionObject::write() at system/controlDict.functions.test:78 #6 Foam::functionObjectList::execute() at ??:? #7 ? at ??:? #8 ? at ??:? #9 __libc_start_main in "/lib64/libc.so.6" #10 ? at ??:? Segmentation fault From line 4 of the error, it seems to me that the mesh object doesn't exist. Any idea how I can get this to work? I would expect mesh to be accessible from a functionObject. I've tested this on two machines both belonging to my university and the error is reproducible. Kind regards, Alex Last edited by alexfells; October 26, 2020 at 11:02. Reason: Provided additional info. |
|
October 27, 2020, 15:17 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
It usually makes sense to use old school "printf" debugging to verify that your code and assumptions are correct. For example, check with foundObject if the field is there. Print out the toc() from the registry to see which objects really are there etc.
|
|
October 28, 2020, 04:58 |
|
#3 |
Senior Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 143
Rep Power: 20 |
I think the fields are not loaded, as you do this via postProcess tool. I am not quite familiar with the post-processing CLI, but some ideas (not tested):
Code:
postProcess -fields "(U)" -func yourCodedFunction Code:
interSimplePimpleWhateverFoamSolver -postProcess -func yourCodedFunction Hope this helps, Jan |
|
Tags |
codedfunctionobject, functionobject |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
error compiling modified applications | yvyan | OpenFOAM Programming & Development | 21 | March 1, 2016 05:53 |
ParaView for OF-1.6-ext | Chrisi1984 | OpenFOAM Installation | 0 | December 31, 2010 07:42 |
POSDAT problem | piotka | STAR-CD | 4 | June 12, 2009 09:43 |
wmake compiling Problem with OF1.5 | openTom | OpenFOAM Installation | 4 | May 3, 2009 15:44 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |