CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Multiple inheritance paradigms in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 27, 2018, 10:05
Default Multiple inheritance paradigms in OpenFOAM
  #1
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
Merry Christmas everyone,

from time to time, by going through the OF code (v16.12), I see some crazy (to me) inheritance hierarchies combined with multiple inheritance. One example is the class template reactingMixture (src/thermophysicalModels/reactionThermo/mixtures/reactingMixture):

Code:
template<class ThermoType>
class reactingMixture
:
    public speciesTable,
    public autoPtr<chemistryReader<ThermoType>>,
    public multiComponentMixture<ThermoType>,
    public PtrList<Reaction<ThermoType>>
{
    // ...
    // declarations
    // ...
};
I've learned that public inheritance can be understood as "is a" relationship (here reactingMixture<ThermoType> is a autoPtr<chemistryReader<ThermoType>>, for instance). The previously posted code does not seem to fit this principle, as the "is a" criterion does not fit for most of these base classes.

My question: Is there a reason for that (some kind of paradigm I do not know about)? What are the advantages of such design? I thought that usually this kind of problem would be solved through composition. Am I just not seeing the big picture?

Thanks for your answers
RP
raumpolizei is offline   Reply With Quote

Old   December 30, 2018, 05:18
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
You are probably right that the reader could/should be a member composition instead of inheritance (although I don't have the code in front of me at the moment). Please open a gitlab issue to track and discuss this.
Thanks,
/mark
olesen is offline   Reply With Quote

Old   January 1, 2019, 11:20
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
filed as https://develop.openfoam.com/Develop...us/issues/1144
olesen is offline   Reply With Quote

Old   January 4, 2019, 08:16
Default
  #4
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
Thanks Mark
raumpolizei is offline   Reply With Quote

Reply

Tags
c++, oop, openfoam, software design, thermo library


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
Multiple outlet treatment in OpenFoam hooman.4028 OpenFOAM Running, Solving & CFD 1 July 19, 2017 00:38
OpenFOAM Training Jan-Jul 2017, Virtual, London, Houston, Berlin CFDFoundation OpenFOAM Announcements from Other Sources 0 January 4, 2017 06:15
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 13:36
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21


All times are GMT -4. The time now is 16:27.