Пример #1
0
 def createElement(self, order, quad):
     '''Create the element'''
     tmin = 0.0
     tmax = 1e6
     tnum = quad.tag
     stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, t,
                                  tnum, tmin, tmax)
     elem = elements.MITCShell(order, stiff)
     return elem
Пример #2
0
    def createElement(self, order, quad):
        # Set constitutive properties
        rho = 2500.0  # density, kg/m^3
        E = 70e3  # elastic modulus, Pa
        nu = 0.3  # poisson's ratio
        kcorr = 5.0 / 6.0  # shear correction factor
        ys = 350e3  # yield stress, Pa
        min_thickness = 0.2
        max_thickness = 1.0
        thickness = 2.5

        stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, thickness,
                                     quad.face, min_thickness, max_thickness)
        stiff.setRefAxis(np.array([1.0, 0.0, 0.0]))

        element = None
        if order == 2:
            element = elements.MITCShell(2, stiff)
        elif order == 3:
            element = elements.MITCShell(3, stiff)
        elif order == 4:
            element = elements.MITCShell(4, stiff)
        return element
Пример #3
0
    def createElement(self, order, quad):
        # Set constitutive properties
        rho = 0.102  # density, lb/in^3
        E = 10e6  # elastic modulus, psi
        nu = 0.3  # poisson's ratio
        kcorr = 5.0 / 6.0  # shear correction factor
        ys = 73e3  # yield stress, psi
        min_thickness = 0.2
        max_thickness = 1.0
        thickness = 0.5  # in

        stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, thickness,
                                     quad.face, min_thickness, max_thickness)

        theta = 30.0 * np.pi / 180.0
        stiff.setRefAxis(np.array([np.sin(theta), np.cos(theta), 0.0]))
        element = None
        if order == 2:
            element = elements.MITCShell(2, stiff)
        elif order == 3:
            element = elements.MITCShell(3, stiff)

        return element
Пример #4
0
    def createElement(self, order, quad):
        '''Create the element'''
        tmin = 0.0
        tmax = 1e6
        tnum = quad.tag
        stiff = ksFSDT.ksFSDT(ksweight, density, E, nu, kcorr, ys, t, tnum,
                              tmin, tmax)
        if self.case == 'cylinder':
            stiff.setRefAxis(np.array([0.0, 0.0, 1.0]))
        elif self.case == 'disk':
            stiff.setRefAxis(np.array([1.0, 0.0, 0.0]))

        elem = elements.MITCShell(order, stiff)
        return elem
Пример #5
0
nu = 0.3  # poisson's ratio
kcorr = 5.0 / 6.0  # shear correction factor
ys = 350e6  # yield stress, Pa
min_thickness = 0.001
max_thickness = 0.020
thickness = 0.005

# Loop over components, creating stiffness and element object for each
num_components = struct_mesh.getNumComponents()
for i in range(num_components):
    descriptor = struct_mesh.getElementDescript(i)
    stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, thickness, i,
                                 min_thickness, max_thickness)
    element = None
    if descriptor in ["CQUAD", "CQUADR", "CQUAD4"]:
        element = elements.MITCShell(2, stiff, component_num=i)
    struct_mesh.setElement(i, element)

# Create tacs assembler object
tacs = struct_mesh.createTACS(6)
res = tacs.createVec()
ans = tacs.createVec()
mat = tacs.createFEMat()

# Create distributed node vector from TACS Assembler object and extract the
# nodes
struct_X_vec = tacs.createNodeVec()
tacs.getNodes(struct_X_vec)
struct_X = struct_X_vec.getArray()
struct_nnodes = len(struct_X) / 3
Пример #6
0
    def __init__(self, comm, bdf_name):
        self.comm = comm
        struct_mesh = TACS.MeshLoader(self.comm)
        struct_mesh.scanBDFFile(bdf_name)

        # 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

        # Loop over components, creating stiffness and element object for each
        num_components = struct_mesh.getNumComponents()
        for i in range(num_components):
            descriptor = struct_mesh.getElementDescript(i)

            # Set the design variable index
            design_variable_index = i
            stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, thickness,
                                         design_variable_index, min_thickness,
                                         max_thickness)
            element = None

            # Create the element object
            if descriptor in ["CQUAD", "CQUADR", "CQUAD4"]:
                element = elements.MITCShell(2, stiff, component_num=i)
            struct_mesh.setElement(i, element)

        # Create tacs assembler object from mesh loader
        self.assembler = struct_mesh.createTACS(6)

        # Create the KS Function
        ksWeight = 50.0
        self.funcs = [
            functions.StructuralMass(self.assembler),
            functions.KSFailure(self.assembler, ksWeight)
        ]

        # Create the forces
        self.forces = self.assembler.createVec()
        force_array = self.forces.getArray()
        force_array[2::6] += 100.0  # uniform load in z direction
        self.assembler.applyBCs(self.forces)

        # Set up the solver
        self.ans = self.assembler.createVec()
        self.res = self.assembler.createVec()
        self.adjoint = self.assembler.createVec()
        self.dfdu = self.assembler.createVec()
        self.mat = self.assembler.createFEMat()
        self.pc = TACS.Pc(self.mat)
        subspace = 100
        restarts = 2
        self.gmres = TACS.KSM(self.mat, self.pc, subspace, restarts)

        # Scale the mass objective so that it is O(10)
        self.mass_scale = 1e-3

        # Scale the thickness variables so that they are measured in
        # mm rather than meters
        self.thickness_scale = 1000.0

        # The number of thickness variables in the problem
        self.nvars = num_components

        # The number of constraints (1 global stress constraint that
        # will use the KS function)
        self.ncon = 1

        # Initialize the base class - this will run the same problem
        # on all processors
        super(uCRM_VonMisesMassMin, self).__init__(MPI.COMM_SELF, self.nvars,
                                                   self.ncon)

        # Set the inequality options for this problem in ParOpt:
        # The dense constraints are inequalities c(x) >= 0 and
        # use both the upper/lower bounds
        self.setInequalityOptions(dense_ineq=True,
                                  use_lower=True,
                                  use_upper=True)

        # For visualization
        flag = (TACS.ToFH5.NODES | TACS.ToFH5.DISPLACEMENTS
                | TACS.ToFH5.STRAINS | TACS.ToFH5.EXTRAS)
        self.f5 = TACS.ToFH5(self.assembler, TACS.PY_SHELL, flag)
        self.iter_count = 0

        return
Пример #7
0
tacs = TACS.Assembler.create(comm, vars_per_node,
                             num_nodes, num_elements)

elems = []
elem_conn = []

# Add all the elements
for j in range(ny):
    for i in range(nx):
        # Create the shell element class
        dv_num = i + nx*j
        stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, t,
                                     dv_num, min_t, max_t)

        # stiff.setRefAxis([0.0, 1.0, 0.0])
        shell_element = elements.MITCShell(2, stiff)
        elems.append(shell_element)

        # Set the element connectivity
        elem_conn.append([i + (nx+1)*j, 
                          i+1 + (nx+1)*j,
                          i + (nx+1)*(j+1), 
                          i+1 + (nx+1)*(j+1)])
        
# Create the connectivity array
conn = np.array(elem_conn, dtype=np.intc).flatten()
ptr = np.arange(0, len(conn)+1, 4, dtype=np.intc)

# Set the connectivity and the elements
tacs.setElements(elems)
tacs.setElementConnectivity(conn, ptr)
Пример #8
0
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)

# Set the elements into TACS
elems = []
for i in range(nquads):
    elems.append(elements.MITCShell(2, stiff))

# Set the elements
creator.setElements(elems)

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

# Visualize it using FH5
flag = (TACS.ToFH5.NODES | TACS.ToFH5.DISPLACEMENTS | TACS.ToFH5.STRAINS)
f5 = TACS.ToFH5(tacs, TACS.PY_SHELL, flag)
f5.writeToFile('mesh.f5')
Пример #9
0
    def __init__(self,comm,tacs_comm,model,n_tacs_procs):
        super(CRMtacs,self).__init__(comm,tacs_comm,model)

        self.tacs_proc = False
        if comm.Get_rank() < n_tacs_procs:
            self.tacs_proc = True
            struct_mesh = TACS.MeshLoader(tacs_comm)
            struct_mesh.scanBDFFile("CRM_box_2nd.bdf")

            # Set constitutive properties
            rho = 2500.0  # density, kg/m^3
            E = 70.0e9 # 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.001
            max_thickness = 0.100

            thickness = 0.015
            spar_thick = 0.015

            # Loop over components in mesh, creating stiffness and element
            # object for each
            map = np.zeros(240,dtype=int)
            num_components = struct_mesh.getNumComponents()
            for i in range(num_components):
                descript = struct_mesh.getElementDescript(i)
                comp = struct_mesh.getComponentDescript(i)
                if 'SPAR' in comp:
                    t = spar_thick
                else:
                    t = thickness
                stiff = constitutive.isoFSDT(rho, E, nu, kcorr, ys, t, i,
                                             min_thickness, max_thickness)
                element = None
                if descript in ["CQUAD", "CQUADR", "CQUAD4"]:
                    element = elements.MITCShell(2,stiff,component_num=i)
                struct_mesh.setElement(i, element)

                # Create map
                if 'LE_SPAR' in comp:
                    segnum = int(comp[-2:])
                    map[i] = segnum
                if 'TE_SPAR' in comp:
                    segnum = int(comp[-2:])
                    map[i] = segnum + 48
                if 'IMPDISP' in comp:
                    map[i] = i
                elif 'RIB' in comp:
                    segnum = int(comp[-9:-7]) - 1
                    if segnum > 3:
                        segnum -= 1
                    map[i] = segnum + 188
                if 'U_SKIN' in comp:
                    segnum = int(comp[-9:-7]) - 1
                    map[i] = segnum + 92
                if 'L_SKIN' in comp:
                    segnum = int(comp[-9:-7]) - 1
                    map[i] = segnum + 140

            self.dof = 6

            # Create tacs assembler object
            tacs = struct_mesh.createTACS(self.dof)
            res = tacs.createVec()
            ans = tacs.createVec()
            mat = tacs.createFEMat()

            # Create distributed node vector from TACS Assembler object and
            # extract the node locations
            nbodies = 1
            struct_X = []
            struct_nnodes = []
            for body in range(nbodies):
                self.struct_X_vec = tacs.createNodeVec()
                tacs.getNodes(self.struct_X_vec)
                struct_X.append(self.struct_X_vec.getArray())
                struct_nnodes.append(len(struct_X) / 3)

            tacs.setNodes(self.struct_X_vec)

            # Create the preconditioner for the corresponding matrix
            pc = TACS.Pc(mat)

            alpha = 1.0
            beta = 0.0
            gamma = 0.0
            tacs.assembleJacobian(alpha,beta,gamma,res,mat)
            pc.factor()

            # Create GMRES object for structural adjoint solves
            nrestart = 0 # number of restarts before giving up
            m = 30 # size of Krylov subspace (max # of iterations)
            gmres = TACS.KSM(mat, pc, m, nrestart)


            # Initialize member variables pertaining to TACS
            self.tacs = tacs
            self.res = res
            self.ans = ans
            self.mat = mat
            self.pc = pc
            self.struct_X = struct_X
            self.struct_nnodes = struct_nnodes
            self.gmres = gmres
            self.svsens = tacs.createVec()
            self.struct_rhs_vec = tacs.createVec()
            self.psi_S_vec = tacs.createVec()
            psi_S = self.psi_S_vec.getArray()
            self.psi_S = np.zeros((psi_S.size,self.nfunc),dtype=TACS.dtype)
            self.ans_array = []
            for scenario in range(len(model.scenarios)):
                self.ans_array.append(self.ans.getArray().copy())
        self.initialize(model.scenarios[0],model.bodies)
Пример #10
0
Файл: crm.py Проект: xyuan/tmr
    if i in ucrm_ribs:
        stiff.setRefAxis(rib_dir)
    else:
        stiff.setRefAxis(skin_spar_dir)

    # Set the component number for visualization purposes
    comp = 0
    if i in ucrm_skins:
        comp = 1
    elif i in ucrm_ribs:
        comp = 2

    # Create the elements of different orders
    for j in range(4):
        elem_dict[j][attr] = elements.MITCShell(j + 2,
                                                stiff,
                                                component_num=comp)

# Initial target mesh spacing
htarget = args.htarget

# Create the new mesh
mesh = TMR.Mesh(comm, geo)

# Set the meshing options
opts = TMR.MeshOptions()

# Set the mesh type
# opts.mesh_type_default = TMR.TRIANGLE
opts.num_smoothing_steps = 10
opts.write_mesh_quality_histogram = 1