예제 #1
0
def rectangular_domain(nx, ny, Ly=100.0):

    # Set the y-dimension based on a unit aspect ratio
    Lx = (nx*Ly)/ny

    # Compute the total area
    area = Lx*Ly
    
    # Set the number of elements/nodes in the problem
    nnodes = (nx+1)*(ny+1)
    nelems = nx*ny
    nodes = np.arange(nnodes).reshape((nx+1, ny+1))          

    # Set the node locations
    xpts = np.zeros((nnodes, 3))
    x = np.linspace(0, Lx, nx+1)
    y = np.linspace(0, Ly, ny+1)
    for j in range(ny+1):
        for i in range(nx+1):
            xpts[nodes[i,j],0] = x[i]
            xpts[nodes[i,j],1] = y[j]

    # Set the connectivity and create the corresponding elements
    conn = np.zeros((nelems, 4), dtype=np.intc)
    for j in range(ny):
        for i in range(nx):
            # Append the first set of nodes
            n = i + nx*j
            conn[n,0] = nodes[i, j]
            conn[n,1] = nodes[i+1, j]
            conn[n,2] = nodes[i, j+1]
            conn[n,3] = nodes[i+1, j+1]

    bcs = np.array(nodes[0,:], dtype=np.intc)
            
    # Create the tractions and add them to the surface
    surf = 1 # The u=1 positive surface
    tx = np.zeros(2)
    ty = -100*np.ones(2)
    trac = elements.PSQuadTraction(surf, tx, ty)

    # Create the auxiliary element class    
    aux = TACS.AuxElements()
    for j in range(int(ny/8)):
        num = nx-1 + nx*j
        aux.addElement(num, trac)
        
    return xpts, conn, bcs, aux, area
예제 #2
0
def addEdgeTraction(order, forest, attr, assembler, tr):
    trac = []

    for findex in range(4):
        trac.append(elements.PSQuadTraction(findex, tr[0]*np.ones(2), \
                                            tr[1]*np.ones(2)))

    # Retrieve octants from the forest
    quadrants = forest.getQuadrants()
    edge_quads = forest.getQuadsWithAttribute(attr)
    aux = TACS.AuxElements()

    for i in range(len(edge_quads)):
        index = quadrants.findIndex(edge_quads[i])
        if index is not None:
            aux.addElement(index, trac[edge_quads[i].tag])

    return aux
예제 #3
0
파일: topo_adapt.py 프로젝트: xyuan/tmr
def addFaceTraction(order, forest, assembler):
    # Get the quadrilaterals of interest
    quads = forest.getQuadsWithName('traction')

    # Create the surface traction
    aux = TACS.AuxElements()

    # Loop over the nodes and create the traction forces in the x/y/z
    # directions
    nnodes = order
    tx = np.zeros(nnodes, dtype=TACS.dtype)
    ty = np.zeros(nnodes, dtype=TACS.dtype)
    ty[:] = 10.0

    # Create the shell traction
    surf = 1
    trac = elements.PSQuadTraction(surf, tx, ty)
    for q in quads:
        aux.addElement(q.tag, trac)

    return aux
예제 #4
0
def bracket_domain(nb, nc, Lx=100.0):
    # Compute the total area
    area = 0.64 * Lx**2

    # The total number of elements along one direction
    nx = nb + nc

    # Allocate all of the nodes (including blanked nodes)
    nodes = np.ones((nx + 1, nx + 1), dtype=np.int)
    nodes[nb + 1:, nb + 1:] = -1

    # Allocate all of the elements (including blanked elements)
    elems = np.ones((nx, nx), dtype=np.int)
    elems[nb:, nb:] = -1

    # Number the nodes
    index = 0
    for j in range(nx + 1):
        for i in range(nx + 1):
            if nodes[i, j] >= 0:
                nodes[i, j] = index
                index += 1

    # Set the element numbering
    index = 0
    for j in range(nx):
        for i in range(nx):
            if elems[i, j] >= 0:
                elems[i, j] = index
                index += 1

    # Set the boundary conditions
    bcs = np.array(nodes[:(nb + 1), -1], dtype=np.intc)

    # Compute the number of nodes and elements
    n = (nb + 1)**2 + 2 * (nb + 1) * nc
    ne = nb**2 + 2 * nb * nc

    # Allocate the arrays
    conn = np.zeros((ne, 4), dtype=np.intc)
    xpts = np.zeros((n, 3))

    # Set the node locations
    for j in range(nx + 1):
        for i in range(nx + 1):
            if nodes[i, j] >= 0:
                xpts[nodes[i, j], 0] = (Lx * i) / nx
                xpts[nodes[i, j], 1] = (Lx * j) / nx

    # Set the nodal connectivity
    for j in range(nx):
        for i in range(nx):
            if elems[i, j] >= 0:
                conn[elems[i, j], 0] = nodes[i, j]
                conn[elems[i, j], 1] = nodes[i + 1, j]
                conn[elems[i, j], 2] = nodes[i, j + 1]
                conn[elems[i, j], 3] = nodes[i + 1, j + 1]

    # Create the tractions and add them to the surface
    surf = 1  # The u=1 positive surface
    tx = np.zeros(2)
    ty = 100 * np.ones(2)
    trac = elements.PSQuadTraction(surf, tx, ty)

    # Create the auxiliary element class
    aux = TACS.AuxElements()
    for j in range(int(5 * nb / 6), nb):
        aux.addElement(elems[-1, j], trac)

    return xpts, conn, bcs, aux, area
예제 #5
0
    bctypes = np.zeros(ny + 2, dtype=np.intc)

    # Set the boundary conditions along the left-edge
    for j in range(ny + 1):
        bcs[j] = j
        bctypes[j] = 1

    # Set the lower-right node
    bcs[-1] = nx * (ny + 1)
    bctypes[-1] = 2

    # Set the new auxiliary elements for forces
    surf = 3  # The v=1 positive surface
    tx = np.zeros(2)
    ty = -100 * np.ones(2)
    trac = elements.PSQuadTraction(surf, tx, ty)

    # Create the auxiliary element class
    aux = TACS.AuxElements()
    for i in range(int(nx / 18)):
        num = nx * (ny - 1) + i
        aux.addElement(num, trac)
elif problem_type == 'bridge':
    # Set the objective scaling factor
    obj_scale_factor = 1.0

    # Set the domain size
    nx = 180
    ny = 90
    xpts, conn, bcs, aux, area = rectangular_domain(nx, ny)
    r0 = np.sqrt(4.99) * np.sqrt(area / len(conn))