Parvez Ahmed
Parvez Ahmed

Reputation: 19

Selecting multiple partitioned regions in ABAQUS with findAt for setting mesh controls

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:

  1. 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)  
    
  2. 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.

Upvotes: 0

Views: 7006

Answers (2)

Parvez Ahmed
Parvez Ahmed

Reputation: 19

Anyone looking for a better understanding of this question, I'd first of all, advise to look up on my other linked question.

I solved this problem of mine by using getByBoundingBoxwhich has the following syntax: getByBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax)

So, this can be conveniently used instead of findAt() to select a large number of partitioned faces or also edges.

So taking a planar rectangle for example, having the four corners as (0.0, 0.0, 0.0), (2.0, 0.0, 0.0), (2.0, 2.0, 0.0) and (0.0, 2.0, 0.0) respectively and let's assume that there are multiple partitioned faces inside this rectangle which all need to be selected at once as one does in the GUI. First, the six arguments of the getByBoundingBox will be:

xmin = 0.0, 
ymin = 0.0, 
zmin = 0.0, 
xmax = 2.0, 
ymax = 2.0, 
zmax = 0.0

Then, it's just a matter of picking the desired region as follows:

pickedRegions = f.getByBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax) 

Upvotes: 0

agentp
agentp

Reputation: 6989

try this, use findAt on each individual point and add the results:

    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,),)

Upvotes: 2

Related Questions