def createElement(self, order, quad): """ Create an element for the entire mesh """ if quad.tag in alum_tags: stiff = constitutive.PlaneStressConstitutive(alum_props) elif quad.tag in battery_tags: stiff = constitutive.PlaneStressConstitutive(battery_props) else: print("quad not defined") # Create the model model = elements.LinearThermoelasticity2D(stiff) # Set the basis functions and create the element if order == 2: basis = elements.LinearQuadBasis() elif order == 3: basis = elements.QuadraticQuadBasis() elif order == 4: basis = elements.CubicQuadBasis() elif order == 5: basis = elements.QuarticQuadBasis() elif order == 6: basis = elements.QuinticQuadBasis() # Create the element type element = elements.Element2D(model, basis) return element
def __init__(self, integrator_options, comm, tacs_comm, model, n_tacs_procs): self.tacs_proc = False if comm.Get_rank() < n_tacs_procs: self.tacs_proc = True # Set constitutive properties T_ref = 300.0 rho = 4540.0 # density, kg/m^3 E = 118e9 # elastic modulus, Pa nu = 0.325 # poisson's ratio ys = 1050e6 # yield stress, Pa kappa = 6.89 specific_heat = 463.0 thickness = 0.015 volume = 25 # need tacs volume for TACSAverageTemperature function # Create the constitutvie propertes and model props_plate = constitutive.MaterialProperties(rho=4540.0, specific_heat=463.0, kappa=6.89, E=118e9, nu=0.325, ys=1050e6) #con_plate = constitutive.ShellConstitutive(props_plate,thickness,1,0.01,0.10) #model_plate = elements.ThermoelasticPlateModel(con_plate) con_plate = constitutive.PlaneStressConstitutive(props_plate, t=1.0, tNum=0) model_plate = elements.HeatConduction2D(con_plate) # Create the basis class quad_basis = elements.LinearQuadBasis() # Create the element #element_shield = elements.Element2D(model_shield, quad_basis) #element_insulation = elements.Element2D(model_insulation, quad_basis) element_plate = elements.Element2D(model_plate, quad_basis) varsPerNode = model_plate.getVarsPerNode() # Load in the mesh mesh = TACS.MeshLoader(tacs_comm) mesh.scanBDFFile('tacs_aero.bdf') # Set the element mesh.setElement(0, element_plate) # Create the assembler object #varsPerNode = heat.getVarsPerNode() assembler = mesh.createTACS(varsPerNode) # 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 = assembler.createNodeVec() assembler.getNodes(self.struct_X_vec) struct_X.append(self.struct_X_vec.getArray()) struct_nnodes.append(len(struct_X) / 3) assembler.setNodes(self.struct_X_vec) # Initialize member variables pertaining to TACS self.T_ref = T_ref self.vol = volume self.assembler = assembler self.struct_X = struct_X self.struct_nnodes = struct_nnodes self.struct_rhs_vec = assembler.createVec() #self.psi_T_S_vec = assembler.createVec() #psi_T_S = self.psi_T_S_vec.getArray() #self.psi_T_S = np.zeros((psi_T_S.size,self.nfunc),dtype=TACS.dtype) self.ans = self.assembler.createVec() self.bvec_heat_flux = self.assembler.createVec() # Things for configuring time marching self.integrator = {} for scenario in model.scenarios: self.integrator[scenario.id] = self.createIntegrator( self.assembler, integrator_options) super(wedgeTACS, self).__init__(integrator_options, comm, tacs_comm, model) self.initialize(model.scenarios[0], model.bodies)
def __init__(self, comm, tacs_comm, model, n_tacs_procs): super(wedgeTACS, self).__init__(comm, tacs_comm, model) self.tacs_proc = False if comm.Get_rank() < n_tacs_procs: self.tacs_proc = True #mesh = TACS.MeshLoader(tacs_comm) #mesh.scanBDFFile("tacs_aero.bdf") # Set constitutive properties T_ref = 300.0 rho = 4540.0 # density, kg/m^3 E = 118e9 # elastic modulus, Pa nu = 0.325 # poisson's ratio ys = 1050e6 # yield stress, Pa kappa = 6.89 specific_heat = 463.0 thickness = 0.015 volume = 25 # need tacs volume for TACSAverageTemperature function # Create the constitutvie propertes and model props_plate = constitutive.MaterialProperties(rho=4540.0, specific_heat=463.0, kappa=6.89, E=118e9, nu=0.325, ys=1050e6) #con_plate = constitutive.ShellConstitutive(props_plate,thickness,1,0.01,0.10) #model_plate = elements.ThermoelasticPlateModel(con_plate) con_plate = constitutive.PlaneStressConstitutive(props_plate, t=1.0, tNum=0) model_plate = elements.HeatConduction2D(con_plate) # Create the basis class quad_basis = elements.LinearQuadBasis() # Create the element #element_shield = elements.Element2D(model_shield, quad_basis) #element_insulation = elements.Element2D(model_insulation, quad_basis) element_plate = elements.Element2D(model_plate, quad_basis) varsPerNode = model_plate.getVarsPerNode() # Load in the mesh mesh = TACS.MeshLoader(tacs_comm) mesh.scanBDFFile('tacs_aero.bdf') # Set the element mesh.setElement(0, element_plate) # Create the assembler object #varsPerNode = heat.getVarsPerNode() assembler = mesh.createTACS(varsPerNode) res = assembler.createVec() ans = assembler.createVec() mat = assembler.createSchurMat() # 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 = assembler.createNodeVec() assembler.getNodes(self.struct_X_vec) struct_X.append(self.struct_X_vec.getArray()) struct_nnodes.append(len(struct_X) / 3) assembler.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 assembler.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.T_ref = T_ref self.vol = volume self.assembler = assembler 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 = assembler.createVec() self.struct_rhs_vec = assembler.createVec() self.psi_T_S_vec = assembler.createVec() psi_T_S = self.psi_T_S_vec.getArray() self.psi_T_S = np.zeros((psi_T_S.size, self.nfunc), dtype=TACS.dtype) self.ans_array = [] self.svsenslist = [] self.dvsenslist = [] for func in range(self.nfunc): self.svsenslist.append(self.assembler.createVec()) self.dvsenslist.append(self.assembler.createDesignVec()) for scenario in range(len(model.scenarios)): self.ans_array.append(self.ans.getArray().copy()) self.initialize(model.scenarios[0], model.bodies)
if CHTMarkerID != None: nVertex_CHTMarker = SU2Driver.GetNumberVertices(CHTMarkerID) # get aero nodes X = [] for i in range(nVertex_CHTMarker): X.extend([ SU2Driver.GetVertexCoordX(CHTMarkerID, i), SU2Driver.GetVertexCoordY(CHTMarkerID, i), SU2Driver.GetVertexCoordZ(CHTMarkerID, i) ]) # initialize TACS # Create the constitutvie propertes and model props = constitutive.MaterialProperties() con = constitutive.PlaneStressConstitutive(props) heat = elements.HeatConduction2D(con) # Create the basis class quad_basis = elements.LinearQuadBasis() # Create the element element = elements.Element2D(heat, quad_basis) # Load in the mesh mesh = TACS.MeshLoader(comm) mesh.scanBDFFile('plate_bump.bdf') # Set the element mesh.setElement(0, element)