单轴压缩试验和二维直剪试验实际上属于同一类,都是通过简单的模型生成,伺服机制,加压及后处理,然而现在更多的pfc模拟要求模拟破碎过程,不模拟cluster的破碎总是显得深度不够。
不可避免的就要求基本cluster的生成,提供一种简单的生成方式。
;首先定义簇--------------------------------------------------------
def make_clusters
ball_total_num_in_clusters = 100
count = 0
total_num = 0
cluster_index = 0
;颗粒遍历
loop foreach local bp ball.list ;建立变量
if ball.group(bp) # 'None' then ;判断颗粒是否已经在簇里面了 ,#不等于的意思
continue ;在簇里面,跳过所有后续内容,直接执行endloop
endif
cluster_index = cluster_index + 1 ;如果没被包含到cluster,那么编号+1
ball_group_name = string.build('cluster_%1', cluster_index) ;建立字符串集合, cluster_index的
ball.group(bp) = ball_group_name ;将这个颗粒归到簇里面
count = count + 1
total_num = total_num + 1 ;颗粒总数目
if total_num >= ball_total_num_in_clusters then
exit
endif
ball_maxnum_in_cluster = int(7 * math.random.uniform) + 1 ;簇中的颗粒数目
loop foreach local cp ball.contactmap(bp,contact.typeid('ball-ball'))
;遍历 指针为bp的球 的 接触为ball-ball 的球
if count >= ball_maxnum_in_cluster then
count = 0
exit loop
endif
if contact.end1(cp) = bp then ;如果这个接触对应球是中间的球 那么ok,接触的另一端其他球,反之其他球是中间球
bp_other = contact.end2(cp)
else
bp_other = contact.end1(cp)
endif ; bp_other得到的已经是其他球而不是中间球
if ball.group(bp_other) # 'None' then
continue
endif
ball.group(bp_other) = ball_group_name
count = count + 1
total_num = total_num + 1
if total_num >= ball_total_num_in_clusters then
exit
endif
end_loop
end_loop
end
;----------------------------------------------------------------------------------
@make_clusters
list @cluster_index
标签:pfc,ball,group,试验,单轴,cluster,num,bp,total From: https://blog.51cto.com/u_15867247/8708066