def test_build_linear_static_case(self): comm = LS.CommWriter() comm.use(LS.YoungModulus(10**3)) comm.use(LS.PoissonRatio(0.3)) comm.use(LS.Modelisation(LS.PlaneStress)) mech_consts = comm.use(LS.MechConstraints()) bound_conds = mech_consts.add(LS.BoundConds()) bound_conds.add(LS.DplFromName(LS.GRP_MA, "A", 3, 0, 1)) bound_conds.add(LS.DplFromName(LS.GRP_NO, "NA", 2, 1, 9)) bound_conds.add(LS.DplFromName(LS.GRP_MA, "B", 5, 2, 7)) pressure = mech_consts.add(LS.Pressure()) pressure.add(LS.GrpPres("B", 12)) pressure.add(LS.GrpPres("D", 27)) fname = osp.join(self.tmp_dir.add("linear_static"), "fname.comm") comm.write(fname) self.check_content(fname, LINEAR_STATIC)
def save_linear(self): #保存到comm文件中 comm = LS.CommWriter() comm.use(LS.Modelisation(self.get_sel_itm().get_model_type())) gm = LS.GrpMaterial() gm.clear_part() grp_material = comm.use(gm) #grp_material.add(LS.Material(self.get_material()))#material grp_material.add(LS.Material(self.get_material()))#material grp_material.add(LS.GroupMaterial(self.materials_conds))#grouop-material mech_consts = comm.use(LS.MechConstraints()) bound_conds = mech_consts.add(LS.BoundConds()) mesh = self.mesh exp = self.exp_store.give_exp("boundaries") log_gui.debug("save_linear %d", len(self.degrees_conds)) if len(self.degrees_conds): for cond in self.degrees_conds: gname = str(cond[0]) grp_type = exp.give_group_key(mesh, gname) bound_conds.add(LS.DplFromName(grp_type, gname, *cond[1:])) else: mess = "Warning: You have not defined boundary conditions " self.mod.launch(aster_s_gui.INFO, mess) mech_consts.add(LS.BoundEnd(len("CHARC=AFFE_CHAR_MECA"),");")) mech_consts.add(LS.PressStart(0,"CHARF=AFFE_CHAR_MECA(MODELE=MODX,")) pressure = mech_consts.add(LS.Pressure() )#here forceface = mech_consts.add(LS.ForceFace() )#here forcenodale = mech_consts.add(LS.ForceNodale() )#here for gname, ptype, v1,v2,v3,v4,v5,v6 in self.pressure_conds: if ptype =="Pressure": pressure.add(LS.GrpPres(str(gname), v1)) elif ptype =="Force_Face": forceface.add(LS.ForceFaceArgs(str(gname), v1,v2,v3)) elif ptype =="Force_Node": forcenodale.add(LS.ForceNodaleArgs(str(gname), v1,v2,v3,v4,v5,v6,self.get_dim())) comm.write(self.comm_path) #self.add_case("linear-static") return True
def validatePage(self): """Validate the wizard""" getf = self.give_field comm = LS.CommWriter() comm.use(LS.Modelisation(getf("model"))) comm.use(LS.YoungModulus(self.get_float("young-modulus"))) comm.use(LS.PoissonRatio(self.get_float("poisson-ratio"))) mech_consts = comm.use(LS.MechConstraints()) bound_conds = mech_consts.add(LS.BoundConds()) mesh = getf("mesh") exp = getf("exp-store").give_exp("boundaries") if not getf("pressure-loading") and not getf("group-boundaries"): mess = "Pressure and/or boundary conditions are required " self._mod.launch(aster_s_gui.ERROR, mess) return False else : if getf("group-boundaries"): for cond in getf("group-boundaries"): gname = str(cond[0]) grp_type = exp.give_group_key(mesh, gname) bound_conds.add(LS.DplFromName(grp_type, gname, *cond[1:])) else: mess = "Warning: You have not defined boundary conditions " self._mod.launch(aster_s_gui.INFO, mess) pressure = mech_consts.add(LS.Pressure()) if getf("pressure-loading"): for gname, val in getf("pressure-loading"): pressure.add(LS.GrpPres(str(gname), val)) else: mess = "Warning: You have not defined pressure " self._mod.launch(aster_s_gui.INFO, mess) comm.write(self.get_str("command-file")) self.add_case("linear-static") return True
def save_nolinear(self): """Validate the wizard""" comm = LS.AstCommWriter() comm.use(LS.Modelisation(self.get_sel_itm().get_model_type())) gm = LS.GrpMaterial() gm.clear_part() grp_material = comm.use(gm) mech_consts = comm.use(LS.MechConstraints()) bound_conds = mech_consts.add(LS.BoundConds()) grp_material.add(LS.Material(self.get_material()))#material grp_material.add(LS.GroupMaterial(self.materials_conds))#grouop-material #####################BondContact######### bond_group=[] fric_group=[] fricless_group=[] grp_pair = self.pair_conds for g in grp_pair: if(str(g[0])==u"bond"): bond_group.append([str(g[1]),str(g[2])]) if(str(g[0])==u"Friction"): fric_group.append([str(g[1]),str(g[2]),str(g[3])]) if(str(g[0])==u"Frictionless"): fricless_group.append([str(g[1]),str(g[2]),"0.0"]) bc=LS.BondContact(bond_group) bond_contact = comm.use(bc) bc.clear_part() ################################# if(len(bond_group)): comm.use(WCD.HasBondContactKey("_F(CHARGE=CHA3)")) else: comm.use(WCD.HasBondContactKey("")) if(len(fric_group+fricless_group)): comm.use(WCD.HasfrictionContactKey("CONTACT = CONTA,")) else: comm.use(WCD.HasfrictionContactKey("")) ######################### mc=LS.MechConstraints() mc.clear_consts() mech_consts = comm.use(mc)#start replace a line bound_conds = mech_consts.add(LS.BoundConds())#first sub section bound_conds.clear_consts() mesh = self.mesh exp = self.exp_store.give_exp("boundaries") log_gui.debug("save_nolinear %d", len(self.degrees_conds)) if len(self.degrees_conds): for cond in self.degrees_conds: gname = str(cond[0]) grp_type = exp.give_group_key(mesh, gname) bound_conds.add(LS.DplFromName(grp_type, gname, *cond[1:])) else: mess = "Warning: You have not defined boundary conditions " self.mod.launch(aster_s_gui.INFO, mess) mech_consts.add(LS.BoundEnd(len("CHARC=AFFE_CHAR_MECA"),");")) mech_consts.add(LS.PressStart(0,"CHARF=AFFE_CHAR_MECA(MODELE=MODX,")) pressure = mech_consts.add(LS.Pressure() )#here forceface = mech_consts.add(LS.ForceFace() )#here forcenodale = mech_consts.add(LS.ForceNodale() )#here for gname, ptype, v1,v2,v3,v4,v5,v6 in self.pressure_conds: if ptype =="Pressure": pressure.add(LS.GrpPres(str(gname), v1)) elif ptype =="Force_Face": forceface.add(LS.ForceFaceArgs(str(gname), v1,v2,v3)) elif ptype =="Force_Node": forcenodale.add(LS.ForceNodaleArgs(str(gname), v1,v2)) groups=set() for g in grp_pair:#todo: if(mesh.get_mesh_grounp_type(str(g[1])) != "VOLUME"): groups.add(str(g[1])) if(mesh.get_mesh_grounp_type(str(g[2])) != "VOLUME"): groups.add(str(g[2])) for g in groups: pressure.add_to_mesh_change(g) ################## par=[] tmp = exp.find_groups(mesh) for group_par in tmp: t = exp.give_group_key(mesh, group_par) print "@@@@1:",group_par,t if(t.__repr__()!="GROUP_NO"): par.append(group_par) par=str(par) par = par.replace('[','') par = par.replace(']','') comm.use(WCD.AllMeshGrounp(par)) ################## contact=LS.Contact(fric_group+fricless_group) comm.use(contact) #contact.clear_part() comm.write(self.comm_path) return True