Writing an Input Reader
node, 1, 0.0, 0.0, 0.0
node, 2, 100.0, 0.0, 0.0
node, 3, 100.0, 100.0, 0.0
node, 4, 0.0, 100.0, 0.0
node, 5, 0.0, 0.0, 100.0
node, 6, 100.0, 0.0, 100.0
node, 7, 100.0, 100.0, 100.0
node, 8, 0.0, 100.0, 100.0
quad, 1, 1, 1, 2, 3, 4
tria, 2, 2, 5, 6, 7
tria, 3, 2, 5, 7, 8
property, 1, 1, 0.75
property, 2, 1, 1.00
material, 1, 20000.0, 0.3
hmcolor, component, 1, 9
hmcolor, component, 2, 10
hmname, component, 1, comp1
hmname, component, 2, comp2
hmname, material, 1, material
const, 1, 123456
const, 2, 123456
const, 5, 123456
const, 6, 123456
force, 3, 0.0, 0.0, 10.0
force, 7, 0.0, 0.0, 10.0
The task of writing an input translator is now defined. The entities that exist in the input deck must be transferred to HyperMesh; more specifically, the nodes, elements, constraints, forces, property, and material information must be translated into a format understood by HyperMesh. Given this objective, and with the use of the hminlib functions, it is now possible to write an input translator.
The source code for the example is listed at the end of the section. As the example progresses, it is recommended that you open your manual and flip to the end of the section in order to follow the source code while reading.
As described above, the structure of an input translator written with the program follows a specific format. The first step that an input translator must perform is to initialize hminlib. This is performed by calling the function HMIN_init(). Note that in the example source code below, the function main() calls HMIN_init(), which takes four parameters. The four parameters are the name of the translator, the version of the translator, and then the argc and argv parameters, which are passed into main(). Also note that HMIN_init() returns a pointer to the input file to be read. HMIN_setsolver() is then called to associate attributes with a given template (see *codename () in the template section).
In the next line of the program, control is passed to hminlib. This is accomplished with the function HMIN_readmodel(), which takes a pointer to a function as its only parameter. The function pointer points to a function from which hminlib can retrieve the user-defined functions used to read in an input file. For this example, refer to this function as the inquire function. Note that the inquire function, passed in HMIN_readmodel(), takes two arguments. The first argument, function, is the type of function hminlib is requesting. As described above, one of the user-definable functions is the open function, and the function returns fetestopen() when the value HMIN_OPENFUNCTION is requested. Prepare the inquire function to deal with the following values for function:
HMIN_OPENFUNCTION
HMIN_ENTITYOPENFUNCTION
HMIN_ENTITYGETFUNCTION
HMIN_ENTITYDICTIONARYFUNCTION
HMIN_ENTITYCLOSEFUNCTION
HMIN_COLORFUNCTION
HMIN_NAMEFUNCTION
HMIN_MOVEFUNCTION
HMIN_CLOSEFUNCTION