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


Python ParsedParameterFile.header["object"]方法代码示例

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


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

示例1: case_setup

# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import header["object"] [as 别名]
def case_setup(ci):
    template_case = SolutionDirectory(
        "template", archive=None, paraviewLink=False)
    case = template_case.cloneCase(
        "{0}NC{1}".format(ci.name, ci.nr_classes)
    )

    phase_properties = ParsedParameterFile(
        path.join(template_case.name, "constant", "phaseProperties"))
    phase_properties["oil"]["PBEDiameterCoeffs"]["MOCCoeffs"]["numberOfClasses"] = ci.nr_classes
    phase_properties["oil"]["PBEDiameterCoeffs"]["MOCCoeffs"]["xi1"] = ci.dv

    # manually fix bad pyfoam parsing
    phase_properties["blending"]["default"]["type"] = "none"
    phase_properties["drag"][1]["swarmCorrection"]["type"] = "none"
    phase_properties.writeFileAs(path.join(
        case.name, "constant", "phaseProperties"
    ))

    n0 = ParsedParameterFile(path.join(template_case.name, "0", "n0"))
    for i in range(ci.nr_classes):
        n0.header["object"] = "n" + str(i)
        n0["internalField"].setUniform(ci.Ninit[i])
        n0.writeFileAs(path.join(case.name, "0", "n" + str(i)))

    controlDict = ParsedParameterFile(
        path.join(case.name, "system", "controlDict")
    )
    controlDict["functions"]["probes"]["fields"] = [
        "n{0}".format(n) for n in range(ci.nr_classes)]
    controlDict.writeFile()
开发者ID:Kojirion,项目名称:OpenPBE,代码行数:33,代码来源:setupCases.py

示例2: case_setup

# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import header["object"] [as 别名]
def case_setup(ci):
    template_case = SolutionDirectory(
        "template", archive=None, paraviewLink=False)
    case = template_case.cloneCase(
        "{0}{1}".format(ci.name, ci.quadrature_order)
    )

    phase_properties = ParsedParameterFile(
        path.join("./diffs", ci.phase_properties_name))
    phase_properties["air"]["PBEDiameterCoeffs"]["QMOMCoeffs"]["quadratureOrder"] = ci.quadrature_order

    # manually fix bad pyfoam parsing
    phase_properties["blending"]["default"]["type"] = "none"
    phase_properties["drag"][1]["swarmCorrection"]["type"] = "none"
    phase_properties.writeFileAs(path.join(
        case.name, "constant", "phaseProperties"
    ))

    m0 = ParsedParameterFile(path.join(template_case.name, "0", "m0"))
    for i in range(ci.number_of_moments):
        m0.header["object"] = "m" + str(i)
        m0["internalField"].setUniform(ci.initial_moments[i])
        m0["dimensions"] = "[0 {0} 0 0 0 0 0]".format(3 * i)
        m0.writeFileAs(path.join(case.name, "0", "m" + str(i)))

    controlDict = ParsedParameterFile(
        path.join(case.name, "system", "controlDict")
    )
    controlDict["functions"]["probes"]["fields"] = [
        "m{0}".format(m) for m in range(ci.number_of_moments)]
    controlDict["endTime"] = ci.end_time
    controlDict["deltaT"] = ci.delta_t
    controlDict.writeFile()
开发者ID:Kojirion,项目名称:OpenPBE,代码行数:35,代码来源:setupCases.py

示例3: main

# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import header["object"] [as 别名]
def main(args):
    # 0 - reading input
    cwd = os.getcwd()
    os.chdir(args.target)
    if len(glob.glob("*.map")) > 1:
        print "error: more then a single map file in the directory, please delete all except one"
        raise SystemExit
    mapFileName = glob.glob("*.map")[0]
    remove_extra_spaces(mapFileName)
    from pdb import set_trace
    #set_trace()
    
    # 0.5 creating z0 dummy file
    os.system("cp -r 0/p 0/z0")
    z0Dict = ParsedParameterFile("0/z0")
    z0Dict.header["object"] = "z0"
    for b in z0Dict["boundaryField"]:
        print b
        if type(b) is str:
            if b.find("terrain")>-1 or b.find("ground")>-1:
                print "found terrain/ground in z0 at patch " + b
                z0Dict["boundaryField"][b]["value"]="uniform 0"
                z0Dict["boundaryField"][b]["type"]="fixedValue"
    z0Dict["dimensions"] = "[ 0 1 0 0 0 0 0]"
    z0Dict.writeFile()

    # 1 - running roughnessToFoam.C
    callString = "( echo %s; echo %d; echo %d; echo %d; echo %d; echo %d; echo %d) | roughnessToFoam" % (mapFileName, args.offsetX, args.offsetY, args.point_ax, args.point_ay, args.point_bx, args.point_by)
    os.system(callString)

    # 2 - reading modified z0 file - made with roughnessToFoam.C
    z0Dict = ParsedParameterFile("0/z0")
    for b in z0Dict["boundaryField"]:
        if type(b) is str:
            if b.find("terrain")>-1:
                # TODO - save each different *terrain*'s z0 and place in matching nut *terrain*. at the moment - only one patch with "terrain" in it is expected, and one with "ground". 
                z0Terrain = z0Dict["boundaryField"][b]["value"]
                print "taken *terrain* z0 from %s" % b
            if b.find("ground")>-1:
                z0Ground = z0Dict["boundaryField"][b]["value"]
                print "taken *ground* z0 from %s" % b

    # 3 - writing z0 into nut file
    nutDict = ParsedParameterFile("0/nut")
    for b in nutDict["boundaryField"]:
        if type(b) is str:
            for c in nutDict["boundaryField"][b]:
                if "z0" in c:
                        if b.find("terrain")>-1:
                            nutDict["boundaryField"][b]["z0"] = z0Terrain
                        if b.find("ground")>-1:
                            nutDict["boundaryField"][b]["z0"] = 0
                            nutDict["boundaryField"][b]["z0"] = z0Ground
                        
    nutDict.writeFile()
    os.chdir(cwd)
开发者ID:Burak1012,项目名称:roughnessToFoam,代码行数:58,代码来源:roughnessToFoam.py

示例4: gamma

# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import header["object"] [as 别名]
vmax = 1
dv = vmax / class_number
m0 = 2
prob = gamma(a=50, scale=1.0e-2)
v = dv + dv * arange(class_number)

if __name__ == "__main__":
    template_case = SolutionDirectory(
        "MOC-template", archive=None, paraviewLink=False)
    case = template_case.cloneCase(
        "{0}{1}".format("MOC", class_number)
    )

    n0 = ParsedParameterFile(path.join(template_case.name, "0", "n0"))
    for i in range(class_number):
        n0.header["object"] = "n" + str(i)
        n0["internalField"].setUniform(
            m0 * (prob.cdf(v[i]) - prob.cdf(v[i] - dv))
        )
        n0.writeFileAs(path.join(case.name, "0", "n" + str(i)))

    phase_properties = ParsedParameterFile(
        path.join(case.name, "constant", "phaseProperties")
    )

    phase_properties["air"]["PBEDiameterCoeffs"]["MOCCoeffs"]["numberOfClasses"] = class_number
    phase_properties["air"]["PBEDiameterCoeffs"]["MOCCoeffs"]["xi1"] = dv
    phase_properties["blending"]["default"]["type"] = "none"
    phase_properties["drag"][1]["swarmCorrection"]["type"] = "none"
    phase_properties.writeFile()
开发者ID:Kojirion,项目名称:OpenPBE,代码行数:32,代码来源:setupIC.py


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