CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

SWIG wrappers interactive OpenFOAM

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 17, 2009, 06:47
Default Dear all, being not too fluen
  #1
New Member
 
Mariam Winkler
Join Date: Mar 2009
Posts: 4
Rep Power: 8
mariam is on a distinguished road
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
mariam is offline   Reply With Quote

Old   February 17, 2009, 06:51
Default Since OpenFOAM makes extensive
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
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
olesen is offline   Reply With Quote

Old   February 17, 2009, 07:03
Default Mark, yes the templates are th
  #3
New Member
 
Mariam Winkler
Join Date: Mar 2009
Posts: 4
Rep Power: 8
mariam is on a distinguished road
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
mariam is offline   Reply With Quote

Old   February 17, 2009, 10:38
Default Hello, I've wrapped the Geo
  #4
Member
 
Etienne Lorriaux
Join Date: Mar 2009
Location: Compiegne, France
Posts: 43
Rep Power: 8
elorriaux is on a distinguished road
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.
elorriaux is offline   Reply With Quote

Old   February 19, 2009, 07:40
Default Mariam, Etienne! I'm working o
  #5
Member
 
Johan Spång
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 35
Rep Power: 8
josp is on a distinguished road
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
josp is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 CD-adapco 0 March 14, 2002 12:47
SMARTFIRE: A new interactive fire field modelling CFD code. John Ewer Main CFD Forum 0 July 7, 1998 03:46


All times are GMT -4. The time now is 02:40.