当前位置: 首页>>代码示例>>Python>>正文


Python Fem.getBoundary_Conditions方法代码示例

本文整理汇总了Python中Fem.getBoundary_Conditions方法的典型用法代码示例。如果您正苦于以下问题:Python Fem.getBoundary_Conditions方法的具体用法?Python Fem.getBoundary_Conditions怎么用?Python Fem.getBoundary_Conditions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fem的用法示例。


在下文中一共展示了Fem.getBoundary_Conditions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_calculation

# 需要导入模块: import Fem [as 别名]
# 或者: from Fem import getBoundary_Conditions [as 别名]
    def start_calculation(self):
        self.button_add_to_table.setEnabled(False)
        self.button_select_file.setEnabled(False)
        self.button_select_output.setEnabled(False)
        self.button_start_calculation.setEnabled(False)
        os.chdir("/")
        ##Get values from the GUI
        if ( os.path.exists(str(self.dirname)) ):
            os.chdir("c:/")
            shutil.rmtree(str(self.dirname))
        
        os.mkdir(str(self.dirname))
        batch = open(str(self.dirname + "/" + "lcmt_CALCULIX_Calculation_batch.bat"),'wb')
        #Tell calculixs solver spooles how many cpus to use
        #batch.write("export CCX_NPROC=" + str(self.params.GetInt("NumberCPUs")) + "\n")
        #If we have a tcsh
        #batch.write("setenv CCX_NPROC 4\n")

        #Now do the calculation stuff for each row in the  table
        for job in range (0,self.JobTable.rowCount()):
            #Extract the data from the table
            current_file_name = self.JobTable.item(job,0).text()
            z_offset_from = self.JobTable.item(job,2).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_offset_to = self.JobTable.item(job,3).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_offset_intervall = self.JobTable.item(job,4).data(QtCore.Qt.DisplayRole).toInt()[0]
            x_rot_from = self.JobTable.item(job,5).data(QtCore.Qt.DisplayRole).toInt()[0]
            x_rot_to = self.JobTable.item(job,6).data(QtCore.Qt.DisplayRole).toInt()[0]
            x_rot_intervall = self.JobTable.item(job,7).data(QtCore.Qt.DisplayRole).toInt()[0]
            y_rot_from = self.JobTable.item(job,8).data(QtCore.Qt.DisplayRole).toInt()[0]
            y_rot_to = self.JobTable.item(job,9).data(QtCore.Qt.DisplayRole).toInt()[0]
            y_rot_intervall = self.JobTable.item(job,10).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_rot_from = self.JobTable.item(job,11).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_rot_to = self.JobTable.item(job,12).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_rot_intervall = self.JobTable.item(job,13).data(QtCore.Qt.DisplayRole).toInt()[0]
            young_modulus = self.JobTable.item(job,14).data(QtCore.Qt.DisplayRole).toDouble()[0]
            poisson_ratio = self.JobTable.item(job,15).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc1 = self.JobTable.item(job,16).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc2 = self.JobTable.item(job,17).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc3 = self.JobTable.item(job,18).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc4 = self.JobTable.item(job,19).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc5 = self.JobTable.item(job,20).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc6 = self.JobTable.item(job,21).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc1 = self.JobTable.item(job,22).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc2 = self.JobTable.item(job,23).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc3 = self.JobTable.item(job,24).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc4 = self.JobTable.item(job,25).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc5 = self.JobTable.item(job,26).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc6 = self.JobTable.item(job,27).data(QtCore.Qt.DisplayRole).toDouble()[0]
            plate_thickness = self.JobTable.item(job,28).data(QtCore.Qt.DisplayRole).toDouble()[0]
            filename_without_suffix = self.JobTable.item(job,0).text().split("/").takeLast().split(".")[0]
            meshobject = Fem.read(str(current_file_name))
            #Perform PCA
            Fem.SMESH_PCA(meshobject)
            #Do min routine
            Fem.minBoundingBox(meshobject)
            #Now get the Node Numbers for the Boundary Conditions
            node_numbers = []
            node_numbers = Fem.getBoundary_Conditions(meshobject)

            #Now we have set up the initial geometry for the calculations. Lets generate an ABAQUS input file now for each z-level with exactly the same
            #boundary conditions


            #1. Lets translate the geometry to the initial desired z-level

            #2. Generate a Folder for the current calculation z-level and output the ABAQUS Geometry and the boundary_conditions
            #Lets first generate a subfolder with the current filename
            os.mkdir(str(self.dirname + "/" + filename_without_suffix))
            i = z_offset_from
            while i <= z_offset_to:
                j = x_rot_from
                while j <= x_rot_to:
                    k = y_rot_from
                    while k <= y_rot_to:
                        l = z_rot_from
                        while l <= z_rot_to:
                            rotation_around_x = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(1,0,0),j)
                            rotation_around_y = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(0,1,0),k)
                            rotation_around_z = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(0,0,1),l)
                            translate = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,i),FreeCAD.Base.Vector(0,0,0),0.0)
                            translation = rotation_around_x.multiply(rotation_around_y).multiply(rotation_around_z).multiply(translate)
                            #Now lets check if the part is still in the billet due to the rotation. If not, we directly skip to the next rotation value
                            if(Fem.checkBB(meshobject,translation,plate_thickness)):
                                print "Too heavy rotations"
                                l= l + z_rot_intervall
                                continue
                            print "it seems that nothing changed"
                            #Use the placedment as optional argument for the write() method
                            #translated_mesh.setTransform(translation)
                            Case_Dir = str(self.dirname) + "/" + filename_without_suffix + "/" + filename_without_suffix +\
                            "_"+"x_rot"+ str(int(j))+ \
                            "_"+"y_rot"+ str(int(k))+ \
                            "_"+"z_rot"+ str(int(l))+ \
                            "_"+"z_l"+ str(int(i))
                            if ( os.path.exists(str(Case_Dir)) ):
                                os.chdir(str(self.dirname))
                                shutil.rmtree(str(Case_Dir))

                            os.mkdir(str(Case_Dir))

#.........这里部分代码省略.........
开发者ID:JonasThomas,项目名称:free-cad,代码行数:103,代码来源:mach_dist_gui.py

示例2: start_calculation

# 需要导入模块: import Fem [as 别名]
# 或者: from Fem import getBoundary_Conditions [as 别名]
    def start_calculation(self):
        self.button_add_to_table.setEnabled(False)
        self.button_select_file.setEnabled(False)
        self.button_select_output.setEnabled(False)
        self.button_start_calculation.setEnabled(False)
        os.chdir(homepath)
        ##Get values from the GUI
        if ( os.path.exists(str(self.dirname)) ):
            os.chdir(homepath)
            shutil.rmtree(str(self.dirname))
        
        os.mkdir(str(self.dirname))
        batch = open(str(self.dirname + "/" + "lcmt_CALCULIX_Calculation_batch.bat"),'wb')
        batch.write("#!/bin/bash\n")        
        batch.write("export CCX_NPROC=4\n")
       
        #Tell calculixs solver spooles how many cpus to use
        #batch.write("export CCX_NPROC=" + str(self.params.GetInt("NumberCPUs")) + "\n")
        #If we have a tcsh
        #batch.write("setenv CCX_NPROC 4\n")

        #Now do the calculation stuff for each row in the  table
        for job in range (0,self.JobTable.rowCount()):
            #Extract the data from the table
            current_file_name = self.JobTable.item(job,0).text()
            z_offset_from = self.JobTable.item(job,2).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_offset_to = self.JobTable.item(job,3).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_offset_intervall = self.JobTable.item(job,4).data(QtCore.Qt.DisplayRole).toInt()[0]
            x_rot_from = self.JobTable.item(job,5).data(QtCore.Qt.DisplayRole).toInt()[0]
            x_rot_to = self.JobTable.item(job,6).data(QtCore.Qt.DisplayRole).toInt()[0]
            x_rot_intervall = self.JobTable.item(job,7).data(QtCore.Qt.DisplayRole).toInt()[0]
            y_rot_from = self.JobTable.item(job,8).data(QtCore.Qt.DisplayRole).toInt()[0]
            y_rot_to = self.JobTable.item(job,9).data(QtCore.Qt.DisplayRole).toInt()[0]
            y_rot_intervall = self.JobTable.item(job,10).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_rot_from = self.JobTable.item(job,11).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_rot_to = self.JobTable.item(job,12).data(QtCore.Qt.DisplayRole).toInt()[0]
            z_rot_intervall = self.JobTable.item(job,13).data(QtCore.Qt.DisplayRole).toInt()[0]
            young_modulus = self.JobTable.item(job,14).data(QtCore.Qt.DisplayRole).toDouble()[0]
            poisson_ratio = self.JobTable.item(job,15).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc1 = self.JobTable.item(job,16).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc2 = self.JobTable.item(job,17).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc3 = self.JobTable.item(job,18).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc4 = self.JobTable.item(job,19).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc5 = self.JobTable.item(job,20).data(QtCore.Qt.DisplayRole).toDouble()[0]
            lc6 = self.JobTable.item(job,21).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc1 = self.JobTable.item(job,22).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc2 = self.JobTable.item(job,23).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc3 = self.JobTable.item(job,24).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc4 = self.JobTable.item(job,25).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc5 = self.JobTable.item(job,26).data(QtCore.Qt.DisplayRole).toDouble()[0]
            ltc6 = self.JobTable.item(job,27).data(QtCore.Qt.DisplayRole).toDouble()[0]
            plate_thickness = self.JobTable.item(job,28).data(QtCore.Qt.DisplayRole).toDouble()[0]
            filename_without_suffix = self.JobTable.item(job,0).text().split("/").takeLast().split(".")[0]
            print current_file_name
            meshobject = Fem.read(str(current_file_name))
            #Perform PCA
            Fem.SMESH_PCA(meshobject)
            #Do min routine
            Fem.minBoundingBox(meshobject)
            #Now get the Node Numbers for the Boundary Conditions
            node_numbers = []
            node_numbers = Fem.getBoundary_Conditions(meshobject)

            #Now we have set up the initial geometry for the calculations. Lets generate an ABAQUS input file now for each z-level with exactly the same
            #boundary conditions


            #1. Lets translate the geometry to the initial desired z-level

            #2. Generate a Folder for the current calculation z-level and output the ABAQUS Geometry and the boundary_conditions
            #Lets first generate a subfolder with the current filename
            os.mkdir(str(self.dirname + "/" + filename_without_suffix))
            i = z_offset_from
            while i <= z_offset_to:
                j = x_rot_from
                while j <= x_rot_to:
                    k = y_rot_from
                    while k <= y_rot_to:
                        l = z_rot_from
                        while l <= z_rot_to:
                            rotation_around_x = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(1,0,0),j)
                            rotation_around_y = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(0,1,0),k)
                            rotation_around_z = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(0,0,1),l)
                            translate = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,i),FreeCAD.Base.Vector(0,0,0),0.0)
                            translation = rotation_around_x.multiply(rotation_around_y).multiply(rotation_around_z).multiply(translate)
                            #Now lets check if the part is still in the billet due to the rotation. If not, we directly skip to the next rotation value
                            if(Fem.checkBB(meshobject,translation,plate_thickness)):
                                print "Too heavy rotations"
                                print str(plate_thickness)
                                l= l + z_rot_intervall
                                continue
                            print "it seems that nothing changed"
                            print str(plate_thickness)
                            #Use the placedment as optional argument for the write() method
                            #translated_mesh.setTransform(translation)
                            Case_Dir = str(self.dirname) + "/" + filename_without_suffix + "/" + filename_without_suffix +\
                            "_"+"x_rot"+ str(int(j))+ \
                            "_"+"y_rot"+ str(int(k))+ \
                            "_"+"z_rot"+ str(int(l))+ \
                            "_"+"z_l"+ str(int(i))
#.........这里部分代码省略.........
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:103,代码来源:mach_dist_gui.py


注:本文中的Fem.getBoundary_Conditions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。