77范文网 - 专业文章范例文档资料分享平台

Patran的PCL用户手册 - 图文(8)

来源:网络收集 时间:2019-03-10 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

PCL Variables and Constants

Datatypes

?

LOGICAL Boolean value: TRUE or FALSE

LOGICAL done, created

INTEGER Value between +/- (231-1)

INTEGER i, num_nodes, node_id

REAL Single precision floating value between 1.0E-30 and 1.0E+30 (positive or negative)

REAL x, y, z, force, pressure

STRING Character string surrounded by double quotes, “Have you seen Elvis?”. Size or string length is defined with brackets, [ ]

STRING FileName[80], GroupName[32]

WIDGET Value is assigned by calls to

UI_WIDGET_NAME_CREATE(…), used to create and manipulate forms, etc.

WIDGET main_form, MyButton, group_lbox

?

?

?

?

MSC.Patran PCL Workshop Notes 04/13/16 36/236

PCL Variables and Constants

Variable Scope

?

GLOBAL LOCAL STATIC CLASSWIDE

Available to all functions during the MSC.Patran session

Default, only visible within the defining function Same as LOCAL, but retains its value between calls

Available to all functions in the CLASS and

retains its value during the MSC.Patran session

? ?

?

GLOBAL REAL a, b, c FUNCTION FindElvis() GLOBAL REAL b STATIC INTEGER c FUNCTION WheresWaldo(x) GLOBAL REAL a REAL c, d, e INTEGER x CLASS training CLASSWIDE REAL d, e FUNCTION MyFunc(q, r) INTEGER f GLOBAL REAL a, b, c REAL q, r FUNCTION init() INTEGER c, f, g Note that variables passed as arguments must be declared If you are going to change the value of a global variable within a function, you must declare the global variable within your function.

MSC.Patran PCL Workshop Notes 04/13/16 37/236

PCL Variables and Constants

Directly Allocated Arrays

?

Directly allocated arrays can have any number of subscripts (dimensions), defined within parentheses ()

Assigned upper and lower bounds, ArrayName(Lower:Upper)

INTEGER MyArray(2:10)

?

? ? ?

Default lower bound is 1 (not 0) Available for all datatypes

Row major (unlike Fortran which is column major)

INTEGER MyArray(2, 3) = 1, 2, 3, 4, 5, 6

1 2 3 4 5 6 ?

Array dimensions are inherited from the argument list, i.e., PCL passes by reference

FUNCTION MyFunc() STRING MyString[32](32) YourFunc(MyString) END FUNCTION

?

FUNCTION YourFunc(MyVal) STRING MyVal[]() END FUNCTION Declaration Examples

REAL displacements(6, 200) STRING group_names[32](20) INTEGER ids(0:2, 0:4, 0:10) LOGICAL exists(12)

MSC.Patran PCL Workshop Notes 04/13/16 38/236

PCL Variables and Constants

Virtual arrays

?

Any variable can be defined as a VIRTUAL array instead of a directly allocated array. Virtual arrays do not have storage locations assigned to them at program initialization. The size and amount of storage is allocated as requested and can be reused for other virtual arrays.

To declare a virtual array, use the keyword VIRTUAL in place of the subscripts for the declaration, i.e.,

REAL MyVals(VIRTUAL) INTEGER NodeIds(VIRTUAL)

?

?

Storage is allocated using the function, sys_allocate_array(), or

sys_allocate_array(MyVals, 1, 300)

sys_allocate_array(MyVals, 1, 300, 1, 3)

sys_allocate_array(MyVals, 1, 300, 1, 3, 0, 5) etc.

?

Storage may be reallocated using the function, sys_reallocate_array(),

sys_reallocate_array(MyVals, 1, 300, 1, 3)

?

Storage may be freed using the function, sys_free_array(),

sys_free_array(MyVals)

MSC.Patran PCL Workshop Notes 04/13/16 39/236

PCL Variables and Constants

Virtual array example

FUNCTION CompareNodes(num_nodes, node_ids) INTEGER i, j, status INTEGER num_nodes, node_ids() INTEGER num_db_nodes, db_node_ids(VIRTUAL) LOGICAL found_node $ Determine the total number of nodes in the database status = db_count_nodes(num_db_nodes) IF (status != 0) THEN RETURN status /* If no nodes in the db, then don’t compare */ IF (num_db_nodes == 0) THEN RETURN –1 $ Allocate array to hold the Ids of all nodes in the db status = sys_allocate_array(db_node_ids, 1, num_db_nodes) IF (status != 0) THEN RETURN status $ Get all of the nodes in the db status = db_get_node_ids(num_db_nodes, db_node_ids) IF (status != 0) THEN RETURN status $ Compare node_ids() to node Ids in the database, db_node_ids() $ Note: This is an inefficient way to compare nodes FOR (i = 1 to num_nodes) found_node = FALSE FOR (j = 1 to num_db_nodes) IF (node_ids(i) == db_node_ids(j)) THEN found_node = TRUE BREAK END IF END FOR IF (!found_node) THEN ui_write(“Node “//str_from_integer(node_ids(i))//” not found!”) END IF END FOR RETURN 0 END FUNCTION /* CompareNodes */

MSC.Patran PCL Workshop Notes 04/13/16 40/236

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Patran的PCL用户手册 - 图文(8)在线全文阅读。

Patran的PCL用户手册 - 图文(8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/513782.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: