A.6.3 Creating Default Sections Using Inheritance

Generally, inheritance of sections can be used to introduce a collection of predefined default settings. Suppose within a section called MySectionDefaults a set of default variables is defined as shown in the example below. By means of inheritance, the elements of this section are passed on to section MySection where all modifications have to be performed later on.

// Begin of the default file mydefaults.ipd
MySectionDefaults
{  var1 = 5;                    // default value
   var2 = 10;                   // default value
}
MySection : MySectionDefaults;  // predefined inheritance
// End of the default file mydefaults.ipd

The inheritance for section MySection has been predefined. To use the defaults settings the default file must be included in the user input file. If no changes have to be performed for the section MySection no additional declarations need to be done in the user input file:

// Begin of user file
#include "mydefaults.ipd"
// End of user file

If modifications have to be performed the section MySection must be reopened and locally modified in the user file, e.g.,

// Begin of user file
#include "mydefaults.ipd"
MySection                   // still inherited from MySectionDefaults
{   var2 = 20;              // new value
}
// End of user file

In this example the section MySection is reopened and the variable var2 is locally modified. The original inheritance of section MySection is preserved.

If two alternative default sections have to be defined a common base section must be used to enable the Input Deck database to check for misspelling of names. In the following example the common base section MyDefaults is defined which contains empty definitions of variables used in the default sections MySectionDefaults1 and MySectionDefaults2 derived from that section just to enable the checking mechanism. After the definition of the two default sections the inheritance is predefined again for the section MySection.

// Begin of the default file mydefaults.ipd
MyDefaults
{  var1 = "";               // empty definition
   var2 = "";               // empty definition
}
MySectionDefaults1 : MyDefaults // first section of default values
{  var1 = 5;                // default value
   var2 = 10;               // default value
}
MySectionDefaults2 : MyDefaults // second section of default values
{  var1 = 6;                // default value
   var2 = 11;               // default value
}
MySection : MySectionDefaults1; // predefined inheritance
// End of the default file mydefaults.ipd

Moreover, in the user file the inheritance for the section MySection can be changed explicitly if desired, e.g.,

// Begin of user file
#include "mydefaults.ipd"
MySection : MySectionDefaults2 // another inheritance defined
{  var2 = 10;               // new value
}
// End of user file

Reopening of already defined sections or changing of the inheritance can only be performed for empty sections.

Robert Klima 2003-02-06