pyFluent - Returns zone names while meshing

Alex
Alex Member Posts: 2
First Comment
**
edited June 2023 in Fluids

Hi!

I have been trying to construct a 'smart' meshing process which would query label/zone names and issue surface refinement depending on said names. Is there a command whose output would be all the zone names in a table or something?

Same question at but for the solver instead of the mesher.

Thanks you for your time!

Alex,

Skeleton code to help with understanding:

For name in zone_table:

if name contains "_ref03":

"meshing.workflow.TaskObject['Add Local Sizing'].Arguments.set_state({r'AddChild': r'yes',r'BOIFaceLabelList': [name],r'BOISize': ,})"

Comments

  • tletutour
    tletutour Member, Employee Posts: 1
    Ansys Employee First Comment
    ✭✭✭

    Hi,

    I don't know if this could help you ( I was trying to retrieve id/name correspondance for volumic zones) but there is an active_list command in fluent which returns zone names and their id. There is no pythonic way to get that resultthat I know of so you would need to record python stdout input like so :

    from contextlib import redirect_stdout
    
    meshing = pyfluent.launch_fluent(mode="meshing")
    meshing.tui.file.read_mesh(filename)
    
    f = io.StringIO()
    with redirect_stdout(f):
        meshing.tui.mesh.manage.active_list()
    # s now contains the output of the active_list command
    s = f.getvalue()
    


  • Alex
    Alex Member Posts: 2
    First Comment
    **
    edited May 2023

    All,

    The command below is working fine. Make sure to use the command from a python file (see code below). Do not use it from Fluent command line as it seems that the object "meshing" would be a bit different then.

    Hope this helps & thanks everyone for your help,

    Alex,

    SOLUTION

    meshing.scheme_eval.scheme_eval('(tgapi-util-convert-zone-ids-to-name-strings (get-face-zones-of-filter "*let*"))')


    Code that successfully tested the command

    import ansys.fluent.core as pyfluent

    meshing = pyfluent.launch_fluent(precision="double", processor_count=8, mode="meshing", show_gui=False)

    meshing.workflow.InitializeWorkflow(WorkflowType=r'Watertight Geometry')

    meshing.workflow.TaskObject['Import Geometry'].Arguments.set_state({r'FileName': r'C:/yourPath/yourFile.scdoc',"LengthUnit": "mm",})

    meshing.workflow.TaskObject['Import Geometry'].Execute()

    test = meshing.scheme_eval.scheme_eval('(tgapi-util-convert-zone-ids-to-name-strings (get-face-zones-of-filter "*let*"))')

    print(test)

    ['origin-inlet-nozzle', 'origin-outlet-duct', 'origin-wall-inlet-duct']


    My Environment just for information:

    Python3.10

    Pycharm

    pip list ansys-fluent-core

    Package Version

    ansys-api-fluent 0.3.5

    ansys-api-platform-instancemanagement 1.0.0b3

    ansys-fluent-core 0.12.3

    ansys-fluent-parametric 0.6.1

    ansys-fluent-visualization 0.6.0

    ansys-platform-instancemanagement 1.0.3

    appdirs 1.4.4

    certifi 2022.12.7

    charset-normalizer 3.0.1

    contourpy 1.0.7

    cycler 0.11.0

    fonttools 4.38.0

    googleapis-common-protos 1.58.0

    grpcio 1.51.1

    h5py 3.8.0

    idna 3.4

    imageio 2.25.1

    importlib-metadata 6.0.0

    kiwisolver 1.4.4

    matplotlib 3.7.0

    numpy 1.24.2

    packaging 23.0

    pandas 1.5.3

    Pillow 9.4.0

    pip 23.1.2

    pooch 1.6.0

    protobuf 3.20.3

    protoc-gen-swagger 0.1.0

    pyparsing 3.0.9

    PySide6 6.4.2

    PySide6-Addons 6.4.2

    PySide6-Essentials 6.4.2

    python-dateutil 2.8.2

    pytz 2022.7.1

    pyvista 0.38.2

    pyvistaqt 0.9.1

    QtPy 2.3.0

    requests 2.28.2

    scooby 0.7.1

    setuptools 65.5.0

    shiboken6 6.4.2

    six 1.16.0

    urllib3 1.26.14

    vtk 9.2.6

    zipp 3.14.0