Week - 8 - Creating component and property
-
set a [hm_getstring "components =" "Enter the name of the component"]: This line prompts the user to enter the name of a component and stores the input in the variableausing thehm_getstringfunction. The prompt message is "Please Enter the name of component =". -
set b [hm_getstring "Thickness =" "Enter the value of thickness"]: This line prompts the user to enter the thickness value and stores the input in the variablebusing thehm_getstringfunction. The prompt message is "Thickness =". -
set sol [hm_getsolver id]: This line retrieves the solver ID using thehm_getsolverfunction and stores it in the variablesol. -
if {$sol==1} {: This line starts an if statement, checking if the solver ID is equal to 1. -
proc optistruct {n t} {: This line defines a procedure named "optistruct" with two argumentsnandt. -
*createentity comps includeid=0 name=$n$t: This command creates a component entity with the name formed by concatenating the values ofnandt. -
*createmark comps 1 $n$t: This command creates a mark set 1 containing the components with the name formed by concatenating the values ofnandt. -
set compsid [hm_getmark comps 1]: This line retrieves the component ID from the mark set created in the previous line and stores it in the variablecompsid. -
*createentity props cardimage=PSHELL includeid=0 name=$n$t: This command creates a property entity of type "PSHELL" with the name formed by concatenating the values ofnandt. -
*createmark props 1 $n$t: This command creates a mark set 1 containing the properties with the name formed by concatenating the values ofnandt. -
set propsid [hm_getmark props 1]: This line retrieves the property ID from the mark set created in the previous line and stores it in the variablepropsid. -
*setvalue props id=$propsid STATUS=1 95=$t: This command sets the value of the "STATUS" and "95" attributes of the property entity identified bypropsid. -
*setvalue comp id=$compsid propertyid={props $propsid}: This command associates the component identified bycompsidwith the property identified bypropsid. -
puts [optistruct $a $b]: This line calls the "optistruct" procedure with the values ofaandbas arguments, and the result is printed. -
}: This line marks the end of the if statement. -
if {$sol==20} {: This line starts another if statement, checking if the solver ID is equal to 20. -
proc radioss {n t} {: This line defines a procedure named "radioss" with two argumentsnandt. -
*createentity comps includeid=0 name=$n$t: This command creates a component entity with the name formed by concatenating the values ofnandt. -
*createmark comps 1 $n$t: This command creates a mark set 1 containing the components with the name formed by concatenating the values ofnandt. -
set compsid [hm_getmark comps 1]: This line retrieves the component ID from the mark set created in the previous line and stores it in the variablecompsid. -
*createentity props cardimage=P1_SHELL includeid=0 name=$n$t: This command creates a property entity of type "P1_SHELL" with the name formed by concatenating the values ofnandt. -
*createmark props 1 $n$t: This command creates a mark set 1 containing the properties with the name formed by concatenating the values ofnandt. -
set propsid [hm_getmark props 1]: This line retrieves the property ID from the mark set created in the previous line and stores it in the variablepropsid. -
*setvalue props id=$propsid STATUS=1 431=$t: This command sets the value of the "STATUS" and "431" attributes of the property entity identified bypropsid. -
*setvalue comp id=$compsid propertyid={props $propsid}: This command associates the component identified bycompsidwith the property identified bypropsid. -
puts [radioss $a $b]: This line calls the "radioss" procedure with the values ofaandbas arguments, and the result is printed. -
}: This line marks the end of the if statement.
These lines of code handle user input, execute different procedures based on the solver ID, create entities (components and properties), associate components with properties, and print the results. The specific procedures "optistruct" and "radioss" perform different operations depending on the solver ID and the provided arguments.
This optistruct procedure creates a component and property in HyperMesh for optiStruct solver. Let's break down each line and explain its purpose:
*createentity comps includeid=0 name=$n$t
This line creates a component entity in HyperMesh with the name formed by concatenating n and t variables. The name=$n$t argument assigns the generated name to the component.
*createmark comps 1 $n$t
set compsid [hm_getmark comps 1]
These two lines create a mark on the previously created component entity and retrieve the mark ID using hm_getmark. The mark ID is stored in the compsid variable and will be used later to reference the component.
*createentity props cardimage=PSHELL includeid=0 name=$n$t
*createmark props 1 $n$t
set propsid [hm_getmark props 1]
These lines create a property entity of type PSHELL (a thin shell property) in HyperMesh. Similar to the component creation, it assigns a name formed by concatenating n and t to the property. A mark is placed on the created property entity, and the mark ID is retrieved and stored in the propsid variable.
*setvalue props id=$propsid STATUS=1 95=$t
This line sets the value of the STATUS attribute of the property to 1, indicating that the property is active. Additionally, it sets the value of attribute 95 (which represents the thickness) to the value stored in the variable t.
*setvalue comp id=$compsid propertyid={props $propsid}
This line associates the component with the property by setting the propertyid attribute of the component to the ID of the created property entity. The component ID is specified using the compsid variable, and the property ID is specified as {props $propsid} to reference the created property.
Overall, this optistruct procedure creates a component and a PSHELL property in HyperMesh, assigns the provided thickness value to the property, and associates the component with the property. This allows you to define the necessary properties for optiStruct analysis in HyperMesh.