Previous TableOfContents Next

Adding a New Tracker Output File Format

Impact is designed to be able to write result data in various formats. There are several different post-processors available to view this result data and the default one for Impact is GID.

To enable writing of tracker data, a trackwriter object is used. The object is initiated as soon as the indata file is read because it is the indata file that decides which format to print in. If nothing is specified, the GID trackwriter object is used.

The TrackWriter Class

The trackwriter class is the mother class for all the different trackwriters. Similar to the Reader class, it mainly contains abstract methods and a few general methods for the subclasses to use. They will be described later.

Creting a Sub Class

Adding a new output format means adding a new subclass to the trackwriter class. This subclass has the task of structuring and directing the output. It works by calling the different trackers, asking them to collect and calculate the results and finally to print their data one by one. The whole "orchestration" of this procedure is done by an object initiated from this subclass.

At the time of writing, there is only one subclass, called Gidtrackwriter. The main method for this class is the write method which is used by the Smack object to order printing of results. During the simulation, this method will be called several times since explicit programs dump their results frequently during simulation. We will go through this method in detail in the next part.

The data we want to print is all contained inside tracker objects. To make matter worse, the data is also encapsulated inside these objects in private variables, making them unreachable from our Gidtrackwriter object. The way to print this data is then to ask the trackers to print it. But how does the tracker know which format to print the results in? The output can look very different from format to format.

The solution is to create a unique printing method for each output format. For each new output format added to Impact, it will mean that each tracker sub-class will have to add one more print method. This approach makes it "messy" to add new output formats since the programmer has to add code in other classes than the trackwriter and trackwriter sub-classes, but since the amount of output formats are far less than amount of tracker types, this seems to be the most rational approach.

Remember that as you add a new trackwriter type, you must add that type to the trackwriter getTrackWriterOfType_xxxx method(s).

The Methods

write

When this method is called, it is time to write the output data from the solution. The Gidtrackwriter just asks each tracker in turn to write it's result through the use of the writeResult method.

Other things to think of


Previous TableOfContents Next