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

[OpenFOAM 1.7.1] runTimeSelection two levels deep?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 29, 2012, 09:37
Default [OpenFOAM 1.7.1] runTimeSelection two levels deep?
  #1
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
Hi all,
I am trying to implement some models in OpenFOAM and need some advice on the strategy.
Basically the structure is this:

Let's say the base is A, and when the user chooses to activate the feature A, he/she has the choice of two models B and C. This part is easy to implement using runTime selection.

Now I want to add a new model to the mix, so that the user can choose feature A, and then the models B,C or D.

The new thing about D is that D can have submodels, say D0 and D1.

If I am not wrong in this case I would need runTimeSelection that is two levels deep. Is it at all possible in the current framework?

And if you can point me to a place where something similar has been done it'll be great.
adhiraj is offline   Reply With Quote

Old   January 29, 2012, 15:07
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Good evening Adhiraj

What you are asking about is definitely possible, however, what you are after is still a bit unclear to me.

So the interface, which both B, C, and D obeys to is identical. Nevertheless, D has some special properties which differs, namely D0 and D1, so the question is:

Why are you not simply making two runTime selectable object E and F, where E=D+D0 and F=D+D1?

To make it into a practical discussion, then D0 and D1 describes the behaviour of one particular parameter, so if you want your original design, then you can make a runTime selection of say myDFunctionalityParameter and in D you get a pointer to this object in the standard runTime way, namely

Code:
autoPtr<myDFunctionalityParameter> Dparameter = DN::New(argList);
scalar returnMyParameter = Dparameter->param();
So, in this way you have the runTime selection, however, it is not a direct two-level method, but it is a runTime selection, which is nested inside another runTime selection. The object 'Dparameter' is obviously a private variable in D.

I hope this helps.

Kind regards,

Niels
ngj is offline   Reply With Quote

Old   January 29, 2012, 21:41
Default
  #3
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
Thanks for replying.
I am not fully sure what you meant, but possibly something like this:
Implement A, B, C, D as usual. Put the functionalities D0 and D1 in a different class, which runs with P as base, and E and F derived from it.
So now D has as a member a pointer to P, and using runtime selection that pointer gives D access to the appropriate model E or F.
adhiraj is offline   Reply With Quote

Old   January 30, 2012, 03:28
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi

No, you have mixed my suggestions together. I suggest the following possibilities:

1. Make the derived classes from A, which are called B, C, DD0, DD1, where DD0 is the derived class D from A, which explicitly contains the methods held in D0, and similar for DD1. DD0 and DD1 are those I called E and F.

2. The second option is to make the derived classes B, C, D, from the (abstract) base class A. Then, as you state, D holds a pointer to an abstract base class P, from which you derive D0 and D1, which are then chosen using runTime selection.

If D0 and D1 is simple and you are not going to extend it, then at least as a start I would go for "1", whereas, if the complexity is large, and D0 and D1 contains many methods, then go straight for "2".

Kind regards,

Niels
ngj is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 15:05.