[GiDlist] using external mesher

Moderator: GiD Team

Post Reply
Andreas Friedberg

[GiDlist] using external mesher

Post by Andreas Friedberg »

Hi Enrique,

thanks for your quick response. I have implemtented the creation of a *.spd-file in the LoadGiDProject-procedure.

I need to use an external mesher from within gid and I want to automate the creation of the input file and the execution of the external mesher in a tcl procedure within the tcl file of my problemtype. What I need to do is following:

1) create in the project directory an input file called *.in for the mesher out of some data stored in global variables
2) move that input file to the problemtype directory where the mesher is
3) feed the input file into the mesher
4) move the output file of the mesher and the input file back to the project directory
5) read that output file into gid

My problem is that I don't know how to create an input file with the extension .in within the project directory, as the pathname of that directory always changes with the name of the project. What I need is something like the filespd-argument, but for a file called *.in.
Can I use the tcl-command exec to run a subprocess for the creation of the mesh file with the external mesher?

thanks for response, Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listas.cimne.upc.edu/pipermail/gidlist/attachments/20030127/e7303421/attachment.htm
Enrique Escolano

[GiDlist] using external mesher

Post by Enrique Escolano »

proc InitGIDProject { dir } {
global MyVarsPriv
#store the problemtype path inside a global variable
set MyVarsPriv(DirProblemType) $dir

}

proc ExternalMesher { } {
#for example, your own variables are stored in a array named MyVarsPriv
global MyVarsPriv
set projectname [lindex [.central.s info project] 1]
set filename $projectname.in
set fout [open $filename w]
#write your data in the file with the tcl command puts
#puts $fout $MyVarsPriv(Param)
close $fout

#copy this file from the model directory to the problemtype directory
set copyfilename [file join $MyVarsPriv(DirProblemType) [file tail $filename]]
file copy $filename $copyfilename

#run the external mesher, for example named "Mesher.exe" whit the input file as parameter
set mesher [file join $MyVarsPriv(DirProblemType) Mesher.exe]
exec $mesher $copyfilename

#copy the output , named for example out.msh from the problemtype directory to the model directory
file copy [file join $MyVarsPriv(DirProblemType) out.msh] $projectname.msh
#read the mesh file (if it is in ASCII GiD mesh format) inside GiD
.central.s process escape escape escape escape Files MeshRead $projectname.msh
}

Note: Instead copy the .in file inside the problemtype directory, it is best to call directly the mesher from the model directory
(It is possible that your user cannot have write permission inside the problemtype directory, but you can write inside your model directory).

cd [file dirname $filename]
set mesher [file join $MyVarsPriv(DirProblemType) Mesher.exe]
exec $mesher $filename
file rename out.msh $projectname.msh


Note: InitGIDProject, .central.s process and .central.s info are specific GiD/tcl commands,
the rest of code is standard tcl language.

Enrique Escolano
----- Original Message -----
From: Andreas Friedberg
To: GiD mailinglist
Sent: Monday, January 27, 2003 11:42 PM
Subject: [GiDlist] using external mesher


Hi Enrique,

thanks for your quick response. I have implemtented the creation of a *.spd-file in the LoadGiDProject-procedure.

I need to use an external mesher from within gid and I want to automate the creation of the input file and the execution of the external mesher in a tcl procedure within the tcl file of my problemtype. What I need to do is following:

1) create in the project directory an input file called *.in for the mesher out of some data stored in global variables
2) move that input file to the problemtype directory where the mesher is
3) feed the input file into the mesher
4) move the output file of the mesher and the input file back to the project directory
5) read that output file into gid

My problem is that I don't know how to create an input file with the extension .in within the project directory, as the pathname of that directory always changes with the name of the project. What I need is something like the filespd-argument, but for a file called *.in.
Can I use the tcl-command exec to run a subprocess for the creation of the mesh file with the external mesher?

thanks for response, Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listas.cimne.upc.edu/pipermail/gidlist/attachments/20030128/cc9ae52e/attachment.htm
Post Reply