Previous | TableOfContents | Next |
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 data, a writer 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 writer object is used.
The writer class is the mother class for all the different writers. 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.
Adding a new output format means adding a new subclass to the writer class. This subclass has the task of structuring and directing the output. It works by calling the elements and nodes (which contain the results) and asks them 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 GidWriter. 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 element and node objects. To make matter worse, the data is also encapsulated inside these objects in private variables, making them unreachable from our GidWriter object. The way to print this data is then to ask the elements to print it. But how does the element 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 element sub-class will have to add one more print method. (The node class already has methods which provides the results data). This approach makes it "messy" to add new output formats since the programmer has to add code in other classes than the writer and writer sub-classes, but since the amount of output formats are far less than amount of element types, this seems to be the most rational approach.
We will soon have a look at what the extra methods in the element classes will mean.
When this method is called, it is time to write the output data from the solution. The implementation of this method in the GidWriter looks as follows:
public void write(String fname, double currtime) {
filename = new String(fname);
time = currtime;
try {
if (counter == 0) {
writeMesh();
}
writeResult();
counter++;
} catch (IOException ioe) {
System.out.println(ioe);
return;
}
}
Two private methods are used here, writeMesh and writeResult. They are the ones doing the main job. The first time the write method is called, some mesh data is written through the writeMesh method in addition to some results. The following times, no more mesh data is written. This is what the GID post-processor wants as input so that is what we must write.
This is a private method. It may only exist for the GidWriter class but I will explain what it does in any case to give a good feeling for this concept.
The method basically gets information from the node objects by asking them for their position in space and then formatting this information to print a mesh data file in the correct format. It can ask the nodes directly since there are general methods for all the data in the node.
It also asks the elements to print all their data about which nodes each element is connected to. This is data that each element object knows, but it is private data. Have a look at this line of code:
bw.write(temp_element.print_Gid(Element.MESH, 0)
Here, the element is asked to print the data using a special control code (Element.MESH). In other cases, the element may be asked to print something else and then another control code will be used. The resulting string of data is then directly written to the file (bw).
The principle used in this method is the same. Each element is asked to print it's data but by using a control code, the data printed by the element may differ according to need. You can find the details in the code itself.
Each element must contain a method to print it's data. The name of this method is standardised to print_name where name is the name of the output format.
The method should access the data in the element and create an output string which will be printed by the writer object. The request from the writer may differ depending on situation and therefore a control code must also be sent which the method must follow to do the right thing
The second parameter is the gauss point number of the element. Since each element will contain at least one Gauss point and the results are stored there, printing will be made for each gauss point. This parameter specifies which gauss point to read and print.
Naturally, the implementation of this method will differ from element type to type which is why each element type needs this method. Remember now when you write a new output format to go through each element sub-class and add this method.
Previous | TableOfContents | Next |