def _Bohrprofil_vernetzen(modell, name, gitter): """Erzeuge ein Netz fuer das Bauteil (Part) name im modell mit der Netzfeinheit gitter. """ import part import mesh from abaqusConstants import UNKNOWN_HEX, UNKNOWN_WEDGE, EXPLICIT, C3D10M, TET, FREE, OFF, DEFAULT from hilfen import Log # partWerkzeug = modell.parts[name] # Sets partWerkzeug.Set(name='setAll', cells=partWerkzeug.cells) partWerkzeug.Set( name='setRP', referencePoints=( partWerkzeug.referencePoints[partWerkzeug.features['RP'].id], )) # Elementtypen anpassen partWerkzeug.setElementType( elemTypes=(mesh.ElemType(elemCode=UNKNOWN_HEX, elemLibrary=EXPLICIT), mesh.ElemType(elemCode=UNKNOWN_WEDGE, elemLibrary=EXPLICIT), mesh.ElemType(elemCode=C3D10M, elemLibrary=EXPLICIT, secondOrderAccuracy=OFF, distortionControl=DEFAULT)), regions=partWerkzeug.sets['setAll']) # Mesh partWerkzeug.setMeshControls(elemShape=TET, regions=partWerkzeug.cells, technique=FREE) partWerkzeug.seedPart(deviationFactor=0.1, minSizeFactor=0.1, size=gitter) partWerkzeug.generateMesh() if (len(partWerkzeug.elements) == 0): Log('Warnung: Mesh-Erstellung zu ' + name + ' fehlgeschlagen')
def seedMesh(paramsDict): for key in list(paramsDict): exec('%s="%s"' %(key, paramsDict[key])) try:#only expecting strings or numbers. exec('%s=float(%s)' %(key, key)) except ValueError: pass if modelName == 'onePartModel': p = mdb.models[modelName].parts['CombinedPart'] c = p.cells pickedRegions = c[:] p.setMeshControls(regions=pickedRegions, elemShape=HEX, technique=STRUCTURED) p.seedPart(size=meshSize, deviationFactor=0.1, minSizeFactor=0.1) else: #Column seeding and generation p = mdb.models[modelName].parts['Column'] c = p.cells pickedRegions = c[:] p.setMeshControls(regions=pickedRegions, elemShape=HEX, technique=STRUCTURED) p.seedPart(size=meshSize, deviationFactor=0.1, minSizeFactor=0.1) #Foundation seeding and generation p = mdb.models[modelName].parts['Foundation'] c = p.cells pickedRegions = c[:] p.seedPart(size=meshSize, deviationFactor=0.1, minSizeFactor=0.1) if modelType == 'CohesiveZoneModel': elemType1 = mesh.ElemType(elemCode=COH3D8, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=COH3D6, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=UNKNOWN_TET, elemLibrary=STANDARD) if strongOrient: cells1 = c.findAt(((bf/4, db/2 + cohThk/2, bpTop + embedDepth/2),)) cells2 = c.findAt(((bf/4, db/2 - tf - cohThk/2, bpTop + embedDepth/2),)) cells3 = c.findAt(((bf/4, -db/2 + tf + cohThk/2, bpTop + embedDepth/2),)) cells4 = c.findAt(((bf/4, -db/2 - cohThk/2, bpTop + embedDepth/2),)) cells5 = c.findAt(((tw/2 + cohThk/2,0.0, bpTop + embedDepth/2),)) cells6 = c.findAt(((bf/2 + cohThk/2, db/2 - tf/2, bpTop + embedDepth/2),)) cells7 = c.findAt(((bf/2 + cohThk/2, -db/2 + tf/2, bpTop + embedDepth/2),)) cells = cells1 + cells2 + cells3 + cells4 + cells5 + cells6 + cells7 pass #Corners elif not strongOrient: cells1 = c.findAt(((db/4, tw/2 + cohThk/2, bpTop + embedDepth/2),)) cells2 = c.findAt(((db/4, -tw/2 - cohThk/2, bpTop + embedDepth/2),)) cells3 = c.findAt(((db/2 - tf - cohThk/2, db/4, bpTop + embedDepth/2),)) cells4 = c.findAt(((db/2 - tf - cohThk/2, -db/4, bpTop + embedDepth/2),)) cells5 = c.findAt(((db/2 + cohThk/2, 0.0, bpTop + embedDepth/2),)) cells6 = c.findAt(((db/2 - tf/2, bf/2 + cohThk/2, bpTop + embedDepth/2),)) cells7 = c.findAt(((db/2 - tf/2, -bf/2 - cohThk/2, bpTop + embedDepth/2),)) pass #corners cells = cells1 + cells2 + cells3 + cells4 + cells5 + cells6 + cells7 if baseplate: cells8 = c.getByBoundingBox(xMin=0.0, xMax=bpWX/2, yMin = -bpWY/2, yMax = bpWY/2, zMin=bpTop, zMax=bpTop+cohThk)#Above baseplate cells9 = c.getByBoundingBox(xMin=0.0, xMax=bpWX/2, yMin = -bpWY/2, yMax = bpWY/2, zMax=bpTop-baseDepth, zMin=bpTop-baseDepth-cohThk) #Below baseplate cells10 = c.getByBoundingBox(xMin=0.0, xMax=bpWX/2, yMin = bpWY/2, yMax = bpWY/2+cohThk, zMin=bpTop-baseDepth, zMax=bpTop) #Up-baseplate side cells11 = c.getByBoundingBox(xMin=0.0, xMax=bpWX/2, yMin = -bpWY/2-cohThk, yMax = -bpWY/2, zMin=bpTop-baseDepth, zMax=bpTop) #Down-baseplate side cells12 = c.getByBoundingBox(xMin=bpWX/2, xMax=bpWX/2+cohThk, yMin = -bpWY/2, yMax = bpWY/2, zMin=bpTop-baseDepth, zMax=bpTop) #Right-baseplate side cells = cells + cells8 + cells9 + cells10 + cells11 + cells12 pickedRegions =(cells, ) p.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3))
def assign_DC3D8_element(part): ''' 输入:构件名称 输出:无 功能:赋予热传递单元属性 ''' a = mdb.models['Model-1'].rootAssembly ''' 对当前单元赋予热传递单元属性 ''' elemType1 = mesh.ElemType(elemCode=DC3D8, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=DC3D6, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=DC3D4, elemLibrary=STANDARD) a = mdb.models['Model-1'].rootAssembly p = mdb.models['Model-1'].parts[part] # 获取p实体的所有cells c = p.cells pickedCells_h = c[:] p.Set(cells=pickedCells_h, name='Set-' + part) # region为获取名为Set-composite的集合 region_h = p.sets['Set-' + part] # p.setMeshControls(regions=pickedCells_h, elemShape=HEX, technique=SWEEP, # algorithm=ADVANCING_FRONT) p.setElementType(regions=region_h, elemTypes=(elemType1, elemType2, elemType3)) # p.generateMesh() print(' {} has been assigned DC3D8R element property!'.format(part))
def creat_C3D8R_element(part): ''' 对当前单元赋予静态分析类型 :param part: :return: ''' elemType1 = mesh.ElemType(elemCode=C3D8R, elemLibrary=STANDARD, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=OFF, hourglassControl=DEFAULT, distortionControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=C3D6, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D4, elemLibrary=STANDARD) a = mdb.models['Model-static'].rootAssembly p = mdb.models['Model-static'].parts[part] # 获取p实体的所有cells c = p.cells # pickedCells为所有cells pickedCells_h = c[:] # region为获取名为Set-composite的集合 region_h = (pickedCells_h, ) p.setElementType(regions=region_h, elemTypes=(elemType1, elemType2, elemType3)) #p.seedPart(size=size, deviationFactor=0.1, minSizeFactor=0.1) #p.generateMesh() print(' {} has been assigned '.format(part))
def defineThermalElements(myAsm, regionPick, args): """ Set thermal element type based on standard/explicit analysis. """ try: if args.dynamicExplicit: elemLibrary = EXPLICIT else: elemLibrary = STANDARD elemType1 = mesh.ElemType(elemCode=C3D20RT, elemLibrary=elemLibrary) elemType2 = mesh.ElemType(elemCode=UNKNOWN_WEDGE, elemLibrary=elemLibrary) elemType3 = mesh.ElemType(elemCode=C3D10MT, elemLibrary=elemLibrary, secondOrderAccuracy=OFF, hourglassControl=DEFAULT, distortionControl=DEFAULT) myAsm.setMeshControls(regions=regionPick, elemShape=TET, technique=FREE, sizeGrowthRate=1.05) myAsm.setElementType(regions=(regionPick, ), elemTypes=( elemType1, elemType2, elemType3, )) except: cad_library.exitwitherror( 'Error trying to assign thermal-type elements for mesh.', -1, 'AbaqusThermal.py')
def initThermal_mesh(part, start_temp): # mdb.models['Model-1'].materials['bfc'].elastic.setValues(table=((7.8, 0.3),)) # # ##################### # 开始赋予力学单元属性 elemType1 = mesh.ElemType(elemCode=C3D8R, elemLibrary=STANDARD, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=OFF, hourglassControl=DEFAULT, distortionControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=C3D6, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D4, elemLibrary=STANDARD) p = mdb.models['Model-1'].parts[part] # 获取p实体的所有cells c = p.cells # pickedCells为所有cells pickedCells = c[:] # 为该cells创建一个名为Set-composite的集合 p.Set(cells=pickedCells, name='Set-' + part + 'load') # region为获取名为Set-composite的集合 region = p.sets['Set-' + part + 'load'] p.setElementType(regions=region, elemTypes=(elemType1, elemType2, elemType3)) # 导出每个构件的cell print(' {} has been assigned C3D8R element property'.format(part))
def creat_thermal_force_element(part): ''' 功能:对传入的part赋予C3D8R,无返回值 输入:构件名称,eg:"bfc" 输出:无返回值,仅为赋予属性 ''' # 定义单元类型 elemType1 = mesh.ElemType(elemCode=C3D8T, elemLibrary=STANDARD, secondOrderAccuracy=OFF, distortionControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=C3D6T, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D4T, elemLibrary=STANDARD) # 获取part # m1 = [key for key in m.keys()] 这是第二种提取model方法, # 暂存后续有要求可更改 # >> > m1 # ['Model-1', 'Model-1-Copy'] p_func = mdb.models['Model-1'].parts[part] # 获取p实体的所有cells c_func = p_func.cells # pickedCells为所有cells pickedCells_h = c_func[:] # region为获取名为Set-composite的集合 region_func = (pickedCells_h, ) p_func.setElementType(regions=region_func, elemTypes=(elemType1, elemType2, elemType3)) print(' Finish assigned {} to C3D8R!'.format(part))
def meshForPanelLower(seedSize1, seedSize2, seedSize3, seedSize4): """ 给下板划分网格,其中seedSize1表示沿孔厚度的种子,seedSize2表示沿孔边的种子, seedSize3表示孔附近的种子,seedSize4表示其余的种子 """ p = mdb.models['Model-1'].parts['Panel_Lower'] e = p.edges pickedEdges = e.getSequenceFromMask(mask=('[#800 #1 ]', ), ) p.seedEdgeBySize(edges=pickedEdges, size=seedSize1, deviationFactor=0.1, constraint=FINER) e = p.edges pickedEdges = e.getSequenceFromMask(mask=('[#200000 #8 ]', ), ) p.seedEdgeBySize(edges=pickedEdges, size=seedSize2, deviationFactor=0.1, constraint=FINER) p = mdb.models['Model-1'].parts['Panel_Lower'] e = p.edges pickedEdges = e.getSequenceFromMask(mask=('[#80101400 ]', ), ) p.seedEdgeBySize(edges=pickedEdges, size=seedSize3, deviationFactor=0.1, constraint=FINER) p.seedPart(size=seedSize4, deviationFactor=0.1, minSizeFactor=0.1) elemType1 = mesh.ElemType(elemCode=C3D8R, elemLibrary=EXPLICIT, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=OFF, hourglassControl=DEFAULT, distortionControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=C3D6, elemLibrary=EXPLICIT) elemType3 = mesh.ElemType(elemCode=C3D4, elemLibrary=EXPLICIT) c = p.cells cells = c.getSequenceFromMask(mask=('[#f ]', ), ) pickedRegions =(cells, ) p.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) p.generateMesh()
def Create_Mesh_Shell(model,part,size): p = mdb.models[model].parts[part] elemType1 = mesh.ElemType(elemCode=S4R, elemLibrary=STANDARD, secondOrderAccuracy=OFF, hourglassControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=S3, elemLibrary=STANDARD) faces = p.faces[:] pickedRegions =(faces, ) p.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2)) p.seedPart(size=size, deviationFactor=0.1, minSizeFactor=0.1) p.generateMesh()
def Create_Mesh(model,part,size): p = mdb.models[model].parts[part] elemType1 = mesh.ElemType(elemCode=SC8R, elemLibrary=STANDARD, secondOrderAccuracy=OFF, hourglassControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=SC6R, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=UNKNOWN_TET, elemLibrary=STANDARD) cells = p.cells[:] pickedRegions =(cells, ) p.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) p.seedPart(size=size, deviationFactor=0.1, minSizeFactor=0.1) p.generateMesh()
def Create_Mesh_Solid(model,part,size): p = mdb.models[model].parts[part] elemType1 = mesh.ElemType(elemCode=C3D20R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=C3D15, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D10, elemLibrary=STANDARD) cells = p.cells[:] pickedRegions =(cells, ) p.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) p.seedPart(size=size, deviationFactor=0.1, minSizeFactor=0.1) p.generateMesh()
def assignElementType(assembly, partInstance, crackNum): #设置单元类型 elemType1 = mesh.ElemType(elemCode=CPS8, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=CPS6, elemLibrary=STANDARD) assembly.setElementType(regions=assembly.sets['wholePart'], elemTypes=(elemType1, )) assembly.setElementType(regions=assembly.sets['crackRgOut' + str(crackNum)], elemTypes=(elemType1, )) assembly.setElementType(regions=assembly.sets['crackRg' + str(crackNum)], elemTypes=(elemType2, ))
def pipePro(self): ''' this function is to define the common properties of pipes with respect to material section, assembly, and mesh. :return: ''' m=mdb.models[self.pipeModel] p=m.parts[self.pipePart] import section material_lib(self.pipeModel) m.PipeProfile(name='profile-1', r=self.od/2, t=self.t) m.BeamSection(name='Section-1',profile='profile-1', material=self.m,integration=DURING_ANALYSIS) pipeEdge=p.edges region=(pipeEdge,) p.SectionAssignment(region=region, sectionName='Section-1') region=(pipeEdge,) p.assignBeamSectionOrientation(region=region,method=N1_COSINES,n1=(0,0,-1)) region=(pipeEdge,) p.assignBeamSectionOrientation(region=region,method=N1_COSINES,n1=(0,0,-1)) import assembly a=m.rootAssembly a.Instance(name=self.pipePart+str(-1),part=p,dependent=OFF) # edges for seeds and mesh l_lon=a.instances[self.pipePart+str(-1)].edges.getByBoundingBox(xMin=-1,xMax=self.L+1) a.Set(edges=l_lon,name='pipeL') import mesh a.seedEdgeBySize(edges=l_lon,size=self.sPipe,constraint=FINER) regions=a.instances[self.pipePart+str(-1)].edges a.generateMesh(regions=(a.instances[self.pipePart+str(-1)],)) elemType1=mesh.ElemType(elemCode=PIPE32H) regions=regionToolset.Region(edges=a.instances[self.pipePart+str(-1)].edges) a.setElementType(regions=regions,elemTypes=(elemType1,))
def shellTo2DGeo(myModel,seedSize=0.5,elementType='CPS'): ''' shellTo2DGeo is the function to be called from abaqus cae mandatory arguments: myModel: an abaqus model (model produced with scanIP and imported in abaqus) optional arguments: seedSize: the relative size of the new mesh points (0.5 means there will be two seeds per geometrical line ie one new element edge per old element edge at the boundaries) elementType: choose type of 2d element, anything else than 'CPS' will produce a plane strain mesh, default keeps plane stress ''' ## load needed abaqus constants from abaqusConstants import TWO_D_PLANAR,DEFORMABLE_BODY,OFF,ON,QUAD,CPS3,CPS4R,CPE3,CPE4R,STANDARD,ENHANCED ## ELEMENT INTEGRATION (2D elements: CPE=plane strain, CPS=plane stress) # defines abaqus elements - hourglass controlled standard quadrangles (abaqus asks for the definition of the triangular elements even if they a not used!!) if elementType=:'CPS': elemType1 = mesh.ElemType(elemCode=CPS4R, elemLibrary=STANDARD, hourglassControl=ENHANCED) elemType2 = mesh.ElemType(elemCode=CPS3, elemLibrary=STANDARD)
def meshForDieUpper(seedSize): """ 给上铆模划分网格 """ p = mdb.models['Model-1'].parts['Die_Upper'] p.seedPart(size=seedSize, deviationFactor=0.1, minSizeFactor=0.1) elemType1 = mesh.ElemType(elemCode=C3D8R, elemLibrary=EXPLICIT, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=OFF, hourglassControl=DEFAULT, distortionControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=C3D6, elemLibrary=EXPLICIT) elemType3 = mesh.ElemType(elemCode=C3D4, elemLibrary=EXPLICIT) c = p.cells cells = c.getSequenceFromMask(mask=('[#3 ]', ), ) pickedRegions =(cells, ) p.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) p.generateMesh()
def changeAnalysisType(self,analysisType='Mechanical'): """ Method to change the analysis type by changing the element type """ # Assign mesh control Mesh on PART (NOT INSTANCE) if analysisType=='ThermalDiffusion': elemType1 = mesh.ElemType(elemCode=DC3D8, elemLibrary=STANDARD) # Axisymetric therma and massdiffusion elements elemType2 = mesh.ElemType(elemCode=DC3D6, elemLibrary=STANDARD) # Axisymetric therma and massdiffusion elements elif analysisType=='Mechanical': elemType1 = mesh.ElemType(elemCode=C3D8, elemLibrary=STANDARD) # Axisymetric stress elements elemType2 = mesh.ElemType(elemCode=C3D6, elemLibrary=STANDARD) # Axisymetric stress elements else: print " ERROR: The analysis types supported are: ThermalDiffusion or Mechanical" sys.exit(" ERROR: Method mesh of class cylinderSpecimenClass was called using incorrect argument, Exiting") # Assign element type self.myAssembly.setElementType(regions=(self.fatiguePart.cells,), elemTypes=(elemType1, elemType2))
def __create_mesh(mesh_edge_length, model_name, part_name): part = mdb.models[model_name].parts[part_name] cells = part.cells.getSequenceFromMask(mask=('[#1 ]', ), ) regions = (cells, ) part.seedPart(size=mesh_edge_length, minSizeFactor=0.1) elem_type_1 = mesh.ElemType(elemCode=C3D8T, elemLibrary=EXPLICIT, secondOrderAccuracy=OFF, distortionControl=DEFAULT) elem_type_2 = mesh.ElemType(elemCode=C3D6T, elemLibrary=EXPLICIT, secondOrderAccuracy=OFF, distortionControl=DEFAULT) elem_type_3 = mesh.ElemType(elemCode=C3D4T, elemLibrary=EXPLICIT, secondOrderAccuracy=OFF, distortionControl=DEFAULT) part.setElementType(regions=regions, elemTypes=(elem_type_1, elem_type_2, elem_type_3)) part.generateMesh()
def __create_mesh(model_name, part_name, mesh_edge_length): part = mdb.models[model_name].parts[part_name] part.seedPart(size=mesh_edge_length, deviationFactor=config.MESH_DEVIATION_FACTOR, minSizeFactor=config.MESH_MIN_SIZE_FACTOR) part = mdb.models[model_name].parts[part_name] faces = part.faces picked_regions = faces.getSequenceFromMask(mask=('[#7 ]', ), ) part.setMeshControls(regions=picked_regions, elemShape=QUAD, technique=STRUCTURED) elem_type_quad = mesh.ElemType(elemCode=CPE4T, elemLibrary=STANDARD) elem_type_tri = mesh.ElemType(elemCode=CPE3T, elemLibrary=STANDARD) part = mdb.models[model_name].parts[part_name] faces = part.faces.getSequenceFromMask(mask=('[#7 ]', ), ) picked_regions = (faces, ) part.setElementType(regions=picked_regions, elemTypes=(elem_type_quad, elem_type_tri)) part = mdb.models[model_name].parts[part_name] part.generateMesh()
def makeMesh2D(globalSeed=20): import mesh part.setMeshControls(elemShape=aq.TRI, regions=(allSet.faces)) # Set to triangle shape part.setElementType(elemTypes=(mesh.ElemType(elemCode=aq.DC2D8, elemLibrary=aq.STANDARD), mesh.ElemType(elemCode=aq.DC2D6, elemLibrary=aq.STANDARD)), regions=(allSet)) # nodes, elements = 0, 0 # Do I need this line? while True: part.seedPart(deviationFactor=0.1, minSizeFactor=0.1, size=globalSeed) part.generateMesh() modelObject.rootAssembly.regenerate() nodes = len(modelObject.rootAssembly.instances['PART1'].nodes) elements = len(modelObject.rootAssembly.instances['PART1'].elements) if nodes < 60000: globalSeed = globalSeed * 0.80 elif nodes > 95000: globalSeed = globalSeed * 1.20 else: break return elements, nodes
def createElementTypeData(self): """ """ elementType = self.getElementType() print "--------------------" print elementType print "--------------------" elementFamily = { "LinearTet": mesh.ElemType(elemCode=C3D4, elemLibrary=STANDARD, distortionControl=OFF), "LinearHexFI2ndOrdAcc": mesh.ElemType(elemCode=C3D8, elemLibrary=STANDARD, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=ON, hourglassControl=DEFAULT, distortionControl=DEFAULT), "LinearHexRI2ndOrdAcc": mesh.ElemType(elemCode=C3D8R, elemLibrary=STANDARD, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=ON, hourglassControl=DEFAULT, distortionControl=DEFAULT), "LinearHexRI": mesh.ElemType(elemCode=C3D8R, elemLibrary=STANDARD, kinematicSplit=AVERAGE_STRAIN, secondOrderAccuracy=OFF, hourglassControl=DEFAULT, distortionControl=DEFAULT), "LinearHexFI": mesh.ElemType(elemCode=C3D8, elemLibrary=STANDARD) } self.dataStr["mdb"]["meshParameters"]["elementCodes"] = elementFamily[ elementType]
def mesh_part(x,y,seed_size=0.5): x = float(x) y = float(y) p = mdb.models['Model-1'].parts['Part-1'] region = [] for cell in p.cells: region.append(cell) p.setMeshControls(regions=region, technique=SWEEP) p.seedPart(size=seed_size, deviationFactor=0.1, minSizeFactor=0.1) elemType1 = mesh.ElemType(elemCode=C3D20R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=C3D15, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D10, elemLibrary=STANDARD) p.setElementType(regions=region, elemTypes=(elemType1, elemType2, elemType3)) # refine twin and parent e = p.edges twin_face = p.faces.findAt((x,y, 0),) edges = twin_face.getEdges() edges = tuple(e[i] for i in edges) p.seedEdgeBySize(edges=edges, size=0.1, deviationFactor=0.1, minSizeFactor=0.1, constraint=FINER) p.generateMesh()
def Load_Mesh(partname): a = mdb.models['Model-1'].rootAssembly f1 = a.instances[partname + '-1'].faces faces1 = f1.getSequenceFromMask(mask=('[#400 ]',), ) region = regionToolset.Region(faces=faces1) mdb.models['Model-1'].EncastreBC(name='BC-1', createStepName='Initial', region=region, localCsys=None) faces1 = f1.getSequenceFromMask(mask=('[#1000000 ]',), ) region = regionToolset.Region(faces=faces1) mdb.models['Model-1'].DisplacementBC(name='BC-2', createStepName='Initial', region=region, u1=SET, u2=UNSET, u3=SET, ur1=SET, ur2=SET, ur3=SET, amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=None) r1 = a.instances[partname + '-1'].referencePoints refPoints1 = (r1[6],) region = regionToolset.Region(referencePoints=refPoints1) mdb.models['Model-1'].ConcentratedForce(name='Load-1', createStepName='Step-1', region=region, cf2=1500.0, distributionType=UNIFORM, field='', localCsys=None) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Mesh elemType1 = mesh.ElemType(elemCode=SC8R, elemLibrary=STANDARD, secondOrderAccuracy=OFF, hourglassControl=DEFAULT) elemType2 = mesh.ElemType(elemCode=SC6R, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=UNKNOWN_TET, elemLibrary=STANDARD) a = mdb.models['Model-1'].rootAssembly c1 = a.instances[partname + '-1'].cells cells1 = c1.getSequenceFromMask(mask=('[#1f ]',), ) pickedRegions = (cells1,) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) pickedRegions = c1.getSequenceFromMask(mask=('[#1f ]',), ) a.setMeshControls(regions=pickedRegions, technique=SWEEP, algorithm=MEDIAL_AXIS) partInstances = (a.instances[partname + '-1'],) a.seedPartInstance(regions=partInstances, size=1.7, deviationFactor=0.1, minSizeFactor=0.1) a.generateMesh(regions=partInstances)
def create_mesh(self): self.set_mesh_control() self.soilPart.setElementType( regions=(self.soilPart.sets["Infinite_Faces"]), elemTypes=(mesh.ElemType(elemCode=CAX4I, elemLibrary=STANDARD), mesh.ElemType(elemCode=CAX4I, elemLibrary=STANDARD))) self.soilPart.seedEdgeBySize( edges=self.soilPart.sets["All_Vertical_Edges"].edges, size=self.mesh_size, constraint=FIXED) self.soilPart.seedEdgeBySize( edges=self.soilPart.sets["Finite_Horizontal_Edges"].edges, size=self.mesh_size, constraint=FIXED) self.soilPart.seedEdgeBySize(edges=(self.soilPart.edges.findAt( (0.01, 0, 0)), ), size=self.mesh_size) self.soilPart.seedEdgeByNumber( edges=self.soilPart.sets["Single_Seed_Edges"].edges, number=1, constraint=FIXED) self.soilPart.generateMesh()
def _generate_mesh(self, part_longerons): # seed part part_longerons.seedPart(size=self.mesh_size, deviationFactor=self.mesh_deviation_factor, minSizeFactor=self.mesh_min_size_factor, constraint=FINER) # assign element type elem_type_longerons = mesh.ElemType(elemCode=self.element_code) part_longerons.setElementType(regions=(part_longerons.edges, ), elemTypes=(elem_type_longerons, )) # generate mesh part_longerons.generateMesh()
def shellTo3DExtruGeo(myModel, extrusionDepth=5., seedSize=0.5): ''' shellTo3DExtruGeo is the function to be called from abaqus cae mandatory arguments: myModel: an abaqus model (model produced with scanIP and imported in abaqus) optional arguments: extrusionDepth: the extrusion depth (default is 5.) seedSize: the relative size of the new mesh points (0.5 means there will be two seeds per geometrical line ie one new element edge per old element edge at the boundaries) ''' ## load needed abaqus constants from abaqusConstants import THREE_D, DEFORMABLE_BODY, C3D8R, STANDARD, ENHANCED, SWEEP ## ELEMENT INTEGRATION elemType1 = mesh.ElemType(elemCode=C3D8R, elemLibrary=STANDARD, hourglassControl=ENHANCED) myAssembly = myModel.rootAssembly clearUnwantedNodes(myModel) myAssembly.regenerate() #needed to still have access to assembly node sets ## for each set that makes a shell, create a new part (by getting the external edges as Lines) and mesh it # those sets are assembly sets defined by scanIP --> loop over assembly instances and over sets in those instances for myInstance in myAssembly.instances.values(): for myISet in myInstance.sets.keys(): # find set which is a shell (each set will form a new part) if myISet.endswith('WITH_ZMIN'): # create a new sketch to create a new geometrical part mySketch = createSketch(myModel, myInstance.sets[myISet]) # create new part whose name will be 'nameOfTheCorrespondingScanIPMask_Geo' myNewPart = myModel.Part(name=myISet.split('_')[1] + '_Geo', dimensionality=THREE_D, type=DEFORMABLE_BODY) myNewPart.BaseSolidExtrude(sketch=mySketch, depth=extrusionDepth) # assign mesh controls and seeds myNewPart.setMeshControls(regions=(myNewPart.cells[0], ), technique=SWEEP) myNewPart.seedPart( size=seedSize) #, deviationFactor=0.1, minSizeFactor=0.1) # create new mesh myNewPart.generateMesh() myNewPart.setElementType(regions=(myNewPart.cells[0], ), elemTypes=(elemType1, )) del mySketch deleteOldFeatures(myModel) addPartsToAssembly(myModel)
def meshInstances(edgeSeedDensity, unitShort, instRef, myAsm): # Mesh the current part f_p = open(LOGDIR, "w") # define global element size as distance between opposite corners of assembly bounding box f_p.write("Meshing the model" + '\n') f_p.write("Mesh size will be determined by using the distance between " + \ "opposite corners of each parts bounding box" + '\n') try: # mesh instances f_p.write("Meshing each part" + '\n') f_p.write('\n') for key in myAsm.instances.keys(): myInst = myAsm.instances[key] entry = instRef[key] region = myInst.cells regionBox = region.getBoundingBox() boxCorner1 = array(regionBox['low']) boxCorner2 = array(regionBox['high']) seedSize = LA.norm(boxCorner2 - boxCorner1) / edgeSeedDensity f_p.write( str(key) + " element size: " + str(seedSize) + " " + str(unitShort) + "\n") regionMask = region.getMask() regionPick = region.getSequenceFromMask(mask=regionMask) elemType = mesh.ElemType(elemCode=C3D10, elemLibrary=STANDARD) myAsm.setMeshControls(regions=regionPick, elemShape=TET, technique=FREE) myAsm.setElementType(regions=(regionPick, ), elemTypes=(elemType, )) myAsm.seedPartInstance(regions=(myInst, ), size=seedSize, constraint=FINER) myAsm.generateMesh(regions=(myInst, ), meshTechniqueOverride=ON, seedConstraintOverride=ON) except Exception as e: f_p.write(STR.join(traceback.format_exception(*sys.exc_info()))) f_p.write('ERROR: Error during seeding and meshing\n') f_p.write( ' Unmeshable parts or parts with invalid geometry might be present\n' ) raise f_p.close()
def mesh_column(): import section import regionToolset import displayGroupMdbToolset as dgm import part import material import assembly import step import interaction import load import mesh import optimization import job import sketch import visualization import xyPlot import displayGroupOdbToolset as dgo import connectorBehavior session.viewports['Viewport: 1'].view.setValues(nearPlane=227.297, farPlane=407.149, width=168.966, height=94.0822, cameraPosition=( -197.033, -113.771, 243.762), cameraUpVector=(0.57938, 0.692318, 0.430132), cameraTarget=(4.12772, 0.726357, 31.758), viewOffsetX=-7.57213, viewOffsetY=-6.06154) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['column-1'].cells pickedRegions = c1.getSequenceFromMask(mask=('[#2 ]', ), ) a.setMeshControls(regions=pickedRegions, elemShape=TET, technique=FREE) elemType1 = mesh.ElemType(elemCode=C3D20R) elemType2 = mesh.ElemType(elemCode=C3D15) elemType3 = mesh.ElemType(elemCode=C3D10) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['column-1'].cells cells = c1.getSequenceFromMask(mask=('[#2 ]', ), ) pickedRegions =(cells, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) i1 = mdb.models['3D_MODEL'].rootAssembly.allInstances['soil-1'] leaf = dgm.LeafFromInstance(instances=(i1, )) session.viewports['Viewport: 1'].assemblyDisplay.displayGroup.remove(leaf=leaf) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['column-1'].cells pickedRegions = c1.getSequenceFromMask(mask=('[#3 ]', ), ) a.setMeshControls(regions=pickedRegions, elemShape=HEX, technique=SWEEP, algorithm=MEDIAL_AXIS) elemType1 = mesh.ElemType(elemCode=C3D8R) elemType2 = mesh.ElemType(elemCode=C3D6) elemType3 = mesh.ElemType(elemCode=C3D4) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['column-1'].cells cells = c1.getSequenceFromMask(mask=('[#3 ]', ), ) pickedRegions =(cells, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3))
def createProjectileMesh(self): for part in self.projectileComponents: part = mdb.models[self.modelName].parts[part] # Make projectile's part TET free meshed - more refined meshes have to be applied manually part_cells = part.cells.getSequenceFromMask( mask= ( '[#1 ]', ), ) part.setMeshControls( regions=part_cells, elemShape=TET, technique=FREE ) # Seed part with default mesh element size part.seedPart( size=self.meshElementSize, deviationFactor=0.1, minSizeFactor=0.1 ) # Assign part C3D4T explicit element type part.setElementType( regions=( part_cells, ), elemTypes=( mesh.ElemType( elemCode=C3D4T, elemLibrary=EXPLICIT, secondOrderAccuracy=OFF, elemDeletion=ON, maxDegradation=0.99 ), ) ) # Mesh part part.generateMesh()
def infinite_elements(fixed_sides): # assign local seed number = 1 (not used now) # --> eventually needed in case of larger infinite elements # sweep mesh a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['soil-1'].cells pickedRegions = c1.getSequenceFromMask(mask=('[#3c ]', ), ) a.setMeshControls(regions=pickedRegions, technique=SWEEP, algorithm=ADVANCING_FRONT) # sweep path a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['soil-1'].cells e1 = a.instances['soil-1'].edges a.setSweepPath(region=c1[2], edge=e1[20], sense=FORWARD) a = mdb.models['3D_MODEL'].rootAssembly c11 = a.instances['soil-1'].cells e11 = a.instances['soil-1'].edges a.setSweepPath(region=c11[3], edge=e11[30], sense=REVERSE) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['soil-1'].cells e1 = a.instances['soil-1'].edges a.setSweepPath(region=c1[4], edge=e1[30], sense=REVERSE) a = mdb.models['3D_MODEL'].rootAssembly c11 = a.instances['soil-1'].cells e11 = a.instances['soil-1'].edges a.setSweepPath(region=c11[5], edge=e11[34], sense=REVERSE) if fixed_sides: elemType1 = mesh.ElemType(elemCode=C3D20R) elemType2 = mesh.ElemType(elemCode=C3D15) elemType3 = mesh.ElemType(elemCode=C3D10) else: # assign acoustic element elemType1 = mesh.ElemType(elemCode=AC3D8, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=AC3D6, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=AC3D4, elemLibrary=STANDARD) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['soil-1'].cells cells1 = c1.getSequenceFromMask(mask=('[#3c ]', ), ) pickedRegions = (cells1, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3))
def assign_properties(infinite_bottom): # column # hex meshing a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['column-1'].cells pickedRegions = c1.getSequenceFromMask(mask=('[#3 ]', ), ) a.setMeshControls(regions=pickedRegions, elemShape=HEX, technique=SWEEP, algorithm=MEDIAL_AXIS) # C3D elements elemType1 = mesh.ElemType(elemCode=C3D8) elemType2 = mesh.ElemType(elemCode=C3D6) elemType3 = mesh.ElemType(elemCode=C3D4) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['column-1'].cells cells = c1.getSequenceFromMask(mask=('[#3 ]', ), ) pickedRegions = (cells, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) # finite soil # tet meshing a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['soil-1'].cells pickedRegions = c1.getSequenceFromMask(mask=('[#3 ]', ), ) a.setMeshControls(regions=pickedRegions, elemShape=TET, technique=FREE) # C3D elements elemType1 = mesh.ElemType(elemCode=C3D8) elemType2 = mesh.ElemType(elemCode=C3D6) elemType3 = mesh.ElemType(elemCode=C3D4) a = mdb.models['3D_MODEL'].rootAssembly c1 = a.instances['soil-1'].cells cells = c1.getSequenceFromMask(mask=('[#3 ]', ), ) pickedRegions = (cells, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) #, algorithm=MEDIAL_AXIS '''