Element Output Example

This example demonstrates how to use template files to generate output files for elements.

Assume that a particular analysis code requires the elements in the data deck to appear in the following format:
1       10        20        30        40       50
BEGIN ELEMENT DATA
  ELEMENTS GROUP = <name>
      <id>   <node1>   <node2>   <node3>  <node4>
  .
  .
  .
  END
.
.
.
END ELEMENTS

This example assumes that the analysis code requires grouped element output, where elements with the same property are placed into the same output element group, regardless of component organization.

The following template generates the necessary output:
*text()
  *string("1       10        20        30        40       50") *end()
*output()

*elements(104,1,"quads","property")
  *before()
    *string("BEGIN ELEMENT DATA") *end()
  *beforecollector()
    *string("  ELEMENTS GROUP = ") *field(string,collector.name,10) *end()
  *format()
    *field(integer,id,10) *field(integer,node1.id,10)
    *field(integer,node2.id,10)*field(integer,node3.id,10)
    *field(integer,node4.id,10) *end()
  *aftercollector()
    *string("  END") *end()
  *after()
    *string("END ELEMENTS") *end()
*output()

Note the placement of the *() commands. HyperWorks Desktop does not place restrictions on where the commands appear in the file, so you can format the template as necessary. Comments can also be added for documentation purposes. HyperWorks Desktop ignores file content until it finds an asterisk, *. A command is defined as the characters between the asterisk and the closing parenthesis, ).

The *elements() command instructs HyperWorks Desktop that the following commands define an element output block or process. The parameters to the *elements() command are the configuration and type of element the output block applies to: a user-defined name for the elements, and a user-defined name for the property the elements require. Element configurations are listed in the following sections for each of the HyperWorks Desktop elements. Element types are a user-defined number associated with each HyperWorks Desktop element (defaults to 1). Changing the type allows multiple definitions for a HyperWorks Desktop element configuration. A quad is configuration 104 and type 1. When these parameters are supplied, HyperWorks Desktop limits the output of this process to quad elements. The next series of commands, *before() , *string(), and *end() behave as described in the node example.

The *beforecollector() command instructs HyperWorks Desktop to process the following commands on the beforecollector() level. When the beforecollector() level is selected, HyperWorks Desktop processes the commands each time it finds a collector holding the required type of information in the database. In this case, *string(), *field(), and *end() are the commands HyperWorks Desktop processes when a component is found. On the *field() command, the data name is collector.name.

*format() describes the process for each element of configuration 104 and type 1. The format commands use the data name node1.id, node2.id, and so on. The period, ., is required because node1 is a pointer to a node. node1.id is the ID of the node.

In addition to this example, the default HyperWorks Desktop templates serve as examples.