Scripting - how to get the number of a point via x-location
Hi everyone,
I've just started to use ICEM CFD, so I'm sorry, if my question is too simple. But to be honest, after using ANSYS APDL for a long time, the coding in ICEM CFD is a little bit confusing. Right now I'm trying to script automated meshing of different airfoils with different amount of formatted data points. At some point of the process, I have to split my block while selecting one point at the trailing edge. Of course, if I have a different amount of formatted data points, the numbering of the two points on the trailing edge will change. Now my question: how can I get the number of one of these two points, to save it in a parameter - so that I can access it in my script later (without always changing the point number in the script file)? Since the y-location of the trailing edge changes, it should be somehow possible to select a point just via x-location if there aren't any other points in the y-axis, right? Summing up, I'm searching for a command equal to the *get-command in ANSYS APDL. ^ ^ Thanks for your help. Yours sincerely, Saphy |
Try:
foreach test_point [ic_geo_get_objects point _PART_NAME_] {if {[ic_geo_get_point_location $test_point] _COORD_INDEX_] == _COORD_VALUE_} {[ic_hex_split_grid _BLOCK_INDICIES_ ; break}} Replace: _PART_NAME_ with the part that you want to search for the point in. If the point could be in any part, replace with "" (ie 2 double quotation marks) _COORD_INDEX_ with the index your searching. Ie if you want to find a point where x = 7.5, replace with 0. If your searching for a Y value, replace with 1. And if your searching for a Z value....... You guessed it! Replace with 2. _COORD_VALUE_ with the coordinate value you are searching for ie if you want X = 7.5, replace with 7.5 _BLOCK_INDICIES_ with the two verticies you wish to split between. As you are creating your blocking in batch, the two verticies you are splitting between will be persistant. Note, this script will only search for the first instance of a point that matches the condition. If instead you want to split at ALL points with an X value of 0, remove the break after the split. For your example, if you wanted to split at a point in part GEOM where X=0, and the split goes between verts 67 & 89: foreach test_point [ic_geo_get_objects point GEOM] {if {[ic_geo_get_point_location $test_point] 0] == 0} {[ic_hex_split_grid 67 89 ; break}} EASY! TclTk programming is EXTREAMLY powerful. People have even programmed up custom interfaces for ICEM so that they can perform all their custom functions using ICEM's powerful geom, hexa and unstructured tools without loading the ICEM GUI. Stu |
Quote:
/adam |
Double Post, Sorry!
|
Oh, that looks great! I will try it out later, when I'm at my work station. But just by looking at it - is it right, that you create a for-loop through an array filled with all of the points of my geometry. Then you ask, if there is a point, which has the wanted coordinate value in the wanted xyz-direction, and to split the block at this particular point or to stop the if-command, if there isn't?
I hope, I did understand the code right. But let me ask you - are there missing brackets in the code after the ic_hex_split_grid-command (just before the semikolon) and also before the ic_geo_get_point_location-command? And can you recommend a link or whatsoever, where I can find a tutorial for TclTk? Actually TclTk seems really powerful and just with the ICEM-Programmer's guide not everything - especially the basics - is understandable. With my little knowledge about it I was just able to count all of my points, and to calculate the point name (p_count/2-1). But this would be extremely bad regarding that sometimes the point numbering isn't equal in the airfoil data. Therefore I should learn more about TclTk I guess. :) Thank you so much for your help! |
Ok, I implemented the code in my scripting replay file, while adding some extra brackets to supress other warnings like "missing bracket". But actually I do get the following additional error warning:
Quote:
|
Instead of searching for a point, just create one where you want to split the block and then delete it! Here is the code that I suggest, run it and see what it does:
Code:
# draw a cube - you have to keep track of the blocking index as you cut the blocking and look for vertex numbers with ic_hex_vertex_number, it's easy - I'm not sure if ic_undo_group_begin/end are of any use! |
Hey Saphyra,
You didn't do anything wrong. I somehow screwed up copy-pasting the code from ICEM into this forum.... Quote:
Quote:
|
Quote:
Your understanding is 99% correct. Instead of the break referring to the if command, it breaks the foreach loop so that it does not continue to look for more points. This is to stop the code from trying to split the block a second time after it has already been split. It is not possible to perform a split twice anyway though, because there will no longer be a single edge that joins vertices 21 & 22 (or whatever you specified) as you will have already split that edge. Therefore the break is just there for programming best practices and to stop an error being displayed in the case that it did find two points. For a great Tcltk reference, I would recommend http://www2.tcl.tk . They have a great function help resource, and I think there might be some tutorials, defiantly bookmark the site! In ICEM, try using Replay Control to record what you want to do if you don't know how to do it. That way you have a basis, rather than coding from scratch. Tcltk is a very easy language to understand, as the syntax is so straightforward. It is very high level, which makes it very easy to use (for example, the foreach function; easy to understand and implement). It is also used in many different programs, so the time you spend learning it for ICEM will pay off in other areas. Stu |
Thank you so much for your help. The new code worked out very well, so that I could also implement other codes, just like searching for the point with the maximum y-location on the profile without knowing the exact y-value etc. You're right, TclTk becomes easier the more you work with it. But for one problem I didn't find the solution yet. For example if I want to change the mesh parameters with the bigeometric mesh law, the code is something like:
Code:
ic_hex_set_mesh 11 13 n 10 h1 0.0001 h2 0 r1 1.2 r2 2 lmax 0 default unlocked |
All times are GMT -4. The time now is 19:56. |