CFD Online Discussion Forums

CFD Online Discussion Forums (
-   ANSYS Meshing & Geometry (
-   -   [ANSYS Meshing] Writing a Code for meshing in ICEM (

davidwilcox October 26, 2012 19:21

Writing a Code for meshing in ICEM
I am just about to undertake a huge task in terms of meshing. I am meshing a city. That's a lot of curves! I was wondering if there was a way to input in a code where you tell ICEM for example, I want x number of nodes on a curve of x metres. If I can do this, it will make life a whole lot merrier. Many thanks in advance.

stuart23 October 27, 2012 10:27

If you want x number of nodes on ALL curves, try this:

set no_nodes 20
foreach curves [ic_geo_get_objects curve ""] {ic_set_meshing_params curve $curves emax [expr "[ic_geo_crv_length $curves] / ($no_nodes - 1)"] emin 0 ehgt 0 edev 0 hrat 0 ] }

If you just want all curves to have a max size of x meters, try this:

set max_size 0.1
foreach curves [ic_geo_get_objects curve ""] {ic_set_meshing_params curve $curves emax $max_size emin 0 ehgt 0 edev 0 hrat 0 ] }

Obviously the first line in both codes is just the variable to be set, change it to whatever you need.


davidwilcox October 29, 2012 19:35

Thanks, Stu. I will give it a go. Hopefully it will work. :)

davidwilcox October 29, 2012 20:13

1 Attachment(s)
Hi Stu,
I loaded your script file for a simple 3d cube inside of a cube and it didnt work. It worked only for 2 curves. Is there anything else I need to do? I've uploaded the picture of the mesh.the outer box complied with your code but the inner one does not for some reason

davidwilcox November 26, 2012 04:29

ICEM SCRIPT no curve found
Hi Stu,
Thanks for your help. One more question. If let's say I have a curve named "oval", how do I put that into a command script in icem to let that curve have 20 nodes?
I have tried many ways but I always get an error saying " no curve named "oval". I am confused because I named a curve in my geometry oval but the ICEM script could not recognize it. Any suggestions?

Many thanks in advance.

stuart23 November 26, 2012 14:59


How did you create the curve?

I use the following command to create a line:
ic_curve FAMILY_NAME CURVE_NAME {point_name_1 point_name_2}

For an oval, you might have to do a B-spline (or stretch a circle)

Using the command line implicitly creates the curve with the specified name. I am not sure how you have named your curves though. To check the names, right click on lines under geometry and click "show names"

Good Luck


All times are GMT -4. The time now is 16:22.