Professional Documents
Culture Documents
Contents
Introduction ......................................................................................................2
About This Series ...........................................................................................2
About This Book .............................................................................................2
Supporting Material ........................................................................................3
Product Design and Process Management ...........................................................4
Projects, Practices and Processes ....................................................................4
Processes, Creativity and NPD.........................................................................6
CAE and Process Management ........................................................................7
Summary .......................................................................................................9
Process Management and Customization........................................................... 10
Process Templates ....................................................................................... 10
Process Customization .................................................................................. 11
What Does Customization Involve?................................................................ 12
The Key Questions ....................................................................................... 13
Customization and Programming ...................................................................... 15
A Programming Primer ................................................................................. 15
Customizing HyperWorks .............................................................................. 17
Putting It All Together .................................................................................. 24
The Process Manager....................................................................................... 26
Creating Process Wizards .............................................................................. 26
Anatomy of a Process Template .................................................................... 28
The Folder Structure..................................................................................... 32
Advanced Topics ............................................................................................. 34
Debugging ................................................................................................... 34
Programming Languages – An Abstract View ................................................. 36
Programming – The HyperWorks View........................................................... 38
XML............................................................................................................. 46
Glossary And References.................................................................................. 48
References................................................................................................... 50
Other Resources........................................................................................... 51
Macros on the User Page .............................................................................. 51
Templex and Templates................................................................................ 51
1
Introduction Managing the CAE Process
Introduction
About This Series
To make the most of this series you should be an engineering student, in
your third or final year of Mechanical Engineering. You should have access
to licenses of HyperWorks, to the Altair website, and to an instructor who
can guide you through your chosen projects or assignments.
The various references cited in the book will probably be most useful after
you have worked through your project and are looking for ways to increase
the scope and elegance of the applications you have developed.
2
Managing the CAE Process Introduction
Supporting Material
Your instructor will have the Instructor’s Manual that accompanies these
volumes – it should certainly be made use of. Further reading and
references are indicated both in this book and in the Instructor’s Manual.
If you find the material interesting, you should also look up the HyperWorks
On-line Help System. The Altair website, www.altair.com, is also likely to be
of interest to you, both for an insight into the evolving technology and to
help you present your project better.
The world has arrived at an age of cheap complex devices of great reliability;
and something is bound to come of it.
Vannevar Bush. in 1945
3
Processes and Product Design Managing the CAE Process
we run the risk of going too far in one direction. There’s another side to
product design, one that emphasizes the need for discipline. All you need to
do is browse through a biography of Thomas Edison to understand the
relevance of this aspect of product design. Edison was, by most accounts,
one of the most prolific inventors in recent times. He held 1,368 patents, is
credited with having said that genius is 99% perspiration, 1% inspiration
and famously observed that “none of my inventions came by accident. I see
a worthwhile need to be met and I make trial after trial until it comes.”
1
which is how the Random House Unabridged Dictionary defines it
4
Processes and Product Design Managing the CAE Process
seen as a dark art, relying heavily on the skill of the individuals involved in
the management of the project. But Project Management is a skill that can
be studied and learned. Several sectors rely on this, most notably Software
Development and IT Services companies. Certification by the Project
Management Institute (www.pmi.org) is quite widespread.
The idea that for every task there is a technique that is more effective than
any other technique is quite widespread in management. Most organizations
develop a series of Best Practices, which are nothing but preferred
techniques for the various scenarios the teams are likely to encounter. While
the concept is attractive, there are three problems from the operational
point of view. The first problem lies in gathering these Best Practices. The
second lies in ensuring that these are made available to all participants in a
usable fashion. The third lies in ensuring that these practices, after all the
effort of collecting them and disseminating them, are actually followed!
2
Adapted from Stevens, G.A. and Burley, J – “3000 Raw Ideas = 1 Commercial
Success!”, Research Technology Management, Vol 40, #3, pp 16-27
5
Processes and Product Design Managing the CAE Process
time and money, managers look for ways to estimate and control both.
Processes, of course, are a natural option to try.
Remember that the intention behind the drive for process is to aid and
enhance creativity, which in turn leads to better products. One popular view
of product development is that the three essential ingredients for successful
product design are People, Processes and Technology. An organization that
has good people and good process but poor technology is inefficient. One
that has good people and technology but poor processes is undisciplined,
while one that has good processes and technology but poor people is
amateur.
3
A review of “Agile Development” methods is instructive – see, for example,
http://en.wikipedia.org/wiki/Agile_software_development
6
Processes and Product Design Managing the CAE Process
The fact that “new to the world” products are a relatively small fraction is
interesting. The logical conclusion is that organizations should pay attention
to building and retaining knowledge about how existing products are
designed – in other words, to capture the design methods and approaches
and make these widely available to designers. In other words, to build
design processes.
4
APQC benchmarking study: Cooper, R.G., Edgett, S.J. and Kleinschmidt, E.J.,
“Benchmarking best NPD practices—II: Strategy, resource allocation and portfolio
management”, Research Technology Management, 47:3, May/June 2004, 50-59.
7
Processes and Product Design Managing the CAE Process
Clearly, the potential impact of CAE-errors can be very high. And, clearly,
the process for CAE is well defined. The missing link is the ability to verify
that the process has actually been followed!
5
From http://www.ima.umn.edu/~arnold/disasters/, written by D.N.Arnold, of the
University of Minnesotta.
8
Processes and Product Design Managing the CAE Process
to-absorb information summaries, and walk back all the way through the
CAE process, checking each and every step.
This approach is not just necessary for safer and better product design. In
several countries, the law requires that such design-records be maintained.
Summary
We have seen that
The most important task for a designer is to “design the right product”. We
cannot supply the answer to that, but we can certainly make it easier to
“design the product right”!
There is nothing so wasteful as doing with great efficiency that which doesn't
have to be done at all.
Anon
9
Customization and Process Management Managing the CAE Process
Process Templates
It’s one thing to agree that a process is useful. Actually defining the process
is an entirely different problem. How does one go about identifying the steps
that make up the process? Should a process be created, or can it be built?
I still remember the jolt I felt in 1958 when I first heard a friend
talk about building a program, as opposed to writing one. In a
flash he broadened my whole view of the software process. The
metaphor shift was powerful, and accurate. Today we understand
how like other building processes the construction of software is,
and we freely use other elements of the metaphor, such as
specifications, assembly of components, and scaffolding.
Continuing with the “build” metaphor, the search for a suitable process can
be compared with the search for a suitable house.
One alternative is to start from the ground up – a brand new design, chosen
to fulfill specific requirements. This makes sense if you can afford both the
6
In his article “No Silver Bullet: Essence and Accidents of Software Engineering”. See
http://en.wikipedia.org/wiki/No_Silver_Bullet
10
Managing the CAE Process Customization and Process Management
cost and the time. And if you have the confidence that what you will end up
with is what you actually want. This is important, unless you’re prepared to
redo it after you see what the result is, incurring further costs and spending
more time before it’s ready for use.
Few house owners are prepared for that risk, so the starting point is often a
set of examples that serve as starting points. Another option is to buy an
existing house and make modifications to suit your preferences.
The ground-up approach is to write the process definition from scratch. Not
only is this expensive and time consuming, there’s also the risk that the
questions you’re addressing to define the process are the wrong ones – and
you won’t know it till you implement it. Process templates offer a way out of
this. A process template serves as a pattern or a model, a good starting
point. It is built upon knowledge and experience acquired by others, so
serves as an excellent way to capture process knowledge.
And if the context in which that experience was acquired is not the same as
yours, the answer is easy – just customize it.
Process Customization
Customization, though, involves modifications, and modifications invariably
carry the risk that you’re introducing fresh errors or inaccuracies. To quote
Brooks again,
7
Interested readers will find Brooks’ The Mythical Man Month worth reading.
11
Customization and Process Management Managing the CAE Process
Brooks’ description makes the risks clear, but to balance the discussion, the
benefits must also be understood just as clearly. Customized processes can
bring tremendous benefits, if done right, particularly for CAE. Remember
that CAE is repetitive. The analyses involved in the design of products,
whether they are totally new or are modifications of existing designs, are
based on best practices drawn from the experience of engineers and
analysts. As a result, CAE involves a set of tasks with relatively small
variations – the sequence of tasks is often referred to as a workflow. The
ability to capture and automate this workflow can be well worth the
investment.
Why customize?
At the most obvious level, process-customization helps reduce mistakes.
Checklists are common in many engineering areas – aircraft, for instance, go
through rigorous checklists at every landing and before every takeoff. Most
CAE applications provide a broad range of checks, such as the element-free-
13
Customization and Process Management Managing the CAE Process
The third obvious benefit is the reduction in time to carry out a set of tasks,
as outlined above in the Audi case.
Less obvious, but often even more beneficial, are the improvements in
product quality that the use of a good process can bring. Design
methodologies such as Design For Six Sigma (DFSS) consider the link
between process quality and product quality to be an axiom. The Law of
Quality states that “the quality of a product is largely determined by the
quality of the process that is used to develop and maintain it.”
A second factor on this side of the equation is time. Even if you are willing to
afford the cost, will the program be ready before the need has expired?
We’ll round up this chapter by turning back to Fred Brooks again. In the
article cited above, he writes “The most radical possible solution for
constructing software is not to construct it at all”. We’ll spend the rest of this
book looking for less radical solutions!
14
Managing the CAE Process A Primer on Programming Approaches
A Programming Primer
Programming languages are of two different types10: systems programming
languages and scripting languages.
Languages like Perl, Python, Visual Basic and Tcl are scripting languages.
These are task-specific. Perl, for example, is designed specifically for text-
manipulation – the name itself stands for Practical Extraction and Reporting
Language. It would not be your language of choice for numerical
computations.
9
Some of these are listed at the end of this book.
10
Purists will rightly point out that there are other types too – such as Assembly
Languages.
15
A Primer on Programming Approaches Managing the CAE Process
Strongly typed programs have the advantage that errors in logic can be
trapped at compile-time, when the compiler reads the source code and
checks for syntactical errors. Scripting languages tend to be interpreted, not
compiled, which means errors often occur at run-time. As a result, testing a
program becomes harder. This leads to an important point: because of the
testing constraints, scripting-languages are mainly used for smaller
programs, while systems-level languages are preferred if the program is
large and complex.
11
See http://home.pacbell.net/ouster/scriptextra.html. Prof.Ousterhout, of course, is
the creator of Tcl and Tk.
16
Managing the CAE Process A Primer on Programming Approaches
Customizing HyperWorks
The various modules that make up HyperWorks – HyperMesh, OptiStruct,
HyperView, etc. – cover all the methods outlined above. We’ll review these
in order of increasing complexity and power before we go on to study the
framework that we’ll use to bring all these together to address process-
definitions.
17
A Primer on Programming Approaches Managing the CAE Process
Macros
A macro is a way to automate repetitive tasks. The macro can be assigned
to a menu or icon, so that a single click results in the execution of the entire
set of command. At its most basic, a macro is just a set of commands,
offering no options to add logic such as if-then-else or do-while constructs.
But macros can be combined with the other customization options, which
means that their power can be extended considerably.
Understanding two files can go a long way towards getting started with
macros. The first of these is command.cmf – it’s a text file in which
HyperMesh stores every command you execute during your HyperMesh
sessions. It’s importance lies in the fact that the recommended way to
create a macro is:
• start HyperMesh
*beginmacro(name)
*endmacro()
The next important file is userpage.mac. This is the file HyperMesh refers to,
to decide which commands must be displayed on the user-menu page,
12
You can use any text editor such as notepad for this, but will be better off with
an editor like notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm)
18
Managing the CAE Process A Primer on Programming Approaches
which is the page that’s displayed when you click on the “User” button on
the Utility Menu. To assign your macro to a button on the user-page, you
edit this file and add a line of the form
From this line, HyperMesh concludes that the button must be created on
page 5 of the Utility Menu, with the word “Test” displayed on the button.
The button is placed at row 20, column 4, and has a width of 6. The button
is colored magenta and displays the words “Test Macro” as help when the
mouse hovers over the button. Finally, when the button is clicked, the macro
named sample is called. Remember that the macro gets its name from the
*beginmacro command.
And how does HyperMesh know which file the macro’s commands reside in?
One option is to paste the entire macro in the file userpage.mac itself, but
this can get messy. A better option is to use the command
*includemacrofile("filename.mac") where filename.mac contains your
macro.
You can call one macro from another, using the *CallMacro( )
command13. This allows you to create a standard set of macros that can be
reused. A complete list of all commands available for use in macros is in the
on-line documentation under the section titled Alphabetical List of
HyperMesh Commands. Since there are more than 1600 commands, this is
best treated as a reference section, to look up for details on the commands
you’ve recorded.
Macros can also be run using the Files / Load / Command file menu.
Tk (short for Tool Kit) provides functions like the *button command we saw
above, while Tcl, short for Tool Command Language and often pronounced
“tickle”, is used to implement programming logic. Some essential elements
of Tcl are covered later in this book, but the important point for us is that
13
Macros are not recursive – a macro cannot call itself!
19
A Primer on Programming Approaches Managing the CAE Process
Tcl can be embedded in macros, thereby making the simple macro almost
infinitely extensible!
Tcl programs, usually called scripts, can also be run from the command
window within HyperMesh. To execute the program in the file sample.tcl,
you would type Source sample.tcl in the command window.
Templex
Earlier in this chapter, we saw that one of the reasons that scripting
languages such as Tcl are easier to use than system-programming
languages like C is because they are less general in scope.
14
Not to be confused with process-templates!
20
Managing the CAE Process A Primer on Programming Approaches
Java
The methods described above are largely limited to the HyperMesh-universe.
CAE users, though, usually have to deal with many more applications. In
most scenarios, at the very minimum the designer also has to work with at
least one CAD system and a document or data-management system which is
usually built around an RDBMS. Further, the Bills-of-Material (BOM) is
commonly used to define the product structure, as shown in the figure
below.
Using the Java API, you can build standalone applications that can access
HyperWorks databases, or applications that run within HyperWorks
applications – you can add commands to the menus or toolbars too. The
online documentation provides details on the Java API in the section titled
Development Using Java.
Batch Meshing
Generation of finite element meshes is one of the most time consuming
tasks in Finite Element Analysis. Not only is the task laborious and repetitive,
the meshes very often have to conform to fairly specific requirements. For
instance, OptiStruct/Analysis requires that the aspect ratio of triangular
elements be less than 500, and recommends that the value be less than 50.
The Batch Mesher is an application that addresses this. Unlike the options
described above, the Batch Mesher is not a new programming interface. It’s
an application in its own right (you start it just as you would start the other
HyperWorks Applications). But since you can use it to automatically import
geometry, cleanup the geometry, mesh, and check element quality, it can
play an important role in process customization.
Like the other customization options described above, the Batch Mesher
allows you to mix and match customization options – you can, for instance,
write Tcl scripts for the Batch Mesher, as described in the online
documentation. In fact, you should look at the files in the batchmesh
directory for an excellent example of how the techniques outlined above can
be used to build applications.
A discussion of the Batch Mesher is well beyond the scope of this book.
22
Managing the CAE Process A Primer on Programming Approaches
Several of the files in this folder have the extension “.tbc”. This means they
are Tcl scripts that have been compiled. While Tcl is normally implemented
as an interpreted language, you can compile Tcl scripts and distribute the
“.tbc” files instead of the “.tcl” files. The main advantage of this is that you
can protect your source code. See http://sourceforge.net/projects/tclpro/ for
details on one such compiler.
Keyboard Shortcuts
You can assign commands to keys using the Preferences menu. For
instance, to run a Tcl script whenever the key “j” is pressed, enter
*evaltclstring scriptname next to the key “j”.
To start HyperMesh, you run hmopengl.exe15. You can add arguments at the
command line when you run HyperMesh. For instance, you could choose to
run
hmopengl filename.hm
Once the command is run, HyperMesh looks for several files. It first looks in
your start-up directory for each file. If it doesn’t find the file, it looks in the
installation directories. The files that are important for us are:
15
You could run hmbatch to start HyperMesh in batch mode.
23
A Primer on Programming Approaches Managing the CAE Process
24
Managing the CAE Process A Primer on Programming Approaches
The fact that the man who gave the world electric light, motion pictures,
talking machines, and the Edison storage battery was responsible for this
utterly useless device should encourage inventors whose first attempts have
failed.
George Lee Dowd Jr
in Popular Science Monthly,1930, on Edison’s unsuccessful Helicopter
25
The Process Manager Managing the CAE Process
About the only thing you cannot do with HWPM is document the workflow in
the first place. It’s a truism that a process that is not documented cannot be
automated, so you must identify the workflow and associated practices
before you get started with HWPM.
16
See CAE and Design Optimization – Advanced
26
Managing the CAE Process MBD Simulation with HyperWorks
What is unarguable is that the design of the process has a critical impact on
its usability. In general, resist the temptation to write an all-encompassing
process that will endure for all time. If you find this hard to do, a quick
review of Shelley’s Ozymandias is strongly recommended!
The iterative approach is a better idea. Allow for the fact that the process
will evolve with usage, and ensure that your design provides for easy and
rapid modification. Also ensure, of course, that you have a well-defined test-
bed that evolves along with the process itself.
The Process Studio is the “authoring” part of HWPM – it’s an IDE (Integrated
Development Environment) for the Process Manager. You use it to create
new processes by building user interfaces and logic, or you can use it to
modify existing processes.
The Process Studio can be run from within the Process Manager, but it’s
most often used independently as a standalone application. Of all the
customization options outlined in the previous Chapter, the ones most often
used with HWPM are the Tcl API and the Java API.
The Process Manager can be used either in batch mode or in the more usual
interactive mode. In the latter case, you would start the Process Manager
from within a HyperWorks application and first select the process you want
to run. Once you choose, it then reads the process-definition and uses a
tree-structure that guides you through the process by
27
The Process Manager Managing the CAE Process
• tracking the status of each step – for instance, your process may
require that some steps be prerequisites for others. In this case, the
Process Manager changes the “availability” of steps based on the
complete / incomplete status of the prerequisite steps. One other
advantage is that it is a lot easier to stop and restart complicated
process – the Process Manager remembers what you were doing
and restores the state of the application.
The easiest way to understand how the Process manager works is to dissect
a sample application.
28
Managing the CAE Process MBD Simulation with HyperWorks
The first step, whenever you run a Process Template, is to choose whether
you want to restart from an earlier stopped-and-saved session or to start
afresh.
If you choose a new session, the Process Tree starts from the first sub-
modeling step. (If you choose to restart a stopped-and-saved process, of
course, the process will resume from wherever it left off the earlier time.)
The tree-display shows how many steps are in the process, and also
indicates the current step by checking its box. Also, the familiar HyperMesh
interface has been replaced with a custom-made interface that tells you
exactly what to do – load a file. There’s even a default selection – door.hm.
29
The Process Manager Managing the CAE Process
If you select this file and click on the Load button, the process immediately
shifts to the next step.
Not only has the user-interface changed to reflect the next step in the
process, the tree has changed too – the green check-mark indicates that the
first step is complete and the second step is the one you’re working on.
By now the approach is pretty clear: the interface is tailored to suit the
specific task, recommended choices are offered to reduce the scope for
error, and you can track how far along the process you’ve gone.
Further, at any step in the process you can save your current state in case
you want to quite now and resume later.
30
Managing the CAE Process MBD Simulation with HyperWorks
Now let’s look at the code itself. To do this, we start the Process Studio and
open the same process template – SubModeling.pmt.
The window now opens the process definition. The Tools / Template
Preferences option defines the name for the process, and other options. The
tab-controls at the bottom of the window let us navigate between the code
and the interface. The Process tab is where you create the tasks that make
up the process-tree, while the Controls tab shows us any Java widgets used
in the application.
Each step in the process-tree has code associated with it. In the figure
above, the step named Import Model is associated with the file named
import_model.tcl. If you want to create a “collapsible” tree, like the
HyperStudy interface, set the Task Type to Folder.
Similarly, the Controls tab shows any Java widgets that the application uses.
Tk controls can be accessed directly from Tcl code, as illustrated by the
code. To complete our dissection, there’s one step left for us to understand
– where the Process Studio expects to find various files.
31
The Process Manager Managing the CAE Process
Let’s look at the modules folder first. You can correlate these with the
process-layout. Each Tcl module is associated with a step in the process-
tree, and the order in which the tree is executed is defined by the layout:
the step named Import Model is associated with the script named
import_model.
Note that each procedure in the file is named in a specific fashion – prefixed
with the string
proc ::hw::pmgr::${::hw::pmgr::namespace}::
This is the namespace that the HWPM engine sets up for the process. Each
Tcl file contains 4 predefined procedures, as well as others that may are
required by the logic. For instance, export_model.tcl and import_model.tcl
contain a callback function named OnBrowseFile( ), which is the function
that’s invoked when the user wants to choose a file or location.
32
Managing the CAE Process MBD Simulation with HyperWorks
Any supporting Tcl scripts you create should be stored in the folder
tclincludes. The folders controls, help and icons, of course, contain the
definitions of any widgets (JAR files, for Java applications), help text (HTML
files) or icons that your application uses.
While this sample application uses Tcl, remember that HWPM allows you to
use Java too – your application’s power is limited only by your imagination!
Most people find the concept of programming obvious, but the doing
impossible.
Alan J. Perlis
33
Advanced Topics Managing the CAE Process
Advanced Topics
Don’t get fooled into thinking this chapter will make an expert out of you,
but do use this chapter to get going on multiple languages. The idea17 that
you should “learn at least a half dozen programming languages” is hard to
dispute, since one of your biggest design problems is to choose the mode of
process-customization.
It’s a good idea to read this chapter after you’ve worked on the assignments
that accompany this book. The only way to learn programming is to roll up
your sleeves and program!
Debugging
Sir Maurice Wilkes18 observed
Unless you know something Sir Maurice didn’t, there’s no getting away from
the fact that you should pay attention to and budget for the finding and
fixing of errors in your program. Errors can be of several forms – logical
errors, unforeseeable circumstances, syntactical errors, and so on.
The best way to get started is by starting small. Don’t write the entire
program and then start testing. Instead, remember that incremental-
development is a good way to go. Look at the functional design of your
application and decide at which points it makes sense to check if what
you’ve done so far is working as designed. (Unit testing is a standard
approach in eXtreme Programming).
17
A suggestion in Peter Norvig’s “Learn Programming in Ten Years”. The complete
article, at http://norvig.com/21-days.html, is strongly recommended reading.
18
Sir Maurice Vincent Wilkes is credited with several important developments in
computing, including the idea of symbolic labels, macros, and subroutine libraries.
34
Managing the CAE Process Advanced Topics
If you find errors after the program’s done, as you inevitably will, use the
divide-and-rule approach. That is, separate the application’s functions into
those that are working and the one that isn’t. Then drill down into the code,
testing bits as you go.
The art, unfortunately, improves mainly with experience, but to sum up, the
steps you should try19 are:
• Reduction: try to isolate the input that’s causing the bug. This
makes it easier to isolate the snippet of code that’s the root of
the problem.
19
Adapted from Terence Parr’s The Essentials of Debugging. See
http://www.cs.usfca.edu/~parrt/doc/debugging.html
35
Advanced Topics Managing the CAE Process
Data Types
All data is stored in memory, whether in RAM or on other storage, in binary
form. Most programming languages, however, allow you to segregate data
into integers, floating point numbers, Boolean values, strings, etc. This
makes it easier for you to manipulate data consistently.
Variables
Strongly typed languages require you to declare the variable before using it.
That is, the variable’s name and its data type are specified before it is used
in the program to hold any data. Subsequent usage must match the rules for
the data type.
Operators
The language has to give you the ability to first store data in variables, then
to manipulate it. Assignment operators like = perform the first job, while
operators like + perform the latter.
Two aspects that often confuse beginners are the concepts of scope and
visibility. When you define a variable in a module, the Operating System sets
36
Managing the CAE Process Advanced Topics
aside some storage for it. What should the Operating System do when the
module is complete? Should it retain it or release it? Some languages allow
you to decide this: variables that never go out of scope are called static
variables, while others are dynamic – they are released whenever the
module is done. If a variable has been released, it has gone out of scope,
which means your program can no longer access it.
Flow Control
Since programs need to take decisions, the programmer needs an ability to
set and test conditions, and proceed accordingly. The most common way to
do this is an if-then-else construct. First the if tests one or more
conditions. Depending on whether the condition is fulfilled or not, control
passes either to the then or to the else.
File I/O, which is the most common device I/O, is easier. The program must
first open the device, then write to it or read from it, and close it when it’s
done. If a program exits or terminates without closing files, the Operating
System will usually close the file, but this is sloppy programming. It’s better
to ensure that all opening-and-closing of files is done explicitly by your code.
37
Advanced Topics Managing the CAE Process
Remember that Tcl has no data types – for Tcl, everything is a string of text.
It’s up to you, therefore, to anticipate what values a variable will hold and
proceed accordingly. This is particularly important if you access the
HyperMesh database from your code. Before we review the commonly used
HyperWorks functions provided by the Tcl API, we’ll look at some commonly
used “intrinsic” commands are listed here. (Use one of the references listed
at the end of this book for an introduction to Tcl itself.)
38
Managing the CAE Process Advanced Topics
39
Advanced Topics Managing the CAE Process
Since Tk is inbuilt into Tcl, you can build widgets by including Tk commands
in your code. You should definitely review how to use the Tk commands
button and message. Commands like menu and menubar are also useful to
build slick interfaces quickly.
when used in a Tcl script. Commands that start with hm are functions that
are provided by the HyperWorks API.
40
Managing the CAE Process Advanced Topics
• hm_completemenuoperation: to clean up
Example: when working with HyperMesh, the graphics
area is cleaned up after the menu is complete. When
using Tcl, you may need to issue this command explicitly.
An Annotated Example
To put all this in proper context, let’s look at a real, working program. This
example is a script to import all IGES files in a given folder into HyperMesh.
The lines in blue are the actual code, while comments are in italics and are
indented for clarity.
# Display a message to the user, who can only
click on “OK”.
tk_messageBox -title "Directions" -message "Pick a
source directory. All IGES files \n in that directory
will be imported." -type ok
# Display a Dialogue Box from which the user can
select the file. Note that the code does not
allow for the user clicking on “cancel”. The
name of the chosen file is stored in the
variable fileSource
set fileSource [tk_chooseDirectory -mustexist true -
title "Find Files In"]
# Define the variable named “format”, which
we’ll use to build the filenames.
set format {#iges\\iges}
43
Advanced Topics Managing the CAE Process
# Create a component collector
with the name that’s given by the
variable compName_surfs, and
assign it a mat collector id = 1,
and set the color to 1.
*collectorcreate components
"$compName\_surfs" "1" 1
# Create a component collector
with the name that’s given by the
variable compName_lines, and
assign it a mat collector id = 2,
and set the color to 1.
*collectorcreate components
"$compName\_lines" "2" 1
# Create a component collector
with the name that’s given by the
variable compName_points, and
assign it a mat collector id = 3,
and set the color to 1.
*collectorcreate components
"$compName\_points" "3" 1
# Run the Iges translator (we
defined the variable named
“format” above). We do not want to
overwrite any existing entities
and use an automatic cleanup
tolerance
*feinput "$format" "$fileName" 0 0 -1 1 0
*clearmark lines 1
*createmark lines 1 "displayed"
*movemark lines 1 "$compName\_lines"
*clearmark points 1
*createmark points 1 "displayed"
*movemark points 1 "$compName\_points"
# Clean up: if there were no
surfaces / lines / points, the
corresponding collector would be
empty.
*EntityDeleteEmpty components 1
}
44
Managing the CAE Process Advanced Topics
}
# Now that the import-and-organization is
over, wind up by setting the color …
*autocolor components
# … and set the display-state of all
component collectors – elements off,
geometry on
*displaycollectorwithfilter components "all" "" 0 1
Java
The APIs provided to the TCL modules is much smaller than the APIs
provided for Java, largely because the Java development-paradigm allows
the development of a wider range of applications than Tcl. Of course, Tcl
applications can use
The Java APIs support Swing (the JFC), and come with a set of libraries and
beans that your application can use. If you’re using a Java IDE (such as
Eclipse), you should add hwmutils.jar, hmsuite.jar, hwmetaphase.jar, and
dbbeans.jar and all the jar files in the lib folder (the path depends on your
installation - C:\Altair\hw8.0sr1\javaapps\WIN32\pmgr\lib for example) to
the set of required libraries.
All the APIs provided by the Process Manager FrameWork are encapsulated
in the interface IHWMFrameWork. To access the framework, beans should
implement a class named com.altair.hwm.interfaces.IHWMControl. If it
does, when the bean is instantiated, the Process Manager passes the
IHWMFrameWork instance to the SetFrameWork method (note that the bean’s
constructor does not have access to the FrameWork). Beans that don’t
implement this class don’t receive the FrameWork handle, but can do their
own work, of course.
45
Advanced Topics Managing the CAE Process
• the Workflow – that is, the set of tasks that make up the process-
tree – using IHWMWorkFlow
All in all, unless you have prior experience with Java or an object-oriented
language like C++, you should look at Tcl as a preferred customization
route.
Finally, remember that the API is for Java, not JavaScript - while Java and
JavaScript share several vocabulary and syntax constructions, the languages
are intended for very different purposes.
XML
HyperWorks uses XML to interface MotionSolve with MotionView, for
instance. XML provides several advantages to the programmer. You probably
will not need to decipher the structure used by HyperWorks, but it’s
interesting anyhow to understand the how and why of XML.
Like other markup languages, XML uses tags liberally. But unlike HTML,
which almost everyone who uses a computer has encountered, XML only
defines the content, not the appearance. This is extremely significant since it
allows for separation between form and data. The developer, therefore, has
tremendous freedom. Unlike HTML, where the tags supported by the
46
Managing the CAE Process Advanced Topics
language are predefined, XML allows you to define your own tags.
Remember that XML files are intended to be read by applications, not by
humans. Since the XML file contains the tags you’ve defined, its easy to
write an application to read the XML file. The XML “code” tells the
application what the data means.
47
Glossary and References Managing the CAE Process
Controls Elements of a GUI (Graphical User Interface) that the user can interact
with to trigger an event that the application will respond to. In
window-based programs, these are often referred to as widgets.
48
Managing the CAE Process Glossary and References
Instance Most computers can run multiple applications – this means the same
application may well be invoked several times. For example, you can
start HyperMesh more than once on the same computer – you will
then be running several “sessions” or “instances” of HyperMesh.
JAR A JAR file is a Java Archive that’s a container for other Java
components. It’s a platform-independent file format that combines
many files – such as Java applets and their components - into one. It’s
a convenient way of packaging together class files, associated images,
and other data files. A JAR file can be decompiled.
SOAP Short for either Simple Object Access Protocol or Service Oriented
Architecture Protocol, is a method for applications to exchange
messages across networks – a client sends a request to a server,
which replies. Reliant on XML, SOAP is one of several middleware
products. CORBA is another commonly used method to achieve the
same function.
Swing A Java Foundation class designed for GUIs. Controls derived from
Swing are platform-independent and inherit their look-and-feel from
the Operating System.
References
http://java.sun.com/reference/faqs/index.html
Tutorials, FAQs, Documentation, References and more.
www.kpdus.com/jad.html
Java decompiler – useful if you want to examine Java files (jars)
http://sourceforge.net/projects/jadclipse
A decompiler plug-in for Eclipse
http://www.eclipse.org
An Integrated Development Environment (IDE) for Java.
http://wiki.tcl.tk/
All you could ever want to know about TCL.
50
Managing the CAE Process Glossary and References
Other Resources
www.altair-india.com/edu, which is periodically updated, contains case
studies of actual usage. It also carries tips on software usage.
• Page indicates which menu page the button will appear on. The
value must be between 1 and 5
• Name is the text displayed on the button
• Row determines which row the button is placed on. Rows start from
0 at the bottom of the screen. The maximum value depends on the
resolution of your display
• Column determines which row the button is placed on. The value
must be between 1 and 10
• Width must be less than 10
• Color can be any of RED, BLUE, GREEN, CYAN, MAGENTA and
BUTTON. The color must be entered in upper-case
• Help is the text displayed on the menu bar when the button is
selected
• Macro is the name of the macro (defined by
*beginmacro(macroname) ) that’s called when the button is clicked.
• Arg1, arg2 etc. are optional – if present, they are passed on to the
macro as arguments.
A template is a text file that defines the form of the output or input file using
a series of commands. HyperMesh uses the template to determine how to
read from or write to the output or input file. Text processing consists of 5
blocks:
BEGIN CODE
1 8 16 24 32 40
NODE DATA
NODE 1 0.0 0.0 0.0
NODE 2 8.0 0.0 0.0
.
.
NODE id x y z
END NODES
END CODE
BEGIN CODE
*nodes( )
*before( )
*string("NODE DATA")
*end( )
*format( )
*string("NODE ")
*field(integer, id, 8)
*field(real, x, 8)
*field(real, y, 8)
*field(real, z, 8)
*string("*)
*end( )
*after()
*string("END NODES")
*end( )
*output( )
The words preceded with asterisks are Template commands, and the
variables within the brackets (id, x, etc.) are data names. The complete set
of commands and names is listed in the online documentation.
52
Managing the CAE Process Glossary and References
The interpreter reads the contents of the square brackets as a formula and
evaluates it accordingly. Operators can implement pretty complicated logic.
Not only do they include commands such as test-for-equality (==, !=, <, >,
<=, >= ) and logical expressions ( &&, || ), you can also use conditions such
*if and *loopif as to determine execution-branches.
Formulae can also be constructed from Template Functions, which allow you
to query the data in the database. For instance, you can use @count( ) to
count the number of nodes in the database. Template functions are
preceded by the symbol @ and must be enclosed in square brackets. A
complete list is in the on line documentation. Some useful functions are:
• y
@pow( ) and @exp( ) for x and e
x
• @sqrt( )and @fabs( ) and for the square-root and absolute value
53