Mesh

Solid brick

Most commonly, a mesh is generated by the method

mdb.models[modelname].parts[partname].generateMesh()

The algorithm of the method will create the mesh based on a number of parameters and settings. For example, the size of elements is defined by the method

mdb.models[modelname].parts[partname].seedPart(...)

as demonstrated in the simple script below, creating the meshed brick in the figure to the right.

Example: a solid brick

In [ ]:
from abaqus import *
from abaqusConstants import *

def solidBrick(modelname, L, b, h, esize):
    mod = mdb.Model(name=modelname)
    ske = mod.ConstrainedSketch(name='__profile__', sheetSize=200.0)
    ske.rectangle(point1=(0.0, 0.0), point2=(L, b))
    prt = mod.Part(name='Brick', dimensionality=THREE_D, type=DEFORMABLE_BODY)
    prt.BaseSolidExtrude(sketch=ske, depth=h)
    del ske
    session.viewports['Viewport: 1'].setValues(displayedObject=prt)

    # Mesh

    prt.seedPart(size=esize)
    prt.generateMesh()
    
solidBrick(modelname='M1', L=100.0, b=50.0, h=25.0, esize = 10.0)

The part will now contain elements and nodes in respective sequences

>>> prt = mdb.models['M1'].parts['Brick']
>>> len(prt.elements)
150
>>> len(prt.nodes)
264

as well as other mesh related sequences

>>> len(prt.elemEdges)
3600
>>> len(prt.elemFaces)
900

Element type per region, for instance for the single cell of the part:

>>> prt.getElementType(region = prt.cells[0], elemShape=HEX)
ElemType(elemCode=C3D8R, elemLibrary=STANDARD)

Properties of one element:

>>> print prt.elements[0]
({'connectivity': (24, 25, 31, 30, 0, 1, 7, 6), 'instanceName': None, 'label': 1, 'type': C3D8R})

and a node:

>>> print prt.nodes[0]
({'coordinates': (100.0, 50.0, 25.0), 'instanceName': None, 'label': 1})

Examples of methods for elements and nodes:

>>> adjelem = prt.elements[0].getAdjacentElements()
>>> print adjelem
['MeshElement object', 'MeshElement object', 'MeshElement object']
>>> 
>>> enodes = prt.elements[0].getNodes()
>>> print len(enodes)
8
>>> print enodes[0]
({'coordinates': (90.0, 50.0, 25.0), 'instanceName': None, 'label': 25})
>>> print enodes[0].getElements()
(mdb.models['M1'].parts['Brick'].elements[0], mdb.models['M1'].parts['Brick'].elements[15])
>>>

Example: make a random messy mesh

Solid brick

Just to demonstrate one of the many possible ways to modify a mesh: let's move individual nodes randomly in x, y, and z directions with mangnitudes less than half of the element size using the method part.editNode(...).

Add the following lines of code to the previous function:

# Random adjustments of nodes

from numpy import random
for i in range(0, len(prt.nodes)):
    dx, dy, dz = (esize/2.0)*random.random(3)
    prt.editNode(nodes = prt.nodes[i:i+1], offset1=dx, offset2=dy, offset3=dz)

Advanced mesh techniques and settings

It is frequently required to controll the number of elements along individual edges. The following script selects edges along x, y and z and defines the number of elements ( nex, ney and nez ) along these edges.

The method for selecting the edges is described in Selection methods.

In [ ]:
from abaqus import *
from abaqusConstants import *
from part import EdgeArray      # required for converting from a list to a sequence of proper type

def solidBrick(modelname, L, b, h, nex, ney, nez):
    mod = mdb.Model(name=modelname)
    ske = mod.ConstrainedSketch(name='__profile__', sheetSize=200.0)
    ske.rectangle(point1=(0.0, 0.0), point2=(L, b))
    prt = mod.Part(name='Brick', dimensionality=THREE_D, type=DEFORMABLE_BODY)
    prt.BaseSolidExtrude(sketch=ske, depth=h)
    del ske
    session.viewports['Viewport: 1'].setValues(displayedObject=prt)

    # Select edges
    edges_x = EdgeArray([e for e in prt.edges if e.pointOn[0][0] > 0.0 and e.pointOn[0][0] < L])
    edges_y = EdgeArray([e for e in prt.edges if e.pointOn[0][1] > 0.0 and e.pointOn[0][1] < b])
    edges_z = EdgeArray([e for e in prt.edges if e.pointOn[0][2] > 0.0 and e.pointOn[0][2] < h])
    
    # Seed and mesh
    prt.seedEdgeByNumber(edges=edges_x, number=nex, constraint=FINER)
    prt.seedEdgeByNumber(edges=edges_y, number=ney, constraint=FINER)
    prt.seedEdgeByNumber(edges=edges_z, number=nez, constraint=FINER)

    prt.generateMesh() 

solidBrick(modelname='M1', L=100.0, b=50.0, h=25.0, nex=10, ney=5, nez=12)

More advanced techniques in the following examples:

  • TODO
  • TODO
  • TODO
TOC Next Prev

Disclaimer:This site is designed for educational purposes only. There are most likely errors, mistakes, typos, and poorly crafted statements that are not detected yet... www.ntnu.edu/employees/nils.p.vedvik

Copyright 2024, All rights reserved