|
[Sponsors] |
[ICEM] Scripting - how to get the number of a point via x-location |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 18, 2013, 08:28 |
Scripting - how to get the number of a point via x-location
|
#1 |
New Member
Join Date: Nov 2013
Posts: 4
Rep Power: 12 |
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 |
|
November 19, 2013, 06:28 |
|
#2 |
Senior Member
Stuart Buckingham
Join Date: May 2010
Location: United Kingdom
Posts: 267
Rep Power: 25 |
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 |
|
November 19, 2013, 06:50 |
|
#3 | |
New Member
Adam Læssøe
Join Date: Nov 2013
Posts: 29
Rep Power: 12 |
Quote:
/adam |
||
November 19, 2013, 06:55 |
|
#4 |
Senior Member
Stuart Buckingham
Join Date: May 2010
Location: United Kingdom
Posts: 267
Rep Power: 25 |
Double Post, Sorry!
Last edited by stuart23; November 21, 2013 at 06:36. |
|
November 19, 2013, 08:03 |
|
#5 |
New Member
Join Date: Nov 2013
Posts: 4
Rep Power: 12 |
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! |
|
November 19, 2013, 15:37 |
|
#6 | |
New Member
Join Date: Nov 2013
Posts: 4
Rep Power: 12 |
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:
|
||
November 19, 2013, 19:07 |
|
#7 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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 ic_undo_group_begin ic_geo_new_family GEOM ic_boco_set_part_color GEOM ic_vid_object box8 GEOM 00 {0 0 0} 1 1 1 ic_set_dormant_pickable point 0 {} ic_set_dormant_pickable curve 0 {} ic_undo_group_end # initialize blocking ic_undo_group_begin ic_geo_new_family BLOCKING ic_boco_set_part_color BLOCKING ic_hex_initialize_blocking {} BLOCKING 0 101 ic_hex_switch_blocking root ic_hex_unblank_blocks ic_hex_multi_grid_level 0 ic_hex_projection_limit 0 ic_hex_default_bunching_law default 2.0 ic_hex_floating_grid off ic_hex_transfinite_degree 1 ic_hex_unstruct_face_type one_tri ic_hex_set_unstruct_face_method uniform_quad ic_hex_set_n_tetra_smoothing_steps 20 ic_hex_set_mesh_params BLOCKING GEOM -version 110 ic_hex_error_messages off_minor ic_hex_switch_blocking root ic_undo_group_end # cut blocking at x,y,z = 0.5,0,0 ic_undo_group_begin set vertex1 [ic_hex_vertex_number { 1 1 1 }] set vertex2 [ic_hex_vertex_number { 2 1 1 }] ic_point {} POINT split_point 0.5,0,0 ic_hex_split_grid $vertex1 $vertex2 split_point m BLOCKING ic_delete_geometry point names split_point 0 1 ic_undo_group_end - 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! |
|
November 21, 2013, 06:48 |
|
#8 | ||
Senior Member
Stuart Buckingham
Join Date: May 2010
Location: United Kingdom
Posts: 267
Rep Power: 25 |
Hey Saphyra,
You didn't do anything wrong. I somehow screwed up copy-pasting the code from ICEM into this forum.... Quote:
Quote:
|
|||
November 21, 2013, 07:02 |
|
#9 | |
Senior Member
Stuart Buckingham
Join Date: May 2010
Location: United Kingdom
Posts: 267
Rep Power: 25 |
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 |
||
November 22, 2013, 21:32 |
|
#10 |
New Member
Join Date: Nov 2013
Posts: 4
Rep Power: 12 |
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 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] How to define to right point for locationInMesh | Mirage12 | OpenFOAM Meshing & Mesh Conversion | 7 | March 13, 2016 14:07 |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 09:38 |
AMI interDyMFoam for mixer | danny123 | OpenFOAM Running, Solving & CFD | 4 | June 19, 2013 04:49 |
a reconstructPar issue | immortality | OpenFOAM Post-Processing | 8 | June 16, 2013 11:25 |
Stable boundaries | marcoymarc | CFX | 33 | March 13, 2013 06:39 |