GTS comes with a simple script called gtstemplate which will generate a C code template for the new class you want to create. For a summary of its syntax just type:
% gtstemplate Usage: gtstemplate [OPTIONS] Class ParentClass Options: [--no-extra-data] [--no-extra-method] [--overload=METHOD]As an example we are going to try and create a template for a new initial condition class called InitPeriodic. Just type:
% gtstemplate --overload=read --overload=write --overload=event \ InitPeriodic GfsInit > init_periodic.cWe have just created a template for a new class called InitPeriodic derived from GfsInit and where the read, write and event methods are overloaded. Fire up your favourite editor and have a look at the file generated: init_periodic.c. The first thing you see is that the file is divided in two sections starting with
/* InitPeriodic: Header */and
/* InitPeriodic: Object */As their names indicate these sections correspond respectively to the declaration of the structures and functions (header part) and to the corresponding definitions (object part). If we were to use these functions and structures in a library, these two parts would be in separate files (a .h and a corresponding .c file). For what we are interested in (a gerris module) they are fine staying in the same file. There is a function we will not need: init_periodic_new, just remove the lines declaring and defining it in the header and object sections. We are left with only one function: init_periodic_class. This function essentially registers our new class and its associated attributes. Things like: