コード例 #1
0
    def writePlot3D(self, fileName, exportSet=0):
        """
        Write the current design to Plot3D file

        Parameters
        __________
        fileName : str
            name of the output Plot3D file
        exportSet : int
            optional argument to specify the export set in VSP
        """

        for dvName in self.DVs:
            DV = self.DVs[dvName]
            # We use float here since sometimes pyOptsparse will give
            # stupid numpy zero-dimensional arrays, which swig does
            # not like.
            openvsp.SetParmVal(DV.parmID, float(DV.value))
        openvsp.Update()

        # First set the export flag for exportSet to False for everyone
        for comp in self.allComps:
            openvsp.SetSetFlag(comp, exportSet, False)

        for comp in self.allComps:
            # Check if this one is in our list:
            compName = openvsp.GetContainerName(comp)
            if compName in self.compNames:
                openvsp.SetSetFlag(comp, exportSet, True)
                self.exportComps.append(compName)

        # Write the export file.
        openvsp.ExportFile(fileName, exportSet, openvsp.EXPORT_PLOT3D)
コード例 #2
0
ファイル: utilities.py プロジェクト: zxp-proteus/OpenVSP
def genX3d(file=None, set=vsp.SET_ALL, dims=[1000, 400], **kwargs):

    if file is not None:
        vsp.ClearVSPModel()
        vsp.ReadVSPFile(file)
        vsp.Update()

    with RunManager(**kwargs):
        vsp.ExportFile("prop.x3d", set, vsp.EXPORT_X3D)
        with open("prop.x3d", "r") as f:
            x3d_str = f.read()

        x3d_str = x3d_str[0:26] + " width=\"{}px\" height=\"{}px\"".format(
            dims[0], dims[1]) + x3d_str[26:-1]

    return x3d_str
コード例 #3
0
ファイル: utilities.py プロジェクト: zxp-proteus/OpenVSP
def export_airfoils(set=vsp.SET_ALL, **kwargs):
    import airfoils
    af_dict = dict()
    with RunManager(**kwargs) as r:
        output_file = r.cwd + "/airfoils.csv"
        vsp.ExportFile(output_file, set, vsp.EXPORT_SELIG_AIRFOIL)

        #parse airfoils.csv
        with open(output_file, "r") as f:
            lines = f.readlines()

        i = 2
        strs = lines[i].split(",")
        rootDir = strs[1].strip()
        i = i + 1
        while i < len(lines):
            if "Airfoil File Name" in lines[i]:
                file = rootDir + lines[i].split(",")[1].strip()
                af = airfoils.VspSeligExport(file)

                i = i + 1

                af.geom_name = lines[i].split(",")[1].strip()
                i = i + 1

                af.geom_id = lines[i].split(",")[1].strip()
                i = i + 1

                af.airfoil_index = int(lines[i].split(",")[1])
                i = i + 1

                af.xsec_flag = lines[i].split(",")[1].strip() == "1"

                i = i + 1

                if af.xsec_flag:
                    af.xsec_index = int(lines[i].split(",")[1])
                    i = i + 1

                    af.xsec_surf_id = lines[i].split(",")[1].strip()
                    i = i + 1

                af.foil_surf_u_value = float(lines[i].split(",")[1])

                i = i + 1
                af.global_u_value = float(lines[i].split(",")[1])

                i = i + 1
                af.le_point = np.array(lines[i].split(",")[1:]).astype(float)

                i = i + 1
                af.te_point = np.array(lines[i].split(",")[1:]).astype(float)

                i = i + 1
                af.chord = float(lines[i].split(",")[1])

                i = i + 1

                #af.findSegments()
                try:
                    af_dict[af.geom_id].append(af)
                except KeyError:
                    af_dict[af.geom_id] = []
                    af_dict[af.geom_id].append(af)

            else:
                i = i + 1

    return af_dict