Geometry and mesh parameterization

Moderator: GiD Team

User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Geometry and mesh parameterization

Post by escolano »

Repeat this steps:
1- Download and install last GiD 12.1.2d (I am using the Windows x32 version, but could use other platforms)
2- Start GiD and go to menu Data->Problemtype->Debugger... (or press <F12>)
then ramdebugger must be opened
3- In ramdebugger open for example our GiD file scripts/Parametric.tcl
4- click the second line of the file "global ParametricPriv" and press a breakpoint with <F9> (or menu Debug->set breakpoint)
5- Press <F5> to start debuggin (the lower status bar of randebugger then show the word 'debug')
6- Go to GiD menu: Geometry->Create->Parametric line....
this command invoke the proc ParametricLine {} where the breakpoint was set, then the debugger must stop on this line, and you can investigate values, avance line by line with <F10> or continue with <F5>

It this doesn't work then do you have some problem that I don't know.
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Geometry and mesh parameterization

Post by eduardrocas »

That worked wonderfully, although I have GiD version 12.03 (evaluation version). Then, how is that it doesn't work with the "hello world" example you provided? Maybe I'm doing something wrong... I just open ramdebugger from GiD, copy your text and try to debug. The lower status bar of randebugger shows the word 'debug', but nothing happens.
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Geometry and mesh parameterization

Post by escolano »

Force the invocation of the procedure once it is 'instrumented for debug'

e.g. write in the lower command entry

Code: Select all

-np- my_test
(-np- is a special trick of this entry to say GiD that the line is a Tcl command, not GiD keywords to be processed)


or you can force the load of your file with the standard 'source' Tcl command:

Code: Select all

-np- source {your_full_path_to_your_file.tcl}
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Geometry and mesh parameterization

Post by eduardrocas »

It works wonderfully!

Thanks a lot! :D
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Geometry and mesh parameterization

Post by eduardrocas »

Hello,

in relation to your first post, where you described the two approaches for parameterization (approach "a" and "b"), I would like to ask:

"a" - In this approach, we can't run Tcl commands, right? Only GiD_Process commands, correct?

"b" - In this approach, how do we provide input arguments to the executed Tcl script?

In other words, what I would like to do is run GiD as a black-box, so that GiD interprets one Tcl script, and I can provide arguments to this Tcl script externally... and change them at every loop iteration. Which do you think would be the best approach?

Thanks,
Eduard
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Geometry and mesh parameterization

Post by escolano »

Option a) : you are right, the batch file is only a collection of GiD process commands, without any programming language.

Option b): you can invoke GiD from the command line with a -t <tcl_command> flag, to evaluate the command.

here you can see the command line options
http://www.gidhome.com/component/manual ... voking_gid

e.g. something like

gid.exe -t "MyCreateRectangle 10.1 5.4"

to evaluate the procedure MyCreateRectangle with parameters 10.1 and 5.4
The procedure must be first defined in GiD, for example because is one of our own procedures
You can load your own procedures in other ways, like put the files of your procedures in the \plugins folder
or directly source your file in the command line (source is a tcl standard procedure to load a tcl file)
e.g.
gid.exe -t "source {C:/tmp/my_file.tcl} ; MyCreateRectangle 10.1 5.4"
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Geometry and mesh parameterization

Post by eduardrocas »

That sounds very very good!

Thanks,
Eduard
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Geometry and mesh parameterization

Post by eduardrocas »

Hello,

I have tried the approach of invoking GiD from a batch file, specifying the Tcl procedure to run. It works great most of the times, however, when I make a FOR loop in the batch file to invoke GiD with a changing parameter, then sometimes (usually one in every 5 iterations) I get the following error:

"Error: ramdebugger not available: could not register port"

If I click on "Stack Trace", it says:
"could not register port while executing. "error" could not register port" (procedure ::commR::register line13) invoked from within "comm::register gid 1"

Do you know how to solve this?

Also, in a FOR loop we have many instances of "gid" running in parallel; I have also noticed that the GiD processes are not killed after running the batch file. The GiD process is killed if I only run one instance of it (the Tcl code closes GiD), but not if I run many instances in the FOR loop.

Thanks,
Eduard
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Geometry and mesh parameterization

Post by escolano »

ramdebugger and GiD processes are connected trough a socket, and there is a limit in this number of ports, but I think that the error message must not be a problem, because probably you are not trying to be debugging a lot of GiD's simultaneously.

The error said that the port can't be opened, but I think that GiD will run normally but without the debug option.

I thinkt that this problem is just because you are starting a lot of GiDs and they are never ending, then the maximum ports is reached.
When do you start a GiD in batch mode you must be careful to exist the process at the end sending to GiD something like:

Code: Select all

escape escape escape quit no
no is to answer the possible question of GiD to save a modified model.

else after doing all batch commands GiD will wait forever more commands

And another comment, if your Gids don't require any graphical feature, like save pictures, then you can try to start GiD with -n flag to be faster (then the GUI is not showed)
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Geometry and mesh parameterization

Post by eduardrocas »

Hello,

Thanks for your reply.

Actually I was already saving and then quitting GiD with the command you provided. I think the problem was the "ramdebugger" error, because GiD stops working. So what I did was commenting the following lines, in the "tclfile-opengl.tcl" file, so that Ramdebugger is not loaded:

Code: Select all

set ramdebuggerinside 1 ;#1 if is included with GiD, all packages are inside scripts
if { $ramdebuggerinside } {
    if { [catch {
        package require commR ;#modification (commR) of tcllib comm package
        comm::register gid 1    
    } err_txt] } {    
        set GidPriv(RamdebuggerMenuState) 0 ;#to hide it in menu
        bgerror "ramdebugger not available: $err_txt"
    } else {
        bind all <F12> {
            package require RamDebugger           
        }
    }
} else {
    #donde esta RamDebuger y tcl?
    if { $tcl_platform(platform) == "windows" } {
        lappend auto_path "E:/Programas/ActiveTcl8.4.9.0/lib"
        set where_RamDebugger "C:/gid project/scripts/ramdebugger"
        lappend auto_path ~/mytcltk
        set where_ActiveTcl_lib {E:/Programas/ActiveTcl8.4.9.0/lib/tcl8.4}
    } else {
        set where_RamDebugger "/home/miguel/GID/stuff/RamDebugger"
        set where_ActiveTcl_lib ""
    }

    
    # enter here the path where you have installed RamDebugger, subdirectory addons
    # for example: c:\Program files\RamDebugger\addons
    lappend auto_path [file join $where_RamDebugger addons]
    package require commR ;#modification (commR) of tcllib package
    comm::register gid 1
    
    bind all <F12> {
        # enter here the path where you have installed RamDebugger
        # for example: c:\Program files\RamDebugger
        lappend auto_path $where_RamDebugger
        if  { $where_ActiveTcl_lib != ""} {
            lappend auto_path $where_ActiveTcl_lib
            lappend auto_path [file join $where_ActiveTcl_lib tcl8.4]
        }
        package require RamDebugger
    }
}
It works very well now, but maybe there's a more elegant way of doing this? Although I'm happy with this solution.

Thanks,
Eduard
Post Reply