innovation intelligence ® 1 chapter 6: interfacing with hypermesh solver templates

15
Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Upload: barnaby-rodgers

Post on 22-Dec-2015

247 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Innovation Intelligence®

1

Chapter 6: Interfacing with

HyperMesh Solver Templates

Page 2: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

22

Interfacing with HyperMesh Solver Templates- Overview

Topics Presented:

• Solver Attributes and Card Images• Querying Solver Attributes• Example: Automate Extracting Data in a Card Image• Assigning data to solver attributes• Creating a reusable and modular procedure• Example: Automate Extracting Data in a Card Image• Updating solver attributes• Example: Automate Defining/Updating Multiple Materials

Page 3: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

33

Solver feoutput Templates

• What are Solver Templates?• Solver templates define every solver specific attribute including data names,

attribute IDs, card image formats, and the format of the data upon export.• Templates exist for each solver supported by HyperMesh and are located in

subfolders under the <altair_home>/templates/feoutput directory. • The *defineattribute command is used to define attribute data names and

IDs in a template file.

• Types of Attributes defined in Solver Templates • There are several different types of attributes including array, double, entity,

integer and string.  • The difference is that each entity type uses an appropriate *attributeupdate

command based on its type.  • There are also a number of hm_attribute commands to query entity attributes.

Page 4: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

44

Solver Attributes and Card Images

• A sample card image for an OptiStruct MAT1 material collector is shown below:

• For each field in the above card image there is, a corresponding attribute and data name in one the optistruct templates located in:

<altair_home>/templates/feoutput/common_nas_os/attribs  

• An excerpt is shown below for several of the card image fields:*defineattribute(E,1,real,none)*defineattribute(G,2,real,none)*defineattribute(Nu,3,real,none)*defineattribute(Rho,4,real,none)

Page 5: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

55

Solver Attributes and Card Images

• Additionally, there are card image definitions that define how the card editor is generated inside of HyperMesh for each attribute.  

• For optistruct, these card images are defined in: <altair_home>/templates/feoutput/optistruct

• An excerpt of the optistruct MAT1 card image is shown below:*menustring("MAT1    ")*menufield(ID,integer,id,8)  *menufield(E,real,$E,8)  *menudefaultvalue("        ")  *menuinitialvalue(210000.0)  *menurestrictedvalue(>,0.0)

• The *menufield determines how a field is created in the card editor for a particular attribute.

• For example, the attribute and card image definitions for the Young’s Modulus for the MAT1 material are:

*defineattribute(E,1,real,none)*menufield(E,real,$E,8)

Knowing all of this information allows us to assign, update and query the data.

Page 6: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

66

Querying Solver Attributes

• Solver data names are accessed using hm_getentityvalue, hm_attributearrayvalue and hm_attributearray2dvalue

• These commands use a data_name_string to access a particular piece of data.  

• Each attribute has both an ID and a data name.  For example, from the MAT1 material card we have several attributes of interest:

*defineattribute(E,1,real,none)*defineattribute(G,2,real,none)*defineattribute(Nu,3,real,none)*defineattribute(Rho,4,real,none)

• The first argument is the solver data name and the second is the attribute ID.  

• So in order to extract the value of E from a material with ID 11:

hm_getentityvalue mats 11 "\$E" 0

 

Page 7: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

77

Example: Automate Extracting Data in a Card Image

• An OptiStruct MAT1 material of id 1 exists in the HyperMesh database. Extract from its card image its values for the parameters Young’s Modulus (E), Shear Modulus (G), Poisson’s ratio (Nu), and density (Rho).

• Display the values for the parameters.

• The following HyperMesh Tcl commands are used in this exercise

hm_getentityvalue

• The following core Tcl commands are used in this exercise

set return\proctk_messageBox

Page 8: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

88

Assigning data to solver attributes

• When the MAT1 material collector shown before was initially created, the relevant commands to assign values to its attributes were written to the command.cmf file:

*collectorcreate(materials,"steel","",11)*createmark(materials,2) "steel"*dictionaryload(materials,2,"C:/Altair/hw10.0/templates/

feoutput/optistruct/optistruct","MAT1")*attributeupdateint(materials,1,3240,1,2,0,1)*attributeupdatedouble(materials,1,1,1,1,0,210000)*attributeupdatedouble(materials,1,2,1,0,0,0)*attributeupdatedouble(materials,1,3,1,1,0,0.3)*attributeupdatedouble(materials,1,4,1,1,0,7.85e-009)*attributeupdatedouble(materials,1,5,1,0,0,0)*attributeupdatedouble(materials,1,6,1,0,0,0)*attributeupdatedouble(materials,1,7,1,0,0,0)*attributeupdatedouble(materials,1,341,1,0,0,0)*attributeupdatedouble(materials,1,343,1,0,0,0)*attributeupdatedouble(materials,1,345,1,0,0,0)*attributeupdateint(materials,1,5237,1,2,0,0)   

Page 9: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

99

Assigning data to solver attributes

• Looking at one of the commands above we have:

*attributeupdatedouble(materials,1,1,1,1,0,210000)

Where:

materials is the type of entity that owns the attribute

1 is the ID of the entity

1 is the identifier of the attribute

1 is the solver number of the attribute

1 is the status of the attribute

0 is the behavior of the attribute

210000 is the value of the attribute 

• Looking at the optistruct attribs template, attribute 1 corresponds to the data name E, or Young’s Modulus.

Page 10: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1010

Creating a reusable and modular procedure

• Create a Tcl procedure that allows us to substitute variables for the name, color and data values.  

• We can make the template file path modular across different platforms. • Also we can make the material ID a variable that references the newly created

material ID, so that the *attributeupdatedouble and *attributeupdateint commands work properly.

• The advantage of doing this is:• Only need to pass the material name, color and the values for the material

properties and the procedure will create the material accordingly. • The variables are then used in the later commands to pass the appropriate

arguments.• This procedure also checks to see if a material with that name already exists, and if

it does, a message is returned in the HyperMesh message bar.• The hm_info command is used to find the appropriate template to load.

Page 11: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1111

Creating a reusable and modular procedure

proc mat_create { name color E Nu Rho } {  if {[hm_entityinfo exist mats $name -byname] == 1} {     hm_errormessage "Material $name already exists"     return;  } else {    *collectorcreate materials "$name" "" $color;     *createmark materials 2 "$name";     #Retrieve material ID for use below;     set mat_id [hm_getmark mats 2];

*dictionaryload materials 2 "[hm_info exporttemplate]“"MAT1";     *attributeupdateint materials $mat_id 3240 1 2 0 1;     *attributeupdatedouble materials $mat_id 1 1 1 0 $E;     *attributeupdatedouble materials $mat_id 3 1 1 0 $Nu;     *attributeupdatedouble materials $mat_id 4 1 1 0 $Rho;     return;  }}

Page 12: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1212

Example: Automate Defining a Card Image with Data

• Create an OptiStruct MAT1 material with the following parameter values. Assume the OptiStruct template is already loaded.

• Young’s Modulus (E)

• Shear Modulus (G)

• Poisson’s ratio (Nu)

• density (Rho)

• Upon automating the task, wrap the code into a Tcl procedure.

• The following HyperMesh commands are added and modified in this exercise:

*dictionaryload() *attributeupdateint()

*attributeupdatedouble()

• The following HyperMesh Tcl commands are used in this exercise:

hm_mark hm_info

• ·The following core Tcl commands are used in this exercise:

set proc

Page 13: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1313

Updating solver attributes

• It is also possible to update an existing card image.  • A procedure to do this is almost identical to the procedure to create a new card

image, except that the material is not created and thus the procedure requires a material ID to be passed instead of a material name.

 

proc mat_update { mat_id E Nu Rho } {  if {[hm_entityinfo exist mats $mat_id -byid] == 0} {      hm_errormessage "Material $mat_id does not exist"      return;  } else {      *createmark materials 2 "by id" "$mat_id";      *dictionaryload materials 2 "[hm_info exporttemplate]" \          "MAT1";      *attributeupdatedouble materials $mat_id 1 1 1 0 $E;      *attributeupdatedouble materials $mat_id 3 1 1 0 $Nu;      *attributeupdatedouble materials $mat_id 4 1 1 0 $Rho;      return;  }}

Page 14: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1414

Example: Automate Defining/Updating Multiple Materials

NAME E G NU RHO

aluminum 10 20 0.3 40

altairium 1000 200 0.3 400

steel 2.00E+06 1.00E+06 0.3 7.80E-09

• This task is an extension to the previous example 6.2.

• Automate defining three OptiStruct MAT1 materials with values for the parameters Young’s Modulus (E), Shear Modulus (G), Poisson’s ratio (Nu), and density (Rho). If the materials exist in HyperMesh, simply update the values, otherwise create the material before setting the parameters. The three materials are:

Page 15: Innovation Intelligence ® 1 Chapter 6: Interfacing with HyperMesh Solver Templates

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1515

Practical Exercises

Exercise 6aDescription:

Generate a procedure to create a property collector with a PSHELL card image in the OptiStruct template. Ask the user to supply a thickness value. Try to incorporate checks into the procedure to avoid errors. For example, if a property with that name already exists, what happens?

HyperMesh commands usedhm_errormessage *createmark*collectorcreateonly *dictionaryload*attributeupdatedouble hm_getmarkhm_getfloat

TCL/TK commands usedsetif

HintsDo the steps in HyperMesh and then extract the commands from the command.cmf file.