新浪博客

【分享】flac3d3.0显示单元体塑形区fish语言代码

2017-06-10 09:08阅读:
fish Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131


;//////////////////////show_allkind_plasticzone.txt///////////////////////////////
;/目的:按单元体不同破坏种类显示在不同窗口中并计算破坏体积和数目 /
;/方法:先rest *.sav然后call本文档,之后选择菜单栏 Window->Tile /
;/条件:适用于FLAC3D3.0 /
;/作者:zhubinglong 2016.04.27
;/////////////////////////////////////////////////////////////////////////////////
def get_plast ;定义函数get_plast
shearnow = 1 ;shearnow、tensionnow
tensionnow = 2 ;shearpast、tensionpast
shearpast = 4 ;的state value分别为1、2、4、8
tensionpast = 8 ;具体内容参见fish reference 2.5.3.3
v_shear_now = 0 ;需求的shearnow、tensionnow
v_tension_now = 0 ;shearpast、tensionpast的体积,初始值为0
v_shear_past = 0
v_tension_past = 0 ;flac默认的值
v_yield = 0
_sum_znum_shearnow=0 ;用来记录处于shearnow的单元体个数
_sum_znum_tensionnow=0
_sum_znum_shearpast=0
_sum_znum_tensionpast=0
_sum_znum_yield=0
;xx=z_state(find_zone(11779),0) ;通过本步可验证
p_z = zone_head ;单元指针
loop while p_z # null ;开始循环,如果单元指针不为空,执行以下操作
if and(z_state(p_z,0),shearnow) = shearnow then ;判断语句,判断单元如果是shearnow状态
v_shear_now = v_shear_now + z_volume(p_z) ;则把该单元的体积加进v_shear_now
z_group(p_z)='my_shearnow_';
_sum_znum_shearnow=_sum_znum_shearnow+1;
endif
if and(z_state(p_z,0),tensionnow) = tensionnow then ;同上判断语句,判断单元是否为tensionnow状态
v_tension_now = v_tension_now + z_volume(p_z)
z_group(p_z)='my_tensionnow_';
_sum_znum_tensionnow=_sum_znum_tensionnow+1
endif
if and(z_state(p_z,0),shearpast) = shearpast then ;同上,判断单元是否shearpast
v_shear_past = v_shear_past + z_volume(p_z)
z_group(p_z)='my_shearpast_';
_sum_znum_shearpast=_sum_znum_shearpast+1
endif
if and(z_state(p_z,0),tensionpast) = tensionpast then
v_tension_past = v_tension_past + z_volume(p_z)
z_group(p_z)='my_tensionpast_';
_sum_znum_tensionpast=_sum_znum_tensionpast+1
endif
if and(z_state(p_z,0),shearnow) # shearnow then
if and(z_state(p_z,0),tensionnow) # tensionnow then
if and(z_state(p_z,0),shearpast) # shearpast then
if and(z_state(p_z,0),tensionpast) # tensionpast then
z_group(p_z)='other';
endif
endif
endif
endif
p_z = z_next(p_z) ;单元指针指向下一个单元
endloop
if _sum_znum_shearnow#0
command
;title
;显示模型中当前剪切破坏单元体
plot creat my_shearnow
plot add surf red range group my_shearnow_
plot add sk range group other
plot show my_shearnow
endcommand
endif
if _sum_znum_tensionnow#0
command
;title
;显示模型中当前拉帐破坏单元体
plot creat my_tensionnow
plot add surf red range group my_tensionnow_
plot add sk range group other
plot show my_tensionnow
endcommand
endif
if _sum_znum_shearpast#0
command
;title
;显示模型中过去剪切破坏单元体
plot creat my_shearpast
plot add surf red range group my_shearpast_
plot add sk range group other
plot show my_shearpast
endcommand
endif
if _sum_znum_tensionpast#0
command
;title
;显示模型中过去拉张破坏单元体
plot creat my_tensionpast
plot add surf red range group my_tensionpast_
plot add sk range group other
plot show my_tensionpast
endcommand
endif
end
get_plast ;执行函数
;;;运行fish后,执行pri fish就可以显示shearnow(当前剪切破坏),tensionnow(当前拉帐破坏)
;;;shearpast(过去剪切破坏),tensionpast(过去拉帐破坏)的体积值
def plasticrange
p_z=zone_head
loop while p_z # null
if z_state(p_z,0) # 0
;z_group(p_z)='my_yield_';
v_yield=v_yield+z_volume(p_z)
_sum_znum_yield=_sum_znum_yield+1
else
;z_group(p_z)='other'
endif
p_z=z_next(p_z)
endloop
if _sum_znum_yield#0
command
;title
;显示模型中屈服破坏单元体
plot creat my_yield
plot add surf red range group my_yield_
plot add sk range group other
plot show my_yield
endcommand
endif
ii = out('破坏类型 体积 单元体个数') ;输出题头
ii = out('shear_now : ' + string(v_shear_now)+' '+ string(_sum_znum_shearnow)) ;输出shear_now的体积值
ii = out('tension_now : ' + string(v_tension_now)+' '+string(_sum_znum_tensionnow));输出tension_now的体积值
ii = out('shear_past : ' + string(v_shear_past)+' '+string(_sum_znum_shearpast)) ;输出shear_past的体积值
ii = out('tension_past :'+string(v_tension_past)+' '+string(_sum_znum_tensionpast));输出tension_past的体积值
ii = out('yield : ' + string(v_yield)+' '+string(_sum_znum_yield)) ;
ii = out('选择菜单栏 Window->Tile,会有惊喜哦!!') ;
end
;plasticrange

我的更多文章

下载客户端阅读体验更佳

APP专享