微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

是否可以在 ABAQUS 中自动分区?如果是这样,如何? 简答长答案一些额外的评论:

如何解决是否可以在 ABAQUS 中自动分区?如果是这样,如何? 简答长答案一些额外的评论:

我正在尝试使用 Python 脚本在 ABAQUS 中自动对模型进行分区。到目前为止,我有一种感觉,我正在陷入无解的兔子洞。我有一种感觉,即使我设法做到了,该算法也会非常低效且比手动分区慢。 我希望脚本:

  • 用垂直于边缘的线连接每个面上的有趣点。
  • 适用于任何模型。
  • 创建以后可以删除/编辑的分区。

我的问题是:是否可以自动分区?如果是这样,我应该使用什么样的算法?

与此同时,我在下面制作了一个初始代码,以了解使用按最短路径功能进行分区的问题: (请注意,我正在遍历顶点而不是有趣的点,因为我还没有找到访问它们的方法。)

我遇到的问题是:

  • 当我通过范围函数人脸进行分区时,将创建新的人脸。我的替代方法是选择所有面孔。
  • 在我分区时创建了新的有趣点。我可以制作初始有趣点的浅拷贝,然后提取坐标,然后使用这些坐标进行分区。在分区之前,我需要将坐标转换回字典对象。
  • 我似乎无法通过命令访问有趣的点。
from abaqus import *
from abaqusConstants import *

#Define Functions

def Create_cube(myPart,myString):                                                
    s = mdb.models[myString].ConstrainedSketch(name='__profile__',sheetSize=200.0)
    g,v,d,c = s.geometry,s.vertices,s.dimensions,s.constraints
    s.setPrimaryObject(option=STANDALONE)
    s.rectangle(point1=(10.0,10.0),point2=(-10.0,-10.0))
    p = mdb.models[myString].Part(name=myPart,dimensionality=THREE_D,type=DEFORMABLE_BODY)
    p = mdb.models[myString].parts[myPart]
    p.BaseSolidExtrude(sketch=s,depth=20.0)
    s.unsetPrimaryObject()
    p = mdb.models[myString].parts[myPart]
    session.viewports['Viewport: 1'].setValues(displayedobject=p)
    del mdb.models[myString].sketches['__profile__']

def subtractTheMatrix(matrix1,matrix2):
    matrix = [0,0]
    for i in range(0,3):
        matrix[i] = matrix1[i] - matrix2[i]
        if matrix[i]==0.0:
            matrix[i]=int(matrix[i])
    return matrix

#Define Variables
myString='Buckling_Analysis'
myRadius= 25.0
myThickness= 2.5
myLength=1526.0
myModel= mdb.Model(name=myString)
myPart='Square'
myOffset=0.0
set_name='foobar'


#-------------------------------------------------------------------MODELLING-----------------------------------------------------------------

#Function1: Create Part
Create_cube(myPart,myString)

#Function2: Extract Coordinates from vertices    (using string manipulation)
#Input: vertices in vertex form
#Output: coordinates of vertices in the form [[x,y,z],[x1,y1,z1],[x2,y2,z2]]   (name: v1_coordinates)       
p = mdb.models[myString].parts[myPart]                                                                    
v1=p.vertices                                                                   
v1_coordinates=[]                  
for x in range(len(v1)):                                                         
    dictionary_object=v1[x]                                                      
    dictionary_object_str= str(dictionary_object)                                
    location_pointon=dictionary_object_str.find("""pointOn""")                   
    location_coord=location_pointon+12
    coordinates_x_string=dictionary_object_str[location_coord:-5]                            
    coordinates_x_list=coordinates_x_string.split(',')                           #convert string to list of strings
    for lo in range(3):
        coordinates_x_list[lo]=float(coordinates_x_list[lo])                     #change string list to float list
    v1_coordinates.append(coordinates_x_list)                                    #append function. adds float list to existing list
print("""these are all the coordinates for the vertices""",v1_coordinates) 


#Function3: Partioning loop though List of Coordinates 
#Input: List of Coordinates
#Output: Partioned faces of model (Can only be seen in ABAQUS viewport.)

f = p.faces 
v1 = p.vertices
#try and except to ignore when vertex is not in plane
final_number_of_faces=24
for i in range(0,final_number_of_faces,2):  
    print("this is for face:")  
    for j in range(len(v1_coordinates)):
        fixed_vertex_coord = v1_coordinates[j]                             
        fixed_vertex_dict = v1.getClosest(coordinates=((fixed_vertex_coord[0],fixed_vertex_coord[1],fixed_vertex_coord[2]),))
        fixed_vertex_dict_str= str(fixed_vertex_dict[0])                           
        location_1=fixed_vertex_dict_str.find("""],""") 
        fixed_vertex_index=int(fixed_vertex_dict_str[location_1-1:location_1])
        for k in range(len(v1_coordinates)):
            try: 
                if subtractTheMatrix(v1_coordinates[j],v1_coordinates[k])==[0,0]:              
                    continue                        
                else:
                    moving_vertex_coord=v1_coordinates[k]                
                    moving_vertex_dict=v1.getClosest(coordinates=((moving_vertex_coord[0],moving_vertex_coord[1],moving_vertex_coord[2]),))
                    moving_vertex_dict_str= str(moving_vertex_dict[0])                       
                    location_2=moving_vertex_dict_str.find("""],""")
                    moving_vertex_index=int(moving_vertex_dict_str[location_2-1:location_2]) 
                    p.PartitionFaceByShortestPath(point1=v1[fixed_vertex_index],point2=v1[moving_vertex_index],faces=f[i])
            except:
                print("face error")
                continue

解决方法

简答

“是否可以在 ABAQUS 中自动进行分区?” -- 是的

“如何”——这取决于。对于您的示例,您可能会非常适合 PartitionEdgeByDatumPlane() 方法。

长答案

一般来说,您无法创建适用于任何模型的方法。您可以自动/概括相似几何图形的分区,以及在使用相似逻辑执行分区时。


根据您的问题,您有多种方法来执行分区,例如:

  • 对于人脸:ByShortestPathBySketchByDatumPlane 等;
  • 对于单元格:ByDatumPlaneByExtrudeEdgeBySweepEdge

根据您的初始几何图形和所需的结果,您可能需要使用不同的几何图形。您的方法(脚本的逻辑)会相应地发展。

Abaqus 脚本语言对于检查相交、几何相关性等不是很理想,所以是的,如果您的几何/任务需要将几种分区方法应用于复杂几何的复杂组合,那么它可能需要一些缓慢的方法(例如循环通过所有顶点)。

一些额外的评论:

  • 无需通过 p 重新分配变量 p = mdb.models[myString].parts[myPart]mdb.models[myString].Part(..) 已经返回部分对象。
  • 您真的需要方法 setPrimaryObject/unsetPrimaryObject 吗?自动化时,您通常不需要视口方法(还有 session.viewports['Viewport: 1'].setValues(displayedObject=p))。
  • 请使用 Abaqus 对象的属性(如您的 previous question 中所述);
  • 不要忘记您可以遍历序列:当您不需要明确知道索引时,使用 for v_i in v1 而不是 for x in range(len(v1));当您需要对象及其索引时使用 enumerate()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。