Trouble Adding Custom Local Sizing in Pyfluent

CoolHarrison
CoolHarrison Member Posts: 18
10 Comments
**
edited July 26 in Fluids

`add_local_sizing.InsertCompoundChildTask()
workflow.TaskObject["Add Local Sizing"].Execute()
add_local_sizing = workflow.TaskObject["Add Local Sizing"]
add_local_sizing.Arguments = dict(
{
"AddChild": "yes",
"BOIControlName": "facesize_main",
"BOIFaceLabelList": ["wall_ahmed_body_main"],
"BOIGrowthRate": 1.15,
"BOISize": 12,
}
)
add_local_sizing.Execute()

add_local_sizing.InsertCompoundChildTask()
workflow.TaskObject["Add Local Sizing"].Execute()
add_local_sizing = workflow.TaskObject["Add Local Sizing"]
add_local_sizing.Arguments = dict(
{
"AddChild": "yes",
"BOIControlName": "facesize_wheels",
"BOIFaceLabelList": ["wheels"],
"BOIGrowthRate": 1.15,
"BOISize": 7,
}
)
add_local_sizing.Execute()

add_local_sizing.InsertCompoundChildTask()
workflow.TaskObject["Add Local Sizing"].Execute()`

This section of code focuses on adding local sizing to each part of my ahmed body. This code was mainly taken under the "Add Local Face Sizing" section of the Ahmed Body External Aerodynamics Simulation example linked here: [https://examples.fluent.docs.pyansys.com/version/dev/examples/00-released_examples/00-ahmed_body_workflow.html#sphx-glr-examples-00-released-examples-00-ahmed-body-workflow-py]

The first section has the BOIControlName "facesize_main", and it ran perfectly (Because it's the exact same code) However, the 3d body that I'm testing has wheels, so I tried to add local sizing under the BOIControlName "facesize_wheels" which I had made up to correspond to my named selection of "wheels". The code freezes on the last line of the code, when the local sizing of the wheels is finally executed.

I'm guessing that that there's a set of BOIControlNames that I have to pick from, but I'm not sure where to find that, or if that's the problem at all. Thanks in advance for the help.

Best Answer

  • Sean Pearson
    Sean Pearson Member, Employee Posts: 20
    10 Comments First Answer First Anniversary Ansys Employee
    ✭✭✭✭
    Answer ✓

    The original issue reported here was "The code freezes on the last line of the code, when the local sizing of the wheels is finally executed." The advice given was so that a reliable journal could be created to resolve the reported issue. Did this work?

Answers

  • Sean Pearson
    Sean Pearson Member, Employee Posts: 20
    10 Comments First Answer First Anniversary Ansys Employee
    ✭✭✭✭

    To create a reliable baseline meshing workflow script, start journaling in Fluent Meshing and run through the steps in the task-based workflow user interface.

  • CoolHarrison
    CoolHarrison Member Posts: 18
    10 Comments
    **

    I tried, and all it left me with is this:
    `try:
    import ansys.fluent.core as pyfluent
    flglobals = pyfluent.setup_for_fluent(product_version="24.1.0", mode="meshing", version="3d", precision="double", processor_count=2)
    globals().update(flglobals)
    except Exception:
    pass

    workflow.InitializeWorkflow(WorkflowType=r'Watertight Geometry')
    workflow.TaskObject['Import Geometry'].Arguments.set_state({r'FileName': r'C:\Users\forha\ahmedWB1_files\dp0\FFF\DM\FFF.scdoc',r'ImportCadPreferences': {r'MaxFacetLength': 0,},r'LengthUnit': r'mm',r'UseBodyLabels': r'Yes',})
    workflow.TaskObject['Import Geometry'].Execute()
    meshing.execute_tui(r'''(newline)''')
    workflow.TaskObject['Add Local Sizing'].Arguments.set_state({r'AddChild': r'yes',r'BOICellsPerGap': 1,r'BOIControlName': r'facesize_front',r'BOICurvatureNormalAngle': 18,r'BOIExecution': r'Face Size',r'BOIFaceLabelList': [r'wall_ahmed_body_front'],r'BOIGrowthRate': 1.15,r'BOISize': 8,r'BOIZoneorLabel': r'label',})
    workflow.TaskObject['Add Local Sizing'].AddChildAndUpdate(DeferUpdate=False)
    workflow.TaskObject['Add Local Sizing'].Arguments.set_state({r'AddChild': r'yes',r'BOICellsPerGap': 1,r'BOIControlName': r'facesize_rear',r'BOICurvatureNormalAngle': 18,r'BOIExecution': r'Face Size',r'BOIFaceLabelList': [r'wall_ahmed_body_rear'],r'BOIGrowthRate': 1.15,r'BOISize': 5,r'BOIZoneorLabel': r'label',})
    workflow.TaskObject['Add Local Sizing'].AddChildAndUpdate(DeferUpdate=False)
    workflow.TaskObject['Add Local Sizing'].Arguments.set_state({r'AddChild': r'yes',r'BOICellsPerGap': 1,r'BOIControlName': r'facesize_main',r'BOICurvatureNormalAngle': 18,r'BOIExecution': r'Face Size',r'BOIFaceLabelList': [r'wall_ahmed_body_main'],r'BOIGrowthRate': 1.15,r'BOISize': 12,r'BOIZoneorLabel': r'label',})
    workflow.TaskObject['Add Local Sizing'].AddChildAndUpdate(DeferUpdate=False)
    workflow.TaskObject['Add Local Sizing'].Arguments.set_state({r'AddChild': r'yes',r'BOICellsPerGap': 1,r'BOIControlName': r'boi_1',r'BOICurvatureNormalAngle': 18,r'BOIExecution': r'Body Of Influence',r'BOIFaceLabelList': [r'fff-boi'],r'BOIGrowthRate': 1.15,r'BOISize': 20,r'BOIZoneorLabel': r'label',})
    workflow.TaskObject['Add Local Sizing'].AddChildAndUpdate(DeferUpdate=False)
    workflow.TaskObject['Generate the Surface Mesh'].Arguments.set_state({r'CFDSurfaceMeshControls': {r'CurvatureNormalAngle': 12,r'GrowthRate': 1.15,r'MaxSize': 50,r'MinSize': 1,r'SizeFunctions': r'Curvature',},r'SeparationRequired': r'No',})
    workflow.TaskObject['Generate the Surface Mesh'].Execute()
    workflow.TaskObject['Describe Geometry'].UpdateChildTasks(SetupTypeChanged=False)
    workflow.TaskObject['Describe Geometry'].Arguments.set_state({r'NonConformal': r'No',r'SetupType': r'The geometry consists of only fluid regions with no voids',})
    workflow.TaskObject['Describe Geometry'].UpdateChildTasks(SetupTypeChanged=True)
    workflow.TaskObject['Describe Geometry'].Execute()
    workflow.TaskObject['Update Boundaries'].Execute()
    workflow.TaskObject['Update Regions'].Execute()
    workflow.TaskObject['Update Regions'].Revert()
    workflow.TaskObject['Update Regions'].Execute()
    workflow.TaskObject['Add Boundary Layers'].Arguments.set_state({r'LocalPrismPreferences': {r'Continuous': r'Continuous',},r'NumberOfLayers': 14,r'Rate': 1.215,r'TransitionRatio': 0.5,})
    workflow.TaskObject['Add Boundary Layers'].AddChildAndUpdate(DeferUpdate=False)
    workflow.TaskObject['Generate the Volume Mesh'].Arguments.set_state({r'VolumeFill': r'poly-hexcore',})
    workflow.TaskObject['Generate the Volume Mesh'].Execute()
    meshing.switch_to_solver()
    solver.execute_tui(r'''(newline)''')
    `
    I went through the entire process, but the part where I print out the drag and lift forces don't appear.

  • CoolHarrison
    CoolHarrison Member Posts: 18
    10 Comments
    **

    It didn't work, because the code that the journal generated was inefficient. I might've made a mistake in the process, but I repeated it a couple of times and I was left with similar results.

  • Sean Pearson
    Sean Pearson Member, Employee Posts: 20
    10 Comments First Answer First Anniversary Ansys Employee
    ✭✭✭✭

    You're saying that the journal didn't work because it was inefficient. Why is that preventing the journal from working?

  • CoolHarrison
    CoolHarrison Member Posts: 18
    10 Comments
    **

    You're totally right, it seems like I just implemented the journaling wrong. Yes the journaling fixed the the custon local sizing issue, and it appears that i must've thought I was responding to the drag and lift question. Thanks for the help, and I apologize for not responding sooner.