The option to create the structured grid of quadrilaterals from a file with XYZ coordinates not exists, because in general these XYZ could be unstructured.
But importing XYZ files exists an option to create a Delaunay mesh of triangles that connect your points. This option is more general and works also for unstructured clouds of points.
You can convert the XYZ into geometrical or mesh entities (Files-Import-XYZ points or Files-Import-XYZ nodes)
To create the triangles, in the window that select the filename you must click the “Import options” arrow, and select the “Triangulate” checkbox
(Note: the triangulation is created projecting the 3D coordinates to the Z=0 plane)
A tool that could be interesting to you is Geometry-Create-NURBS surface-By points…, and select the points.
It create a NURBS surface that approximate smoothly a cloud of irregular points, and you can remesh this surface again to have a structured mesh of quadrilaterals.
Finally, with Tcl/Tk scripting it is relativelly easy to read a XYZ ASCII file, and create the structured mesh, assumig that the XYZ are structured also.
This is a procedure that to this, (in fact is a little more general, because it accepts if the rectangle of the XYZ grid are rotated an angle in the XY plane)
I copy two procedures, one that really do the task, and another that allow you to select the filename with a filebrowser window.
#assumed that is a grid (can be rotated) in x,y and try to detect
#the number of rows, cols and rotation angle
proc ReadGridRotated { filename } {
variable RAD_TO_DEGREE
if { ![file exists $filename] } {
return 1
}
set fp [open $filename r]
set all [split [read $fp] \n]
close $fp
set prevnpoin [GiD_Info mesh MaxNumNodes]
set xprev “”
set d2ref 0
set nx -1
set i 1
foreach line $all {
if { $line == “” } continue
foreach {x y z} $line break
if { ![string is double $z] || $z == “” } {
set z 0
} else {
set z [expr -1*$z]
}
GiD_Mesh create node append “$x $y $z”
if { $nx== -1 && $xprev != “” } {
set d2 [expr {($x-$xprev)($x-$xprev)+($y-$yprev)($y-$yprev)}]
if { $d2ref == 0 } {
set d2ref [expr {$d2*1.1}]
} else {
if { $d2$d2ref } {
set nx [expr {$i-1}]
}
}
}
set xprev $x
set yprev $y
incr i
}
unset all
set newnpoin [expr {[GiD_Info mesh MaxNumNodes]-$prevnpoin}]
set ny [expr {$newnpoin/$nx}]
set p1 [GiD_Info mesh nodes [expr {$prevnpoin+1}]]
set p2 [GiD_Info mesh nodes [expr {$prevnpoin+$nx}]]
set vx [expr {[lindex $p2 1]-[lindex $p1 1]}]
set vy [expr {[lindex $p2 2]-[lindex $p1 2]}]
set angle [expr {acos(double($vx)/sqrt($vx*$vx+$vy*$vy))*$RAD_TO_DEGREE}]
set et quadrilateral
set nn 4
for { set j 1 } { $j$ny } { incr j } {
for { set i 1 } { $i$nx } { incr i } {
set p [expr {($j-1)*$nx+$i+$prevnpoin}]
GiD_Mesh create element append $et $nn “$p [expr {$p+1}] [expr {$p+$nx+1}] [expr {$p+$nx}]”
}
}
return [list $nx $ny $angle]
}
proc ReadGridRotatedWindow { } {
variable gridfilename
if { ![info exists gridfilename] } {
set gridfilename “”
}
set types [list [list [= “Grid ASCII file”] “.dat”] [list [_ “All files”] “.*”]]
set defaultextension .dat
set title [= “Read grid ASCII file”]
set gridfilename [Browser-ramR file read .gid $title $gridfilename $types $defaultextension 0]
if { $gridfilename != “” } {
set t0 [clock seconds]
GidUtils::WaitState .
set res [ReadGridRotated $gridfilename]
foreach “nx ny angle” $res break
GidUtils::EndWaitState .
GidUtils::SetWarnLine [= “Time= %s seconds, %sx%s angle=%s degrees”
[expr [clock seconds]-$t0] $nx $ny $angle]
if { [GiD_Info project ViewMode] != “MESHUSE” } {
GiD_Process Mescape Meshing MeshView escape
}
GiD_Process Zoom Frame
#GiD_Redraw
}
}
#invoke the window
ReadGridRotatedWindow
You can create for example add a macro button to the macro buttons toolbar and paste my blue code to be invoked by this button.
Another simple way to test it is to save the blue code in a file (e.g. in “C:\tmp\myfile.tcl”), and write this in the lower command line of GiD to load it:
-np- source {C:\tmp\myfile.tcl}
Regards
Enrique Escolano
----- Original Message -----
From: “Guillaume De Nayer” denayer at hsu-hh.de
To: gidlist at listas.cimne.upc.edu
Sent: Tuesday, July 09, 2013 2:30 PM
Subject: [GiDlist] Import a structured grid (X,Y,Z coordinates) into GiD
Hi,
I’m new on this list, but I’m using GiD for 2 years.
Here is my problem:
I have a file containing a structured grid (just the X, Y, Z
coordinates). I can import this file into GiD, but I get only the nodes
shown.
Is it possible to generate a structured grid from the given coordinates
in the file in GiD ?
If yes, what must be done ?
Best Regards,
Guillaume
GiDlist mailing list
GiDlist at listas.cimne.upc.edu
_http://listas.cimne.upc.edu/cgi-bin/mailman/listinfo/gidlist_
-------------- next part --------------
An HTML attachment was scrubbed…
URL: http://listas.cimne.upc.edu/pipermail/gidlist/attachments/20130709/be60dac6/attachment.htm