|
[Sponsors] |
[ICEM] How to get vertex location from script? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 12, 2013, 12:28 |
How to get vertex location from script?
|
#1 |
New Member
Adam Læssøe
Join Date: Nov 2013
Posts: 29
Rep Power: 13 |
As the title says.
How can I get the location ({x y z}) of a vertex? I have found Code:
ic_hex_point_location mypt04 I can do it through the GUI, by: [Left panel]>[Right click "Vertices"]>[Show vertex info]>[selection of vertex from screen] But that operation is not recorded by the record replay function. Any help is greatly appreciated. /adam |
|
December 13, 2013, 15:55 |
|
#2 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
I was looking for the same thing a few weeks ago and I never found a way in the scriting guide... I worked my way around with ic_hex_vertex_number { i j k } and another approach for blocking, cutting blocking, etc.
Keep us posted if you find the function. |
|
January 3, 2014, 07:41 |
|
#3 |
New Member
Adam Læssøe
Join Date: Nov 2013
Posts: 29
Rep Power: 13 |
Initially I worked around it by calculating where I had put each split and so on. After a while this became very annoying, so yesterday I made my own workaround.
The workaround requires to save the blocking (that you want to 'query') to file. In the blocking file, the coordinates of the vertices are also recorded, so using the vertex's ijk, I search through the entire blocking file. Now, there are some shortcomings:
There are two functions defined below, the first is a small helper routine to read a file into a variable using only one line. The second (get_vertex_location_from_blk) is where the parsing is done. Code:
# Read a file proc read_whole_file {file_name} { set fp [open "$file_name" r] set file_data [read $fp] close $fp return $file_data } # Read vertex location from file. # © Adam Andersen Læssøe, Jan, 2014 # Feel free to use or expand in any way you want, but provide credit. # Returns -1 if unsucsessful proc get_vertex_location_from_blk {vertex_number blk_file} { # In the sample file I looked at the ijk was only present on the line also specifying the coordinates. set ijk [ic_hex_vertex_ijk $vertex_number] # Wrap in braces to ensure uniqueness (the ijk might have some 'modifier' like "17:1") set ijk "\{ $ijk \}" # Read in the whole file. Carefull: if this is to be iterated over, it may become slow. # Consider rewriting to suit your needs, eg. by supplying the data as an input parameter, so it at least only has to read once. # file data set fd [read_whole_file $blk_file] set fd [split $fd "\n"] set n_lines [llength $fd] # set have_found_ijk 0 set i 0 while {[expr $i<$n_lines]} { # line data set ld [lindex $fd $i] #mess [lindex $fd $i] if {[string first $ijk $ld]!="-1"} { # Below two lines do not work. ICEM throws: 'Error: wrong # args: should be "try"' #try {return [lindices $ld {0 1 2}]} #on error {} {return -2} # Be naive and hope for the best (could raise out of range exception) return [lindices $ld {0 1 2}] } incr i } return -1 } |
|
January 3, 2014, 08:18 |
[solved]
|
#4 |
New Member
Adam Læssøe
Join Date: Nov 2013
Posts: 29
Rep Power: 13 |
Well isn't that just typical?! Cleaning up my open text tabs (using Sublime Text - awesome!), I came upon one I had forgot:
A list of commands that can be used in ICEM (to get it in ugly form type: info commands (and wait a while)). Searching that list for location - lo and behold - was: Code:
ic_hex_get_node_location Code:
ic_hex_get_node_location $my_vertex_unmber For your investigative pleasure, I have also attached the command list sorted alphabetically. |
|
Tags |
icem, scripting, tcl, vertex |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ill defined primitive entry 'boundary' | francisco.angel | OpenFOAM Pre-Processing | 16 | September 8, 2022 07:11 |
[mesh manipulation] Mesh Refinement | Luiz Eduardo Bittencourt Sampaio (Sampaio) | OpenFOAM Meshing & Mesh Conversion | 42 | January 8, 2017 13:55 |
[blockMesh] Include list of points | Hikachu | OpenFOAM Meshing & Mesh Conversion | 0 | June 20, 2011 10:03 |
[CAD formats] my stl surface is seen as just a line | rcastilla | OpenFOAM Meshing & Mesh Conversion | 2 | January 6, 2010 02:30 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 16:57 |