Command-line TetGen meshing and preparing the mesh-complete directory
Command-line TetGen meshing and preparing the mesh-complete directory
Greetings to the SimVascular team,
I would like to use SimVascular through the command line. Right now, I have been doing the following steps in the GUI:
in the meshing tab:
1. load the .tgs script (tetgen script), the script already has the parameters (wall faces, max edge size, etc.) assigned, as well as the filename of the .vtp model to be used for the meshing
2. click the "Run Mesher" button and wait for the meshing to complete
3. click the "Write Files" button so that the files are written in the mesh-complete folder
Then, I can use the files generated in the mesh-complete folder to proceed with the simulation.
However, I cannot find any documentation on how to replicate those steps within the command-line. So I would like to just read the .tgs script, run the mesher, and write out the files. Is this possible, or would I need to write my own script for this?
Thank you very much and best regards,
Rok
I would like to use SimVascular through the command line. Right now, I have been doing the following steps in the GUI:
in the meshing tab:
1. load the .tgs script (tetgen script), the script already has the parameters (wall faces, max edge size, etc.) assigned, as well as the filename of the .vtp model to be used for the meshing
2. click the "Run Mesher" button and wait for the meshing to complete
3. click the "Write Files" button so that the files are written in the mesh-complete folder
Then, I can use the files generated in the mesh-complete folder to proceed with the simulation.
However, I cannot find any documentation on how to replicate those steps within the command-line. So I would like to just read the .tgs script, run the mesher, and write out the files. Is this possible, or would I need to write my own script for this?
Thank you very much and best regards,
Rok
- Adam Updegrove
- Posts: 236
- Joined: Fri Aug 30, 2013 4:11 pm
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Hi Rok,
Great question!
We do not have tutorials or very good documentation set up for this stuff, but it is possible.
Before starting SimVascular from the command line (if on mac or linux), run the command:
export SV_BATCH_MODE=1
Then start up SimVascular, and it will start up in batch mode without the GUI. You will be able to access the tcl commands of SimVascular from the command line.
To get an understanding of what commands you need to run, take a look at some of our example test scripts in our github:
https://github.com/SimVascular/SimVascular-Test
The steady_cylinder example for polydata-tetgen is a good place to start. I would also suggest starting by running stuff from the console in SimVascular before moving to the command line.
SimVascular Development Team
Great question!
We do not have tutorials or very good documentation set up for this stuff, but it is possible.
Before starting SimVascular from the command line (if on mac or linux), run the command:
export SV_BATCH_MODE=1
Then start up SimVascular, and it will start up in batch mode without the GUI. You will be able to access the tcl commands of SimVascular from the command line.
To get an understanding of what commands you need to run, take a look at some of our example test scripts in our github:
https://github.com/SimVascular/SimVascular-Test
The steady_cylinder example for polydata-tetgen is a good place to start. I would also suggest starting by running stuff from the console in SimVascular before moving to the command line.
SimVascular Development Team
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Hi Adam,
thank you very much for this. This way I was able to repeat the procedure inside the Simvascular console - I wrote the commands into a .tcl script and then entered "source myscript.tcl" which successfully did what I wanted.
Then I tried to do the same thing within the command line using the SimVascular batch mode, however running the command "solid_readNative" (with the correctly specified arguments) resulted in an error message "current kernel is not valid (5)". This command works fine inside the console.
I am using the latest Simvascular build (2.0.20404) from the SimVascular website, on OSX El Capitan, MBP 2015. Do you have any idea as to how to fix this issue?
Note: when starting SimVascular in batch mode, the console prints out "real batch mode not supported anymore", but otherwise simvascular seems to be running. Should I be using an earlier version perhaps?
Thank you very much and best regards,
Rok
thank you very much for this. This way I was able to repeat the procedure inside the Simvascular console - I wrote the commands into a .tcl script and then entered "source myscript.tcl" which successfully did what I wanted.
Then I tried to do the same thing within the command line using the SimVascular batch mode, however running the command "solid_readNative" (with the correctly specified arguments) resulted in an error message "current kernel is not valid (5)". This command works fine inside the console.
I am using the latest Simvascular build (2.0.20404) from the SimVascular website, on OSX El Capitan, MBP 2015. Do you have any idea as to how to fix this issue?
Note: when starting SimVascular in batch mode, the console prints out "real batch mode not supported anymore", but otherwise simvascular seems to be running. Should I be using an earlier version perhaps?
Thank you very much and best regards,
Rok
- Adam Updegrove
- Posts: 236
- Joined: Fri Aug 30, 2013 4:11 pm
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Hi Rok,
I think this warning shows up because you won't have access to all simvascular tcl functions, but you should still have access to all the tcl bound c++ functions (functions with -something before arguments. As you can see in the solid commands below).
Make sure you are setting the solid kernel before you load a model.
> solidSetKernel -name PolyData
> solidReadNative -file $yourfile -obj $yourobj
You may run into more issues going forward. You will have to look into the SimVascular source code for all the tcl bound c++ function calls.
We are currently working to try to make changes to allow more complete access to to tcl functionality.
SimVascular Development Team
I think this warning shows up because you won't have access to all simvascular tcl functions, but you should still have access to all the tcl bound c++ functions (functions with -something before arguments. As you can see in the solid commands below).
Make sure you are setting the solid kernel before you load a model.
> solidSetKernel -name PolyData
> solidReadNative -file $yourfile -obj $yourobj
You may run into more issues going forward. You will have to look into the SimVascular source code for all the tcl bound c++ function calls.
We are currently working to try to make changes to allow more complete access to to tcl functionality.
SimVascular Development Team
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Thanks, Adam. My script currently consists of solid_readNative (works fine, I was forgetting to set the kernel), mesh_readTGS (did not work until I manually copied the tetgen.tcl file into my working directoys and imported the script), and the last command, mesh_writeCompleteMesh (which also did not work until I manually copied the osmsc.tcl file into the working directory and imported it).
However, the last procedure, mesh_writeCompleteMesh, involves the vtkXMLPolyDataWriter command which is not found in the batch mode (it works in SimVascular's console) and so the procedure cannot write any files.
Do you happen to know a quick way of importing the VTK library so that I could use these commands? Othewise I could try to build the VTK source with TCL wrapping enabled and try to include that (though right now I have little experience with TCL stuff).
Thanks and best regards,
Rok
However, the last procedure, mesh_writeCompleteMesh, involves the vtkXMLPolyDataWriter command which is not found in the batch mode (it works in SimVascular's console) and so the procedure cannot write any files.
Do you happen to know a quick way of importing the VTK library so that I could use these commands? Othewise I could try to build the VTK source with TCL wrapping enabled and try to include that (though right now I have little experience with TCL stuff).
Thanks and best regards,
Rok
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Quick update: I was able to resolve the issue. I had to build the VTK with TCL wrapping, set the TCLLIBPATH environment variable and then run the simvascular_vtk_init.tcl script. With this, I was able to gain access to every needed command.
Again, thanks very much for the help. And regarding the future update where more tcl functionality is instantly available in the batch mode, I definitely agree this is a good idea.
Have a great day and best regards,
Rok
Again, thanks very much for the help. And regarding the future update where more tcl functionality is instantly available in the batch mode, I definitely agree this is a good idea.
Have a great day and best regards,
Rok
- Adam Updegrove
- Posts: 236
- Joined: Fri Aug 30, 2013 4:11 pm
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Good stuff! That is what I was about to suggest.
No problem. I will post here with any updates when we make changes for more complete functionality.
SimVascular Development Team
No problem. I will post here with any updates when we make changes for more complete functionality.
SimVascular Development Team
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Hi SimVascular team,
I installed the latest version of SimVascular on Mac OS Sierra, and I'm having problems running it in terminal again.
This time, I run it in batch mode as before and I run the init script (https://github.com/SimVascular/SimVascu ... k_init.tcl) but this one appears to be for version 2.0.
Consequently, the command "solid_setKernel -name PolyData" returns "invalid command name "solid_setKernel"".
What are the steps required for tetgen meshing in terminal for the new version?
Thanks and best regards
I installed the latest version of SimVascular on Mac OS Sierra, and I'm having problems running it in terminal again.
This time, I run it in batch mode as before and I run the init script (https://github.com/SimVascular/SimVascu ... k_init.tcl) but this one appears to be for version 2.0.
Consequently, the command "solid_setKernel -name PolyData" returns "invalid command name "solid_setKernel"".
What are the steps required for tetgen meshing in terminal for the new version?
Thanks and best regards
- Adam Updegrove
- Posts: 236
- Joined: Fri Aug 30, 2013 4:11 pm
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Hi Rok,
There is an additional step that you need to perform in batch mode now with SimVascular. SimVascular now loads the core functionality dynamically instead of statically. This allows portability and modularity in SimVascular functionality.
So, you will need to load all of SimVascular's core libraries dynamically through the tcl interface now prior to accessing the SimVascular tcl functions.
To do see how to do this, look at lines 120-160 of Tcl/SimVascular_2.0/simvascular_startup.tcl in the source. I've also attached the file here for convenience.
After you have loaded the libraries dynamically with the tcl load function, everything should run as it did before. Let me know if you have any questions!
SimVascular Development Team
There is an additional step that you need to perform in batch mode now with SimVascular. SimVascular now loads the core functionality dynamically instead of statically. This allows portability and modularity in SimVascular functionality.
So, you will need to load all of SimVascular's core libraries dynamically through the tcl interface now prior to accessing the SimVascular tcl functions.
To do see how to do this, look at lines 120-160 of Tcl/SimVascular_2.0/simvascular_startup.tcl in the source. I've also attached the file here for convenience.
After you have loaded the libraries dynamically with the tcl load function, everything should run as it did before. Let me know if you have any questions!
SimVascular Development Team
- Attachments
-
- simvascular_startup.tcl.txt
- (22.4 KiB) Downloaded 75 times
Re: Command-line TetGen meshing and preparing the mesh-complete directory
Hi Adam,
many thanks, using the first half of the provided .tcl script I was able to do the entire workflow without any additional script imports (as was previously required).
I'll write here if anything else comes up but for now I think this is it.
Thanks again and best regards,
Rok
many thanks, using the first half of the provided .tcl script I was able to do the entire workflow without any additional script imports (as was previously required).
I'll write here if anything else comes up but for now I think this is it.
Thanks again and best regards,
Rok