吾生有涯 学海无涯
析模有界 知识无界

PyFluent文档|05 网格生成-传统流程

内容纲要

Fluent的网格生成引导工作流程旨在简化从CAD几何到体网格生成的过程。用户可以使用PyFluent访问引导的工作流程。

工作流程被划分为新的网格生成工作流程和经典网格生成工作流程,它们与日志语法对齐。

1 传统网格工作流程

可以使用PyFluent来访问与日志语法一致的经典网格工作流程。

1.1 Watertight geometry网格工作流

使用 Watertight Geometry 工作流来处理不需要大量清理或修改的封闭CAD几何体。以下示例展示了如何使用Watertight Geometry工作流。

1.1.1 导入几何

import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

import_file_name = examples.download_file('mixing_elbow.pmdb', 'pyfluent/mixing_elbow')
meshing = pyfluent.launch_fluent(
mode="meshing", precision='double', processor_count=2
)
meshing.workflow.InitializeWorkflow(WorkflowType='Watertight Geometry')
meshing.workflow.TaskObject['Import Geometry'].Arguments = {
'FileName': import_file_name, 'LengthUnit': 'in'
}
meshing.workflow.TaskObject['Import Geometry'].Execute()

1.1.2 添加局部尺寸

meshing.workflow.TaskObject['Add Local Sizing'].AddChildToTask()
meshing.workflow.TaskObject['Add Local Sizing'].Execute()

1.1.3 生成面网格

meshing.workflow.TaskObject['Generate the Surface Mesh'].Arguments = {
'CFDSurfaceMeshControls': {'MaxSize': 0.3}
}
meshing.workflow.TaskObject['Generate the Surface Mesh'].Execute()

1.1.4 描述几何

meshing.workflow.TaskObject["Describe Geometry"].UpdateChildTasks(
SetupTypeChanged=False
)
meshing.workflow.TaskObject["Describe Geometry"].Arguments = {
SetupType: "The geometry consists of only fluid regions with no voids"
}
meshing.workflow.TaskObject["Describe Geometry"].UpdateChildTasks(SetupTypeChanged=True)
meshing.workflow.TaskObject["Describe Geometry"].Execute()

1.1.5 更新边界

meshing.workflow.TaskObject["Update Boundaries"].Arguments = {
"BoundaryLabelList": ["wall-inlet"],
"BoundaryLabelTypeList": ["wall"],
"OldBoundaryLabelList": ["wall-inlet"],
"OldBoundaryLabelTypeList": ["velocity-inlet"],
}
meshing.workflow.TaskObject["Update Boundaries"].Execute()

1.1.6 更新区域

meshing.workflow.TaskObject["Update Regions"].Execute()

1.1.7 添加边界层

meshing.workflow.TaskObject["Add Boundary Layers"].AddChildToTask()
meshing.workflow.TaskObject["Add Boundary Layers"].InsertCompoundChildTask()
meshing.workflow.TaskObject["smooth-transition_1"].Arguments = {
"BLControlName": "smooth-transition_1",
}
meshing.workflow.TaskObject["Add Boundary Layers"].Arguments = {}
meshing.workflow.TaskObject["smooth-transition_1"].Execute()

1.1.8 生成体网格

meshing.workflow.TaskObject["Generate the Volume Mesh"].Arguments = {
"VolumeFill": "poly-hexcore",
"VolumeFillControls": {
"HexMaxCellLength": 0.3,
},
}
meshing.workflow.TaskObject["Generate the Volume Mesh"].Execute()

1.1.9 切换到solution模式

solver = meshing.switch_to_solver()

1.2 Fault-tolerant meshing工作流

使用Fault-tolerant网格划分工作流程可处理更复杂的非水密 CAD 几何图形,这些几何图形可能需要某种形式的清理或修改(例如,重叠、交叉、孔洞、重复等缺陷)。下面的示例展示了如何使用Fault-tolerant工作流程。

1.2.1 导入 CAD 和部件管理

import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

import_file_name = examples.download_file(
"exhaust_system.fmd", "pyfluent/exhaust_system"
)
meshing = pyfluent.launch_fluent(precision="double", processor_count=2, mode="meshing")
meshing.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing")
meshing.PartManagement.InputFileChanged(
FilePath=import_file_name, IgnoreSolidNames=False, PartPerBody=False
)
meshing.PMFileManagement.FileManager.LoadFiles()
meshing.PartManagement.Node["Meshing Model"].Copy(
Paths=[
"/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/main,1",
"/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/flow-pipe,1",
"/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/outpipe3,1",
"/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/object2,1",
"/dirty_manifold-for-wrapper," + "1/dirty_manifold-for-wrapper,1/object1,1",
]
)
meshing.PartManagement.ObjectSetting["DefaultObjectSetting"].OneZonePer.set_state("part")
meshing.workflow.TaskObject["Import CAD and Part Management"].Arguments.set_state(
{
"Context": 0,
"CreateObjectPer": "Custom",
"FMDFileName": import_file_name,
"FileLoaded": "yes",
"ObjectSetting": "DefaultObjectSetting",
"Options": {
"Line": False,
"Solid": False,
"Surface": False,
},
}
)
meshing.workflow.TaskObject["Import CAD and Part Management"].Execute()

1.2.2 描述几何形状和流动

meshing.workflow.TaskObject["Describe Geometry and Flow"].Arguments.set_state(
{
"AddEnclosure": "No",
"CloseCaps": "Yes",
"FlowType": "Internal flow through the object",
}
)
meshing.workflow.TaskObject["Describe Geometry and Flow"].UpdateChildTasks(
SetupTypeChanged=False
)
meshing.workflow.TaskObject["Describe Geometry and Flow"].Arguments.set_state(
{
"AddEnclosure": "No",
"CloseCaps": "Yes",
"DescribeGeometryAndFlowOptions": {
"AdvancedOptions": True,
"ExtractEdgeFeatures": "Yes",
},
"FlowType": "Internal flow through the object",
}
)
meshing.workflow.TaskObject["Describe Geometry and Flow"].UpdateChildTasks(
SetupTypeChanged=False
)
meshing.workflow.TaskObject["Describe Geometry and Flow"].Execute()

1.2.3 封闭流体区域(封盖)

meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"CreatePatchPreferences": {
"ShowCreatePatchPreferences": False,
},
"PatchName": "inlet-1",
"SelectionType": "zone",
"ZoneSelectionList": ["inlet.1"],
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"CreatePatchPreferences": {
"ShowCreatePatchPreferences": False,
},
"PatchName": "inlet-1",
"SelectionType": "zone",
"ZoneLocation": [
"1",
"351.68205",
"-361.34322",
"-301.88668",
"396.96205",
"-332.84759",
"-266.69751",
"inlet.1",
],
"ZoneSelectionList": ["inlet.1"],
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask()

meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].InsertCompoundChildTask()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state({})
meshing.workflow.TaskObject["inlet-1"].Execute()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"PatchName": "inlet-2",
"SelectionType": "zone",
"ZoneSelectionList": ["inlet.2"],
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"PatchName": "inlet-2",
"SelectionType": "zone",
"ZoneLocation": [
"1",
"441.68205",
"-361.34322",
"-301.88668",
"486.96205",
"-332.84759",
"-266.69751",
"inlet.2",
],
"ZoneSelectionList": ["inlet.2"],
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask()

meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].InsertCompoundChildTask()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state({})
meshing.workflow.TaskObject["inlet-2"].Execute()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"PatchName": "inlet-3",
"SelectionType": "zone",
"ZoneSelectionList": ["inlet"],
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"PatchName": "inlet-3",
"SelectionType": "zone",
"ZoneLocation": [
"1",
"261.68205",
"-361.34322",
"-301.88668",
"306.96205",
"-332.84759",
"-266.69751",
"inlet",
],
"ZoneSelectionList": ["inlet"],
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask()

meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].InsertCompoundChildTask()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state({})
meshing.workflow.TaskObject["inlet-3"].Execute()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"PatchName": "outlet-1",
"SelectionType": "zone",
"ZoneSelectionList": ["outlet"],
"ZoneType": "pressure-outlet",
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state(
{
"PatchName": "outlet-1",
"SelectionType": "zone",
"ZoneLocation": [
"1",
"352.22702",
"-197.8957",
"84.102381",
"394.41707",
"-155.70565",
"84.102381",
"outlet",
],
"ZoneSelectionList": ["outlet"],
"ZoneType": "pressure-outlet",
}
)
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].AddChildToTask()

meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].InsertCompoundChildTask()
meshing.workflow.TaskObject["Enclose Fluid Regions (Capping)"].Arguments.set_state({})
meshing.workflow.TaskObject["outlet-1"].Execute()

1.2.4 提取边特征

meshing.workflow.TaskObject["Extract Edge Features"].Arguments.set_state(
{
"ExtractMethodType": "Intersection Loops",
"ObjectSelectionList": ["flow_pipe", "main"],
}
)
meshing.workflow.TaskObject["Extract Edge Features"].AddChildToTask()

meshing.workflow.TaskObject["Extract Edge Features"].InsertCompoundChildTask()

meshing.workflow.TaskObject["edge-group-1"].Arguments.set_state(
{
"ExtractEdgesName": "edge-group-1",
"ExtractMethodType": "Intersection Loops",
"ObjectSelectionList": ["flow_pipe", "main"],
}
)
meshing.workflow.TaskObject["Extract Edge Features"].Arguments.set_state({})

meshing.workflow.TaskObject["edge-group-1"].Execute()

1.2.5 确定区域

meshing.workflow.TaskObject["Identify Regions"].Arguments.set_state(
{
"SelectionType": "zone",
"X": 377.322045740589,
"Y": -176.800676988458,
"Z": -37.0764628583475,
"ZoneSelectionList": ["main.1"],
}
)
meshing.workflow.TaskObject["Identify Regions"].Arguments.set_state(
{
"SelectionType": "zone",
"X": 377.322045740589,
"Y": -176.800676988458,
"Z": -37.0764628583475,
"ZoneLocation": [
"1",
"213.32205",
"-225.28068",
"-158.25531",
"541.32205",
"-128.32068",
"84.102381",
"main.1",
],
"ZoneSelectionList": ["main.1"],
}
)
meshing.workflow.TaskObject["Identify Regions"].AddChildToTask()

meshing.workflow.TaskObject["Identify Regions"].InsertCompoundChildTask()

meshing.workflow.TaskObject["fluid-region-1"].Arguments.set_state(
{
"MaterialPointsName": "fluid-region-1",
"SelectionType": "zone",
"X": 377.322045740589,
"Y": -176.800676988458,
"Z": -37.0764628583475,
"ZoneLocation": [
"1",
"213.32205",
"-225.28068",
"-158.25531",
"541.32205",
"-128.32068",
"84.102381",
"main.1",
],
"ZoneSelectionList": ["main.1"],
}
)
meshing.workflow.TaskObject["Identify Regions"].Arguments.set_state({})

meshing.workflow.TaskObject["fluid-region-1"].Execute()
meshing.workflow.TaskObject["Identify Regions"].Arguments.set_state(
{
"MaterialPointsName": "void-region-1",
"NewRegionType": "void",
"ObjectSelectionList": ["inlet-1", "inlet-2", "inlet-3", "main"],
"X": 374.722045740589,
"Y": -278.9775145640143,
"Z": -161.1700719416913,
}
)
meshing.workflow.TaskObject["Identify Regions"].AddChildToTask()

meshing.workflow.TaskObject["Identify Regions"].InsertCompoundChildTask()

meshing.workflow.TaskObject["Identify Regions"].Arguments.set_state({})

meshing.workflow.TaskObject["void-region-1"].Execute()

1.2.6 定义泄漏阈值

meshing.workflow.TaskObject["Define Leakage Threshold"].Arguments.set_state(
{
"AddChild": "yes",
"FlipDirection": True,
"PlaneDirection": "X",
"RegionSelectionSingle": "void-region-1",
}
)
meshing.workflow.TaskObject["Define Leakage Threshold"].AddChildToTask()

meshing.workflow.TaskObject["Define Leakage Threshold"].InsertCompoundChildTask()
meshing.workflow.TaskObject["leakage-1"].Arguments.set_state(
{
"AddChild": "yes",
"FlipDirection": True,
"LeakageName": "leakage-1",
"PlaneDirection": "X",
"RegionSelectionSingle": "void-region-1",
}
)
meshing.workflow.TaskObject["Define Leakage Threshold"].Arguments.set_state(
{
"AddChild": "yes",
}
)
meshing.workflow.TaskObject["leakage-1"].Execute()

1.2.7 更新区域设置

meshing.workflow.TaskObject["Update Region Settings"].Arguments.set_state(
{
"AllRegionFilterCategories": ["2"] * 5 + ["1"] * 2,
"AllRegionLeakageSizeList": ["none"] * 6 + ["6.4"],
"AllRegionLinkedConstructionSurfaceList": ["n/a"] * 6 + ["no"],
"AllRegionMeshMethodList": ["none"] * 6 + ["wrap"],
"AllRegionNameList": [
"main",
"flow_pipe",
"outpipe3",
"object2",
"object1",
"void-region-1",
"fluid-region-1",
],
"AllRegionOversetComponenList": ["no"] * 7,
"AllRegionSourceList": ["object"] * 5 + ["mpt"] * 2,
"AllRegionTypeList": ["void"] * 6 + ["fluid"],
"AllRegionVolumeFillList": ["none"] * 6 + ["tet"],
"FilterCategory": "Identified Regions",
"OldRegionLeakageSizeList": [""],
"OldRegionMeshMethodList": ["wrap"],
"OldRegionNameList": ["fluid-region-1"],
"OldRegionOversetComponenList": ["no"],
"OldRegionTypeList": ["fluid"],
"OldRegionVolumeFillList": ["hexcore"],
"RegionLeakageSizeList": [""],
"RegionMeshMethodList": ["wrap"],
"RegionNameList": ["fluid-region-1"],
"RegionOversetComponenList": ["no"],
"RegionTypeList": ["fluid"],
"RegionVolumeFillList": ["tet"],
}
)
meshing.workflow.TaskObject["Update Region Settings"].Execute()

1.2.8 选择网格控制选项

meshing.workflow.TaskObject["Choose Mesh Control Options"].Execute()

1.2.9 生成面网格

meshing.workflow.TaskObject["Generate the Surface Mesh"].Execute()

1.2.9 更新边界

meshing.workflow.TaskObject["Update Boundaries"].Execute()

1.2.10 添加边界层

meshing.workflow.TaskObject["Add Boundary Layers"].AddChildToTask()

meshing.workflow.TaskObject["Add Boundary Layers"].InsertCompoundChildTask()

meshing.workflow.TaskObject["aspect-ratio_1"].Arguments.set_state(
{
"BLControlName": "aspect-ratio_1",
}
)
meshing.workflow.TaskObject["Add Boundary Layers"].Arguments.set_state({})

meshing.workflow.TaskObject["aspect-ratio_1"].Execute()

1.2.11 生成体网格

meshing.workflow.TaskObject["Generate the Volume Mesh"].Arguments.set_state(
{
"AllRegionNameList": [
"main",
"flow_pipe",
"outpipe3",
"object2",
"object1",
"void-region-1",
"fluid-region-1",
],
"AllRegionSizeList": ["11.33375"] * 7,
"AllRegionVolumeFillList": ["none"] * 6 + ["tet"],
"EnableParallel": True,
}
)
meshing.workflow.TaskObject["Generate the Volume Mesh"].Execute()

1.2.12 切换至solution模式

solver = meshing.switch_to_solver()

1.3 命令参数使用示例

这个简单的例子展示了如何在一个Watertight Geometry工作流中使用CommandArgument属性和显式属性访问方法。

注意:CommandArgument 属性为只读属性。

import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

import_file_name = examples.download_file("mixing_elbow.pmdb", "pyfluent/mixing_elbow")
meshing = pyfluent.launch_fluent(mode="meshing", precision="double", processor_count=2)
w = meshing.workflow
w.InitializeWorkflow(WorkflowType="Watertight Geometry")

w.TaskObject["Import Geometry"].CommandArguments()
w.TaskObject["Import Geometry"].CommandArguments.FileName.is_read_only()
w.TaskObject["Import Geometry"].CommandArguments.LengthUnit.is_active()
w.TaskObject["Import Geometry"].CommandArguments.LengthUnit.allowed_values()
w.TaskObject["Import Geometry"].CommandArguments.LengthUnit.default_value()
w.TaskObject["Import Geometry"].CommandArguments.LengthUnit()
w.TaskObject["Import Geometry"].CommandArguments.CadImportOptions.OneZonePer()
w.TaskObject["Import Geometry"].CommandArguments.CadImportOptions.FeatureAngle.min()

1.4 一些改进

可以调用TaskObject来获取其状态:

meshing.workflow.TaskObject()

TaskObject中的项目现在可以通过设置字典风格来访问:

for name, object in meshing.workflow.TaskObject.items():
...

注:本文内容取自PyFluent UserGuide。


(完毕)

本篇文章来源于微信公众号: CFD之道

赞(0) 打赏
版权声明:未经允许,请勿随意用于商业用途。
文章名称:《PyFluent文档|05 网格生成-传统流程》
文章链接:https://www.topcfd.cn/39121/
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
分享到

说两句 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者吧

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册