0

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.

Community
  • 1
  • 1
Parvez Ahmed
  • 19
  • 2
  • 7
  • `getBoundingBox is for seeing the size of a box containing your face(s). `getByBoundingBox is for selecting face(s) within a box. `getByBoundingBox takes xMax=20, xMin=1, yMax=88, etc as its inputs - i really think that would be a better way to do this, but not sure without seeing what you want. – will Aug 09 '16 at 17:57
  • if you want help on the error - 1) please put the exact error 2) have you tested this with the simplest possible case or manually used f.findAt - are you sure you don't have a tuple of tuple of tuples. – will Aug 09 '16 at 18:00
  • @ will: in this link, you'll see what I am trying to do. I have partitioned the entire body in small blocks and now, i'm trying to set mesh controls in each and every partitioned cell. http://stackoverflow.com/questions/38625874/faster-way-to-partition-a-face-with-sketch-in-abaqus-with-scripting . I have tried implementing both the functions in a simple rectangular block and the 2nd function doesn't work. The problem seems to be the setting up of the tuple somehow. – Parvez Ahmed Aug 09 '16 at 21:40
  • Here's the error notification from ABAQUS: "...in set_mesh_control_structured; pickedRegions = f.findAt(regions_tuple); TypeError: arg1(coordinates)[0][0];found tuple expecting float" – Parvez Ahmed Aug 09 '16 at 21:40
  • It seems like you have created many faces and you want each face to have a just one element - why don't you just set the part/instance seed size to a big number, and that way every face will get 1 element? – will Aug 10 '16 at 13:45
  • The way i have partitioned, that was the only way i saw which suited the purpose of achieving the kind of transition mapped quad meshing as shown in the image. I tried other ways without any success. Anyways, i tried `getByBoundingBox` and this functioned perfectly.. Thanks for the pointer.. – Parvez Ahmed Aug 10 '16 at 18:20
  • you should write it up as an answer. – agentp Aug 10 '16 at 18:53
  • good that you have found a solution. I still wonder if after all your partioning into the neat steps of transitions - if you assign a very large seed size, then you would get 1 element per face? – will Aug 11 '16 at 19:40
  • Sorry for the delayed response. I'm always getting one element per face. Can you please elaborate on what you think I'm doing wrong? Even though i'm getting the required results, I'm not quite sure about my method either. So, it'll be really cool if you could point me to a better and easier method of getting the required transition meshing which doesn't need me to partition the entire body the way I've done so far. Cheers.. – Parvez Ahmed Aug 13 '16 at 20:51

2 Answers2

2

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,),)
agentp
  • 6,849
  • 2
  • 19
  • 37
  • @ agentp: This is a very reasonable and smart solution. Thanks a lot again. By the way, what do you think is better in this case: using findAt or getByBoundingBox? – Parvez Ahmed Aug 09 '16 at 22:48
  • I've never used `getByBoundingBox`. It would be interesting to see if its faster, since obviously it could be more convenient. – agentp Aug 10 '16 at 00:21
  • I just tried the `getByBoundingBox` approach and it worked like a charm. It's far more easier, faster and comprehensive than using `findAt()`.. – Parvez Ahmed Aug 10 '16 at 18:27
0

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) 
Parvez Ahmed
  • 19
  • 2
  • 7