|
[Sponsors] |
February 17, 2009, 05:47 |
Dear all,
being not too fluen
|
#1 |
New Member
Mariam Winkler
Join Date: Mar 2009
Posts: 4
Rep Power: 17 |
Dear all,
being not too fluent in C, I had tried to wrap the OpenFOAM functions in order to use it from python. While this helped me substantially with other simulation software, I was unable to get a working OpenFOAM wrapper. Unfortunately I failed at the very basic GeometricField classes. I was happy to read Ivor in thread http://www.cfd-online.com/OpenFOAM_D...s/1/10942.html, who mentioned that he was working on such a wrapper. Can I find somewhere Ivor's wrapper or the code it is based on, for helping my OpenFOAM experience with a more user-friendly programming environment? Assuming that it is quite some work to wrap all OpenFOAM classes, I'm also interested to contribute some parts, probably related to, but not limited to turbomachinery. However, as I said, I couldn't get started on my own and I need help with the basic SWIG interface setup. Mariam |
|
February 17, 2009, 05:51 |
Since OpenFOAM makes extensive
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Since OpenFOAM makes extensive use of C++ templates, I can imagine that wrapping them with SWIG might require a fair amount of attention.
A quick google turned up this as a starting point for you: http://www.salome-platform.org/forum...11&thread=1564 |
|
February 17, 2009, 06:03 |
Mark, yes the templates are th
|
#3 |
New Member
Mariam Winkler
Join Date: Mar 2009
Posts: 4
Rep Power: 17 |
Mark, yes the templates are the cause of my problems. But apparently Ivor and Hrv have built a wrapper despite of the difficulties.
I am less asking about advice how to solve each individual problem (have worked with SWIG and templates a lot, but never had similar problems). Rather I hope I can build upon previous code. Thanks Mariam |
|
February 17, 2009, 09:38 |
Hello,
I've wrapped the Geo
|
#4 |
Member
Etienne Lorriaux
Join Date: Mar 2009
Location: Compiegne, France
Posts: 45
Rep Power: 17 |
Hello,
I've wrapped the GeometricField with swig : template<class> class PatchField, class GeoMesh> class GeometricField{ public: GeometricField ( const IOobject&, const GeoMesh::Mesh& ); }; %template(volScalarField) GeometricField<scalar,fvpatchfield,volmesh>; %template(volVectorField) GeometricField<vector,fvpatchfield,volmesh>; %template(surfaceScalarField) GeometricField<scalar,fvspatchfield,surfacemesh>; %template(surfaceVectorField) GeometricField<vector,fvspatchfield,surfacemesh>; It seems to work, i'm able to run icoFoam and I'm getting the same results than the original solver. But swig is too limited, i'm thinking to switch to boost. For the moment, i'm able to run almost everything i need with swig wrappers (great difficulties with the dytnamicFvMesh class), but i fear that i will we locked with this project in the future. Note that i'm working with OF-1.4.1-dev for this wrapping project, i've not upgraded my wrappers to 1.5-dev yet. Etienne. |
|
February 19, 2009, 06:40 |
Mariam, Etienne! I'm working o
|
#5 |
Member
Johan Spång
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 35
Rep Power: 17 |
Mariam, Etienne! I'm working on some boost-python wrapping of OpenFOAM. But I have a different approach in that I have embedded an interactive python prompt into parallel runs of OpenFOAM. So OpenFOAM is still started as usual with foamJob -p solverName
It's possible to inspect the properties of (say) a scalarField at runtime and use all the great python tools like numpy/pylab to process the data. I think boost-python is a more suitable tool but swig will probably work aswell. I wrapped volScalarField like this: /* Foam volScalarField */ class_<volscalarfield> ( "volScalarField", "__doc__ volScalarField", init <const GeometricField< double,fvPatchField,volMesh>& >() ); Still, embedding/extending or plain extending does not really matter since the wrapping procedure is the same. I'll upload the code (very early development) somewhere as soon as I can! Best wishes /Johan |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM users in Munich OpenFOAM benutzer in M%c3%bcnchen | jaswi | OpenFOAM | 0 | August 3, 2007 13:11 |
A new Howto on the OpenFOAM Wiki Compiling OpenFOAM under Unix | mbeaudoin | OpenFOAM Installation | 2 | April 28, 2006 08:54 |
Vehicle Thermal Management Interactive Course | CD adapco Group Marketing | Siemens | 0 | March 14, 2002 11:47 |
SMARTFIRE: A new interactive fire field modelling CFD code. | John Ewer | Main CFD Forum | 0 | July 7, 1998 03:46 |