With reference to my previous question,
Faster way to partition a Face with Sketch in ABAQUS with scripting,
I have to select the multiple regions created by the partitioning method to assign the mesh controls and seed the edges and finally, mesh the regions respectively.
Problem is, since the partitioned regions are parametrised and of such a greater number, defining a function for the purpose and running it in a loop was the only way that seemed fit to me. Hence, I tried to define a function in two different ways like so:
A function is defined to select the regions and run in a loop throughout the length of the body. Here, each small region is picked once and the same mesh controls are applied repeatedly leading to a long time in generating the mesh.
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)
The second function tries to select all the regions one by one and then apply the mesh controls at the end only once. This is where the problem creeps up. One assumes that the argument for findAt() is a tuple of tuples but it doesn't work and ABAQUS gives an error warning saying that "...in set_mesh_control_structured; pickedRegions = f.findAt(regions_tuple); TypeError: arg1(coordinates)[0][0];found 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)
Can anyone please tell me what I'm doing wrong in the second function definition or is there a better way to select multiple regions for the purpose of setting mesh controls and seeding apart from findAt()? I am aware of getBoundingBox and faces.index[#] etc. but I have no clue on how to use them. So, a MWE will also be highly appreciated.
Thanks a lot in advance.