参考我之前的问题,
Faster way to partition a Face with Sketch in ABAQUS with scripting,
我必须选择分区方法创建的多个区域来分配网格控件并对边缘进行种子处理,最后分别对这些区域进行网格划分。
问题是,由于分区区域是参数化的并且数量更大,因此为此目的定义函数并在循环中运行它是唯一适合我的方法。因此,我尝试用两种不同的方式定义函数:
定义一个函数来选择区域并在整个身体长度的循环中运行。在这里,每个小区域被挑选一次,并且重复应用相同的网格控件,导致生成网格的时间很长。
def set_mesh_control_structured(x_left, x_right, y_top, y_bottom,
element_type, mesh_technique, minimize_transition):
p = mdb.models['Model-1'].parts['Part']
f = p.faces
pickedRegions = f.findAt(((x_left + (x_right - x_left)/2, y_bottom
(y_top - y_bottom)/2, 0.0), ))
return p.setMeshControls(regions=pickedRegions,
elemShape=element_type, technique=mesh_technique,
minTransition=minimize_transition)
# Executed within a 'for' loop like e.g.:
for i in range((8 * total_blocks) + 6):
set_mesh_control_structured(x_left, x_right + (i *
block_length), y_coord[0], 0.0, QUAD, STRUCTURED, OFF)
第二个函数尝试逐个选择所有区域,然后仅在末尾应用网格控件一次。这就是问题蔓延的地方。一个假设findAt()的参数是一个元组的元组,但它不起作用,ABAQUS在set_mesh_control_structured中给出一个错误警告,说明" ...; pickedRegions = f.findAt(regions_tuple); TypeError:arg1(coordinates)[0] [0];找到tuple expecting float "。
def set_mesh_control_structured(range_arg, x_left, x_right, y_top,
y_bottom, element_type, mesh_technique, minimize_transition):
p = mdb.models['TDCB'].parts['Part_TDCB']
f = p.faces
regions_tuple = ()
for i in range(range_arg):
# Put x,y,z coords in one value
incremental_picked_regions = (x_left + (i * (x_right -
x_left)/2), y_bottom + (i * (y_top - y_bottom)/2), 0.0)
# Abaqus wants each repeating unit as ((x,y,z),)
incremental_picked_regions = ((incremental_picked_regions),)
# Adding all the coordinates into 1 tuple
regions_tuple += (incremental_picked_regions,)
pickedRegions = f.findAt(regions_tuple)
return p.setMeshControls(regions=pickedRegions,
elemShape=element_type, technique=mesh_technique,
minTransition=minimize_transition)
任何人都可以告诉我在第二个函数定义中我做错了什么,或者是否有更好的方法来选择多个区域以设置网格控件和除了findAt()之外的种子?我知道getBoundingBox和faces.index [#]等,但我不知道如何使用它们。因此,MWE也将受到高度赞赏。
提前多多感谢。
答案 0 :(得分:1)
试试这个,在每个点上使用findAt
并添加结果:
for i in range(range_arg):
# Put x,y,z coords in one value
incremental_picked_regions = (x_left + (i * (x_right -
x_left)/2), y_bottom + (i * (y_top - y_bottom)/2), 0.0)
if i==0 :
pickedRegions = f.findAt((incremental_picked_regions,),)
else:
pickedRegions += f.findAt((incremental_picked_regions,),)
答案 1 :(得分:0)
任何想要更好地理解这个问题的人,我首先建议查看我的其他相关问题。
我使用getByBoundingBox
解决了我的这个问题,它具有以下语法:
getByBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax)
因此,可以方便地使用它来代替findAt()来选择大量的分区面或边缘。
所以以平面矩形为例,分别为(0.0,0.0,0.0),(2.0,0.0,0.0),(2.0,2.0,0.0)和(0.0,2.0,0.0)四个角,让我们看看假设在这个矩形内有多个分区面,所有这些面都需要像GUI中那样一次被选中。首先,getByBoundingBox
的六个参数将是:
xmin = 0.0,
ymin = 0.0,
zmin = 0.0,
xmax = 2.0,
ymax = 2.0,
zmax = 0.0
然后,只需按以下方式选择所需区域:
pickedRegions = f.getByBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax)