CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (https://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [ANSYS Meshing] Automatic Script for Named Selections of a Volute (https://www.cfd-online.com/Forums/ansys-meshing/251256-automatic-script-named-selections-volute.html)

zacko August 4, 2023 08:18

Automatic Script for Named Selections of a Volute
 
1 Attachment(s)
Hello,

I'm trying to write a python script for ANSYS Meshing.
For now, the ANSYS Scripting guide for Mechanical does only help to a certain point.

What I try to achieve:
I want to automate the naming of faces of a volute. These are: Outlet, Interface, Symmetry and Walls.

I wrote the script to name the Outlet, Interface and Symmetry Face based on the face areas. For the symmetry, since it is the biggest plane, I used the function:
Code:

SelectionOperatorType.Largest
That works fine.

All other faces, that are not selected yet, shall be placed in a selection called Walls.

I tried it with putting every face into Walls first, using a face area > 0.0 mm. And then start the naming of the other faces. But, the other faces are sadly not excluded of the Walls selection afterwards.

Is there a good option about using connections? Or any other method?

Attached an image of an exemplary volute and the named selection up until now and the code. Also, I assume there must a better way to code my named selections.

Code:

sel = Model.AddNamedSelection()
sel.ScopingMethod=GeometryDefineByType.Worksheet

b3 = 0.3
D3 = 0.73
Dd = 0.8

bool_symmetry = True

if bool_symmetry == True:
    A_interface = 0.5*(pi * D3 * b3)
    A_discharge = 0.5*(pi/4 * Dd**2)
   

# DISCHARGE
sel.Name = "VOLUTE_OUTLET"
discharge = sel.GenerationCriteria
discharge.Add(None)
discharge[0].EntityType=SelectionType.GeoFace
discharge[0].Criterion=SelectionCriterionType.Size
discharge[0].Operator=SelectionOperatorType.RangeInclude
discharge[0].UpperBound = Quantity(A_discharge*1.01 ,"m m")
discharge[0].LowerBound = Quantity(A_discharge*0.99, "m m")
sel.Generate()


# SYMMTERY
sel_sym = Model.AddNamedSelection()
sel_sym.ScopingMethod=GeometryDefineByType.Worksheet

sel_sym.Name = "VOLUTE_SYMMETRY"
symmetry = sel_sym.GenerationCriteria
symmetry.Add(None)
symmetry[0].EntityType=SelectionType.GeoFace
symmetry[0].Criterion=SelectionCriterionType.Size
symmetry[0].Operator=SelectionOperatorType.Largest

sel_sym.Generate()


# INTERFACE
sel_itf = Model.AddNamedSelection()
sel_itf.ScopingMethod=GeometryDefineByType.Worksheet

sel_itf.Name = "VOLUTE_INTERFACE"
interface = sel_itf.GenerationCriteria
interface.Add(None)
interface[0].EntityType=SelectionType.GeoFace
interface[0].Criterion=SelectionCriterionType.Size
# I use RangeInclude, because the Equal command does not find the face (maybe rounding error?)
interface[0].Operator=SelectionOperatorType.RangeInclude
interface[0].UpperBound = Quantity(A_interface*1.01 ,"m m")
interface[0].LowerBound = Quantity(A_interface*0.99, "m m")
sel_itf.Generate()

Maybe you have better resources of ANSYS that I haven't found yet?
Thank you for your help.

Daniel


All times are GMT -4. The time now is 03:13.