コード例 #1
0
    def __init__(self, comm, tacs_comm, model, n_tacs_procs):
        super(OneraPlate, self).__init__(comm, tacs_comm, model)

        assembler = None
        mat = None

        if comm.Get_rank() < n_tacs_procs:
            # Set the creator object
            ndof = 6
            creator = TACS.Creator(tacs_comm, ndof)

            if tacs_comm.rank == 0:
                # Create the elements
                nx = 10
                ny = 10

                # Set the nodes
                nnodes = (nx+1)*(ny+1)
                nelems = nx*ny
                nodes = np.arange(nnodes).reshape((nx+1, ny+1))

                conn = []
                for j in range(ny):
                    for i in range(nx):
                        # Append the node locations
                        conn.append([nodes[i, j],
                                     nodes[i+1, j],
                                     nodes[i, j+1],
                                     nodes[i+1, j+1]])

                # Set the node pointers
                conn = np.array(conn, dtype=np.intc).flatten()
                ptr = np.arange(0, 4*nelems+1, 4, dtype=np.intc)
                elem_ids = np.zeros(nelems, dtype=np.intc)
                creator.setGlobalConnectivity(nnodes, ptr, conn, elem_ids)

                # Set the boundary conditions - fixed on the root
                bcnodes = np.array(nodes[:, 0], dtype=np.intc)
                creator.setBoundaryConditions(bcnodes)

                root_chord = 0.8
                semi_span = 1.2
                taper_ratio = 0.56
                sweep = 26.7 # degrees

                # Set the node locations
                Xpts = np.zeros(3*nnodes)
                x = np.linspace(0, 1, nx+1)
                y = np.linspace(0, 1, ny+1)
                for j in range(ny+1):
                    for i in range(nx+1):
                        c = root_chord*(1.0 - y[j]) + root_chord*taper_ratio*y[j]
                        xoff = 0.25*root_chord + semi_span*y[j]*np.tan(sweep*np.pi/180.0)

                        Xpts[3*nodes[i,j]] = xoff + c*(x[i] - 0.25)
                        Xpts[3*nodes[i,j]+1] = semi_span*y[j]

                # Set the node locations
                creator.setNodes(Xpts)

            # Set the material properties
            props = constitutive.MaterialProperties(rho=2570.0, E=70e9, nu=0.3, ys=350e6)

            # Set constitutive properties
            t = 0.025
            tnum = 0
            maxt = 0.015
            mint = 0.015
            con = constitutive.IsoShellConstitutive(props, t=t, tNum=tnum)

            # Create a transformation object
            transform = elements.ShellNaturalTransform()

            # Create the element object
            element = elements.Quad4Shell(transform, con)

            # Set the elements
            elems = [ element ]
            creator.setElements(elems)

            # Create TACS Assembler object from the mesh loader
            assembler = creator.createTACS()

            # Create distributed matrix
            mat = assembler.createSchurMat()  # stiffness matrix

        self._initialize_variables(assembler, mat)

        self.initialize(model.scenarios[0], model.bodies)

        return
コード例 #2
0
for i in range(nquads):
    t = quads[i, 2]
    quads[i, 2] = quads[i, 3]
    quads[i, 3] = t

# Flatten the arrays
pts = pts.flatten()
quads = (quads.flatten()).astype(np.intc)

# Set the pointer to the connectivity array
ptr = np.arange(0, 4 * nquads + 1, 4, dtype=np.intc)
ids = np.arange(0, nquads, dtype=np.intc)

# Create the tacs creator
vars_per_node = 6
creator = TACS.Creator(comm, vars_per_node)
creator.setGlobalConnectivity(npts, ptr, quads, ids)
creator.setNodes(pts)

# Set constitutive properties
rho = 2500.0  # density, kg/m^3
E = 70e9  # elastic modulus, Pa
nu = 0.3  # poisson's ratio
kcorr = 5.0 / 6.0  # shear correction factor
ys = 350e6  # yield stress, Pa
min_thickness = 0.002
max_thickness = 0.20
thickness = 0.02

stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, thickness, 0,
                             min_thickness, max_thickness)
コード例 #3
0
ファイル: triangle.py プロジェクト: zxp-proteus/tacs
        # Compute the stresses
        s = np.zeros(e.shape)
        s[0] = self.D * (e[0] + self.nu * e[1])
        s[1] = self.D * (e[1] + self.nu * e[0])
        s[2] = self.G * e[2]

        # Compute the valure of the failure function
        fval = (s[0]**2 + s[1]**2 - s[0] * s[1] + 3 * s[2]**2) / self.ys**2

        return fval


# Allocate the TACS creator
comm = MPI.COMM_WORLD
creator = TACS.Creator(comm, 2)

# Create the stiffness object
rho = 2570.0
E = 70e9
nu = 0.3
ys = 350e6

# stiff = constitutive.PlaneStress(rho, E, nu)
stiff = PS(rho, E, nu, ys)

# Create the elements
elem_order = 2
elem = elements.PlaneTri6(stiff)

if comm.rank == 0:
コード例 #4
0
def create_structure(comm,
                     props,
                     xpts,
                     conn,
                     bcs,
                     aux,
                     m_fixed,
                     r0=4,
                     min_mat_fraction=-1.0,
                     bctypes=None):
    '''
    Create a structure with the speicified number of nodes along the
    x/y directions, respectively.
    '''

    # Set the number of design variables
    nnodes = len(xpts)
    nelems = len(conn)
    nmats = props.getNumMaterials()
    num_design_vars = (nmats + 1) * nelems

    # Create the TACS creator object
    creator = TACS.Creator(comm, 2)

    # Set up the mesh on the root processor
    if comm.rank == 0:
        # Set the node pointers
        ptr = np.arange(0, 4 * nelems + 1, 4, dtype=np.intc)
        elem_ids = np.arange(nelems, dtype=np.intc)
        creator.setGlobalConnectivity(nnodes, ptr, conn.flatten(), elem_ids)

        # Set up the boundary conditions
        bcnodes = np.array(bcs, dtype=np.intc)

        # Set the boundary condition variables
        if bctypes is None:
            nbcs = 2 * bcnodes.shape[0]
            bcvars = np.zeros(nbcs, dtype=np.intc)
            bcvars[:nbcs:2] = 0
            bcvars[1:nbcs:2] = 1

            # Set the boundary condition pointers
            bcptr = np.arange(0, nbcs + 1, 2, dtype=np.intc)
        else:
            bcvars = []
            bcptr = [0]
            for btype in bctypes:
                if btype & 1:
                    bcvars.append(0)
                if btype & 2:
                    bcvars.append(1)
                bcptr.append(len(bcvars))
            bcvars = np.array(bcvars, dtype=np.intc)
            bcptr = np.array(bcptr, dtype=np.intc)
        creator.setBoundaryConditions(bcnodes, bcptr, bcvars)

        # Set the node locations
        creator.setNodes(xpts.flatten())

    # Create the filter and the elements for each point
    elems = []
    const = []
    xcentroid = np.zeros((nelems, 3))
    for i in range(nelems):
        xcentroid[i] = 0.25 * (xpts[conn[i, 0]] + xpts[conn[i, 1]] +
                               xpts[conn[i, 2]] + xpts[conn[i, 3]])

    # Find the closest points
    locator = multitopo.Locator(xcentroid)
    max_points = 15
    for i in range(nelems):
        # Get the closest points to the centroid of this element
        nodes, dist = locator.closest(xcentroid[i], max_points)
        index = 0
        while index < max_points and dist[index] < r0:
            index += 1

        # Create the filter weights
        nodes = nodes[:index]
        weights = ((r0 - dist[:index]) / r0)**2
        weights = weights / np.sum(weights)

        # Create the plane stress object
        ps = multitopo.MultiTopo(props, nodes, weights)
        const.append(ps)
        elems.append(elements.PlaneQuad(2, ps))

    # Set the elements
    creator.setElements(elems)

    # Create the tacs assembler object
    tacs = creator.createTACS()

    # Retrieve the element partition
    if comm.rank == 0:
        partition = creator.getElementPartition()

        # Broadcast the partition
        comm.bcast(partition, root=0)
    else:
        partition = comm.bcast(root=0)

    # Add the auxiliary element class to TACS
    tacs.setAuxElements(aux)

    # Create the analysis object
    analysis = TACSAnalysis(comm,
                            props,
                            tacs,
                            const,
                            nmats,
                            conn=conn,
                            xpts=xpts,
                            m_fixed=m_fixed,
                            min_mat_fraction=min_mat_fraction)

    return analysis