2.4 ACT插件
ACT 是Application Customization Toolkit的缩写。WB从14.5版本之后即有此插件功能,插件为用户提供了一些工具,可以很方便地解决在WB界面里需要插入Command或繁琐操作才能处理的问题。下面的ACT实例以WB 15.0为例。
如图2-4-1所示,调用某个ACT插件时,需要在插件前面的Loaded处打勾。
(1)以FEInfo ACT插件为例,进入分析界面可以看到新增一工具条,如图2-4-2所示的方框。
首先使用WB默认的一些有关有限元模型的操作。点击View→Annotation Preferences,如图2-4-3设置,即可看到整个模型的节点编号。如图2-4-4依次点击,可以看到单个节点的详细信息(包括节点相对于坐标系的位置及节点编号)。
再使用ACT功能。如图2-4-5依次点击,其中2~6步需要按住Ctrl键,可以看到点选的节点坐标位置和节点编号;如图2-4-6点击,可以看到与点选节点相邻的单元位置和编号。类似操作,在相应菜单位置可以用编号(格式:编号,编号-编号)、坐标位置、txt文档(内容:编号,编号,……例如:1,2,3,20)查找节点和单元;同时可以测量两节点或单元的距离,这对收敛计算的估计非常有帮助。
注意
插入的txt文档必须采用英文目录,同时文档中编号之间的逗号必须为英文字符。
(2)以WindLoad_APDL ACT插件为例。建立一圆台模型,进入分析界面可以看到新增一工具条,如图2-4-7所示的方框。根据建筑结构载荷规范,结构件依照不同的高度,风载荷会发生变化,计算的效果以风载的水平剪切作用为目的。
建立一坐标系,坐标系的原点为风载加载的起点,X方向为风载方向,Z方向为风载高度方向,如图2-4-8所示。
https://yqfile.alicdn.com/670e53abc415d18702e1c6207b8b843e113d8f6a.png" >
载荷加载如图2-4-9所示,依据风载计算公式{{F}_{d}}=frac{1}{2}rho {{v}^{2}}A{{C}_{d}}(式中,{{F}_{d}}为风载荷,rho为空气密度,v为风速,A为风载载荷面积,{{C}_{d}}为牵引系数)可知,风载与空气密度有关。因此,一定要设置环境温度,因为不同温度对应的空气密度不同。
https://yqfile.alicdn.com/518067a704999984fbf65b10211739dff7501b4e.png" >
WindLoad_APDL设置如图2-4-10所示。图中1为风载加载面,2为图2-4-8新建的坐标系,3可选择定值或梯度风载,4选择风载方向和高度,5定义风速,6定义空气密度,7定义形状因子。
https://yqfile.alicdn.com/721d3eb18d9e39841be467ef5ffb33749244ae14.png" >
计算结果如图2-4-11所示。
ACT作为插件不仅扩展了WB的内部功能,同时还作为接口与WB建立关联,例如,TCSCA、EDEM、PDF等软件都开发了与WB的相应ACT接口程序。
(3)C程序。用于将FE模型转换成stl文件。(注:ANSYS17.0已经可以直接用右键导出,之前版本只能用组件系统下的Finite Element Modeler模块进行处理。)
主程序:
/*
---------------------------------------------------------------------------
Simple program that takes the nodes and elements from the surface of an
ANSYS FE model and converts it to a binary STL file.
USAGE:
Create and ANSYS surface mesh one of two ways:
1: amesh the surface with triangles
2: esurf an existing mesh with triangles
Write the triangle surface mesh out with nwrite/ewrite
Run ans2stl with the rootname of the *.node and *.elem files as the only argument
This should create a binary STL file
COMPILE:
gcc -o ans2stl_win ans2stl_win.c
---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct vertStruct *vert;
typedef struct facetStruct *facets;
typedef struct facetListStruct *facetList;
int ie[8][999999];
float coord[3][999999];
int np[999999];
struct vertStruct {
float x,y,z;
float nx,ny,nz;
int ivrt;
facetList firstFacet;
};
struct facetListStruct {
facets facet;
facetList next;
};
struct facetStruct {
float xn,yn,zn;
vert v1,v2,v3;
};
facets theFacets;
vert theVerts;
char stlInpFile[80];
float xmin,xmax,ymin,ymax,zmin,zmax;
float ftrAngle;
int nf,nv;
void swapit();
void readBin();
void getnorm();
long readnodes();
long readelems();
/*--------------------------------*/
main(argc,argv)
int argc;
char *argv[];
{
char nfname[255];
char efname[255];
char sfname[255];
char s4[4];
FILE *sfile;
int nnode,nelem,i,i1,i2,i3;
float xn,yn,zn;
if(argc <= 1){
puts("Usage: ans2stl file_root");
exit(1);
}
sprintf(nfname,"%s.node",argv[1]);
sprintf(efname,"%s.elem",argv[1]);
sprintf(sfname,"%s.stl",argv[1]);
nnode = readnodes(nfname);
nelem = readelems(efname);
nf = nelem;
sfile = fopen(sfname,"wb");
fwrite("PADT STL File, Solid Binary",80,1,sfile);
swapit(&nelem,s4); fwrite(s4,4,1,sfile);
for(i=0;i<nelem;i++){
i1 = np[ie[0][i]];
i2 = np[ie[1][i]];
i3 = np[ie[2][i]];
getnorm(&xn,&yn,&zn,i1,i2,i3);
swapit(&xn,s4); fwrite(s4,4,1,sfile);
swapit(&yn,s4); fwrite(s4,4,1,sfile);
swapit(&zn,s4); fwrite(s4,4,1,sfile);
swapit(&coord[0][i1],s4); fwrite(s4,4,1,sfile);
swapit(&coord[1][i1],s4); fwrite(s4,4,1,sfile);
swapit(&coord[2][i1],s4); fwrite(s4,4,1,sfile);
swapit(&coord[0][i2],s4); fwrite(s4,4,1,sfile);
swapit(&coord[1][i2],s4); fwrite(s4,4,1,sfile);
swapit(&coord[2][i2],s4); fwrite(s4,4,1,sfile);
swapit(&coord[0][i3],s4); fwrite(s4,4,1,sfile);
swapit(&coord[1][i3],s4); fwrite(s4,4,1,sfile);
swapit(&coord[2][i3],s4); fwrite(s4,4,1,sfile);
fwrite(s4,2,1,sfile);
}
fclose(sfile);
puts(" ");
printf(" STL Data Written to %s.stl \n",argv[1]);
puts(" Done!!!!!!!!!");
exit(0);
}
void getnorm(xn,yn,zn,i1,i2,i3)
float *xn,*yn,*zn;
int i1,i2,i3;
{
float v1[3],v2[3];
int i;
for(i=0;i<3;i++){
v1[i] = coord[i][i3] - coord[i][i2];
v2[i] = coord[i][i1] - coord[i][i2];
}
*xn = (v1[1]*v2[2]) - (v1[2]*v2[1]);
*yn = (v1[2]*v2[0]) - (v1[0]*v2[2]);
*zn = (v1[0]*v2[1]) - (v1[1]*v2[0]);
}
long readelems(fname)
char *fname;
{
long num,i;
FILE *nfile;
char string[256],s1[7];
num = 0;
nfile = fopen(fname,"r");
if(!nfile){
puts(" error on element file open, bye!");
exit(1);
}
while(fgets(string,86,nfile)){
for(i=0;i<8;i++){
strncpy(s1,&string[6*i],6);
s1[6] = '\0';
sscanf(s1,"%d",&ie[i][num]);
}
num++;
}
printf("Number of element read: %d\n",num);
return(num);
}
long readnodes(fname)
char *fname;
{
FILE *nfile;
long num,typeflag,nval,ifoo;
char string[256];
num = 0;
nfile = fopen(fname,"r");
if(!nfile){
puts(" error on node file open, bye!");
exit(1);
}
while(fgets(string,100,nfile)){
sscanf(string,"%d ",&nval);
switch(nval){
case(-888):
typeflag = 1;
break;
case(-999):
typeflag = 0;
break;
default:
np[nval] = num;
if(typeflag){
sscanf(string,"%d %g %g %g",
&ifoo,&coord[0][num],&coord[1][num],&coord[2][num]);
}else{
sscanf(string,"%d %g %g %g",
&ifoo,&coord[0][num],&coord[1][num],&coord[2][num]);
fgets(string,81,nfile);
}
num++;
break;
}
}
printf("Number of nodes read %d\n",num);
return(num);
}
/* A Little ditty to swap the byte order, STL files are for DOS */
void swapit(s1,s2)
char s1[4],s2[4];
{
s2[0] = s1[0];
s2[1] = s1[1];
s2[2] = s1[2];
s2[3] = s1[3];
}
测试实例:
/ *======================================================
SAMPLE ANSYS INPUT DECK THAT SHOWS USAGE
finish
/clear
/file,a2stest
/PREP7
!----------
! Build silly geometry
BLC4,-0.6,0.35,1,-0.75,0.55
SPH4,-0.8,-0.4,0.45
CON4,-0.15,-0.55,0.05,0.35,0.55
VADD,all
!------------------------
! Mesh surface with non-solved (MESH200) triangles
et,1,200,4
MSHAPE,1,2D ! Use triangles for Areas
MSHKEY,0 ! Free mesh
SMRTSIZE,,,,,5
AMESH,all
!----------------------
! Write out nodes and elements
nwrite,a2stest,node
ewrite,a2stest,elem
!--------------------
! Execute the ans2stl program
/sys,ans2stl_win.exe a2stest
======================================================= */