Difference between revisions of "Creating Setting up Windows 10 for OF use by Franco Otaola"

From OpenFOAM Wiki
Jump to navigation Jump to search
Line 15: Line 15:
  
 
==Setting up Windows 10==
 
==Setting up Windows 10==
 +
  
 
'''Open linux shell here:'''
 
'''Open linux shell here:'''
Line 37: Line 38:
  
 
These steps, will put the "open linux shell here" directly in the right click menu that can be helpful, all the credits for this tutorial to [https://winaero.com/make-open-linux-shell-always-visible this page].
 
These steps, will put the "open linux shell here" directly in the right click menu that can be helpful, all the credits for this tutorial to [https://winaero.com/make-open-linux-shell-always-visible this page].
 +
  
 
'''New text editor:'''
 
'''New text editor:'''
Line 51: Line 53:
  
 
Some last tips about Notepad++, by default it, the software "saves" the session, this meaning when we close the window and we re open it, it will open all the files that were previously opened. To change this behavior, we need to go to <TT>Settings>Preferences>Backup</TT> and turn it off. One last tip in setting up Notepad++, is to turn on the auto update file option, this will update the files each X minutes if it has been modified by and external source, to turn on this option we need to go to <TT>settings>preferences>MISC</TT>. and turn on "Update silently", "Scroll to last line after update". While we are here you can turn on Document switcher (Ctrl+Tab), with this we can add the Alt+Tab windows behavior but for the different files opened inside Notepad++.
 
Some last tips about Notepad++, by default it, the software "saves" the session, this meaning when we close the window and we re open it, it will open all the files that were previously opened. To change this behavior, we need to go to <TT>Settings>Preferences>Backup</TT> and turn it off. One last tip in setting up Notepad++, is to turn on the auto update file option, this will update the files each X minutes if it has been modified by and external source, to turn on this option we need to go to <TT>settings>preferences>MISC</TT>. and turn on "Update silently", "Scroll to last line after update". While we are here you can turn on Document switcher (Ctrl+Tab), with this we can add the Alt+Tab windows behavior but for the different files opened inside Notepad++.
 +
  
 
'''Setting up default text editor for extensionless files:'''
 
'''Setting up default text editor for extensionless files:'''
Line 71: Line 74:
  
 
All credits given to hasen from [https://superuser.com/questions/13653/how-to-set-the-default-program-for-opening-files-without-an-extension-in-windows this post].
 
All credits given to hasen from [https://superuser.com/questions/13653/how-to-set-the-default-program-for-opening-files-without-an-extension-in-windows this post].
 +
  
 
'''Creating bash scripts that uses trace scripts in paraview that are compatible to run in windows and in linux machines:'''
 
'''Creating bash scripts that uses trace scripts in paraview that are compatible to run in windows and in linux machines:'''
  
Sometimes we can use the trace tool in paraview to automatize the post processing of our case, and this can be quiet helpful in an annoying boring tasks. The trace tool will create automatically a python script that then can be run it with pvpython application from paraview and it will do all the tasks for us. As in case of paraFoam if the script will use the GUI of paraview, the command: << pvpython traceScript.py >> will not work. An easy way around to be able to use the trace scripts in our bash scripts that will work in either windows and linux is to create a conditional that will detect it the script is being run in windows (and therefore it will use the pvpython installed in paraview for windows) or run the pvpython installed in the linux computer. When we are working in WSL over a windows folder we have /mnt/ before the windows path.
+
Sometimes we can use the trace tool in paraview to automatize the post processing of our case, and this can be quiet helpful in an annoying boring tasks. The trace tool will create automatically a python script that then can be run it with pvpython application from paraview and it will do all the tasks for us. As in case of paraFoam if the script will use the GUI of paraview, the command: <TT><< pvpython traceScript.py >></TT> will not work. An easy way around to be able to use the trace scripts in our bash scripts that will work in either windows and linux is to create a conditional that will detect it the script is being run in windows (and therefore it will use the pvpython installed in paraview for windows) or run the pvpython installed in the linux computer. When we are working in WSL over a windows folder we have /mnt/ before the windows path.
 +
 
 +
if [[ "$(pwd | head -c 5)" = "/mnt/" ]];then
 +
echo "        - Running Windows paraview version"
 +
/mnt/c/Program\ Files/ParaView\ 5.9.0-Windows-Python3.8-msvc2017-64bit/bin/pvpython.exe traceScript.py
 +
else
 +
echo "        - Running Linux paraview version"
 +
pvpython traceScript.py
 +
fi

Revision as of 08:46, 18 June 2021

Go back to Collection by authors.

Go back to [1].

Setting up Windows 10 for OF use

In this tutorial some helpful tips for the setting up of a Windows 10 machine will be given. This steps are not essential for the use of OF in Windows but rather an improvement in usability and a speed improvement for the case setups. This tutorial will not touch the installation of OF in windows but rather steps to follow after its installation, for installation of OF in windows please refer to Installing OpenFOAM in Windows 10

Setting up Windows 10

Open linux shell here:

One option that I missed a lot from my linux computer was to navigate with the file explorer to my case and then simply by right click we can open the terminal in that folder location, without the need of "cd path". Once you installed your WSL in Windows 10 exists too, by default, we need to use Shift+right click in the folder, this will give us the “advanced” version of the contextual menu, give us more choices (and having the open linux shell here). For people that really want to use only the right click, we can add this option to the classic contextual menu of windows. For this, we need to install ExectTI (ExectTI) and then follow the steps:

  • Install ExectTi (to be able to modify the registry of windows with the highest privilege)
  • Run regedit.exe -m (this will open the regedit)
  • Go to HKEY_CLASSES_ROOT\Directory\shell\WSL
  • Remove the "Extended" value right click>delete
  • Go to HKEY_CLASSES_ROOT\Directory\Background\shell\WSL
  • Remove the "Extended" value right click>delete
  • Restart your computer if necessary

These steps, will put the "open linux shell here" directly in the right click menu that can be helpful, all the credits for this tutorial to this page.


New text editor:

Frequently in linux base system, the default text editors are more powerful than the windows default app, notepad, being able to automatically detect the language that the file is and highlighting the keywords. This utility can be quiet helpful for the modification of dictionary files as it allow us to see comments, vectors, loops, conditionals highlighted. The default windows app, is rather featureless, while it does the job, there are better suited free options out there. Notepad ++ (https://notepad-plus-plus.org/) is an excellent tool for an windows 10 OF user, it give us some life improvents when editing scripts and dictionaries, such as:

  • Line numbers, this can be rather helpful, a lot of times we need to know specifically the line number of an option inside an specific dictionary.
  • It can open several files at the same time in one windows in a tab-like style
  • Text highlight depending in the language (language > select specific language), at least from my experience, an OF user will at least use: C++ for the dictionaries and shell/python for scripting. It is possible to define a default language (Settings>New Document>Default language) I personally set up shell as I commonly find myself editing this type of files.
  • It can follow a log file (automatic update) while it is being generated. For this, open the log file in notepad++ and go to view>Monitoring (tail -f) or by clicking in the small eye icon. This as the brackets mentions will do exactly the same thing as using tail -f log.file in a terminal.

Some last tips about Notepad++, by default it, the software "saves" the session, this meaning when we close the window and we re open it, it will open all the files that were previously opened. To change this behavior, we need to go to Settings>Preferences>Backup and turn it off. One last tip in setting up Notepad++, is to turn on the auto update file option, this will update the files each X minutes if it has been modified by and external source, to turn on this option we need to go to settings>preferences>MISC. and turn on "Update silently", "Scroll to last line after update". While we are here you can turn on Document switcher (Ctrl+Tab), with this we can add the Alt+Tab windows behavior but for the different files opened inside Notepad++.


Setting up default text editor for extensionless files:

Something quiet annoying in Windows is that, if the file does not have any extension or that it has an unknown extension, windows will ask with which program we want to open the file. In the later case, when the file has an unknown extension we can set up a default app, but when the file does not have any extension it is not possible (by GUI) to set up a default app. Nevertheless, we can set up this with some command lines in the windows terminal to set up a default app for extensionless files:


  • Open the windows terminal
  • Run <<assoc .="No Extension" >> (without the << >>)
  • Then run <<ftype "No Extension"="C:\path\to\my editor.exe" "%1" >> (without the << >> and also modifying the path "C:\path\to\my editor.exe" with the text editor of our preference, for example if we use notepad++ with the default windows location: " ftype "No Extension"=^"^%ProgramFiles^%\Notepad++\notepad++.exe^" "%1""

If, for any reason we want to go back to the previews state, where windows ask us each time with which software to open the files we can follow the steps:

  • Open the windows terminal
  • Run << ftype "No Extension"=" >> (without the << >>)
  • Run << assoc "No Extension"\DefaultIcon= >> (without the << >>)
  • Run << assoc .= >> (without the << >>)

All credits given to hasen from this post.


Creating bash scripts that uses trace scripts in paraview that are compatible to run in windows and in linux machines:

Sometimes we can use the trace tool in paraview to automatize the post processing of our case, and this can be quiet helpful in an annoying boring tasks. The trace tool will create automatically a python script that then can be run it with pvpython application from paraview and it will do all the tasks for us. As in case of paraFoam if the script will use the GUI of paraview, the command: << pvpython traceScript.py >> will not work. An easy way around to be able to use the trace scripts in our bash scripts that will work in either windows and linux is to create a conditional that will detect it the script is being run in windows (and therefore it will use the pvpython installed in paraview for windows) or run the pvpython installed in the linux computer. When we are working in WSL over a windows folder we have /mnt/ before the windows path.

if head -c 5)" = "/mnt/" ;then echo " - Running Windows paraview version" /mnt/c/Program\ Files/ParaView\ 5.9.0-Windows-Python3.8-msvc2017-64bit/bin/pvpython.exe traceScript.py else echo " - Running Linux paraview version" pvpython traceScript.py fi