CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM

Multiple inheritance, function pointers or?

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

LinkBack Thread Tools Display Modes
Old   March 20, 2009, 11:36
Default Multiple inheritance, function pointers or?
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,759
Rep Power: 29
ngj will become famous soon enoughngj will become famous soon enough
Hi all

I have moved into an area of the C++ programming, where I do not feel on solid ground anymore, thus I hope to get some advice/ideas from the more experienced of you.

I am making a new template class derived from mixedFvPatchField<Type>. From this template class I am going to derive certain wave-boundary conditions, such as Stokes First Order Theory, Stokes Second Order Theory, and whatever theory you would like.
This is the straight forward part.

Further I am working on a class, which I call geometricIntersections. This class take an expression for an interface (water surface in this case) and returns an object describing how much of the face is wet, the center of the wet part, etc. I am going to use this class elsewhere, thus I do not want to implement it directly into the template class.
The description of the interface is naturally placed in the derived boundary classes.

I have been looking into different litterature/googled the possibilities and I have come up with two approaches.

1. Inherite the geometric class. This requires multiple inheritance, and there seems to be many pro and cons in this regard. The one I am especially worried about is the fact, that the this-pointer is only pointer at one of the base-classes. Is there a standard, which says at which base class it is pointing, e.g. the first one in the inheritance declaration?
Here the description of the interface is given as a virtual function.

2. The other possibility is to use function pointers, but as I see it, it is kind of messy to make the interface in such a way.

I am greatful for any suggestions or advice.

Have a nice weekend,

ngj is online now   Reply With Quote


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
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
BlockMesh FOAM warning gaottino OpenFOAM Native Meshers: blockMesh 7 July 19, 2010 14:11
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00

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