<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on ctsolakis.com</title><link>https://ctsolakis.com/blog/</link><description>Recent content in Posts on ctsolakis.com</description><generator>Hugo</generator><language>en-us</language><managingEditor>ctsol001@odu.edu (Christos Tsolakis)</managingEditor><webMaster>ctsol001@odu.edu (Christos Tsolakis)</webMaster><lastBuildDate>Sat, 12 Apr 2025 21:23:37 -0400</lastBuildDate><atom:link href="https://ctsolakis.com/blog/index.xml" rel="self" type="application/rss+xml"/><item><title>Automate Installation of Multiple Binary packages 2</title><link>https://ctsolakis.com/2025/04/12/automate-installation-of-multiple-binary-packages-2/</link><pubDate>Sat, 12 Apr 2025 21:23:37 -0400</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2025/04/12/automate-installation-of-multiple-binary-packages-2/</guid><description>&lt;p>In a previous &lt;a href="https://ctsolakis.com/2023/10/07/automate-installation-of-multiple-binary-packages/">post&lt;/a> we saw how to automate installation of different versions of ParaView and give each one its own icon and menu entry.&lt;/p>
&lt;p>What if we want to add a new version without re-downloading all the previous ones ?&lt;/p>
&lt;p>We need to:&lt;/p>
&lt;ol>
&lt;li>Find which versions we already have&lt;/li>
&lt;li>Store this information&lt;/li>
&lt;li>Skip steps for the ones we have&lt;/li>
&lt;/ol>
&lt;p>Although, these sound obvious it took quite some time to find the proper way to do it in ansible, hence this note.&lt;/p></description></item><item><title>Automate Installation of Multiple Binary packages</title><link>https://ctsolakis.com/2023/10/07/automate-installation-of-multiple-binary-packages/</link><pubDate>Sat, 07 Oct 2023 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2023/10/07/automate-installation-of-multiple-binary-packages/</guid><description>&lt;p>As a ParaView developer it is useful to keep multiple versions of ParaView
installed so that testing for regressions becomes quick and easy. I used to
just drop the binaries from &lt;a href="https://www.paraview.org/download/">https://www.paraview.org/download/&lt;/a> right into an
&lt;code>~/opt&lt;/code> directory, and add custom launchers with
&lt;a href="https://github.com/bluesabre/menulibre">menulibre&lt;/a>. To differentiate between
versions I would edit the icon with Gimp so that it includes the corresponding
ParaView version.&lt;/p>
&lt;p>Since I started using ansible to set up different VMs and machines it became
natural to look for an opportunity to use it everywhere.
In this case the goal is:&lt;/p></description></item><item><title>Organizing build commands in cmake with profiles</title><link>https://ctsolakis.com/2022/11/09/organizing-build-commands-in-cmake-with-profiles/</link><pubDate>Wed, 09 Nov 2022 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2022/11/09/organizing-build-commands-in-cmake-with-profiles/</guid><description>&lt;p>When dealing with a C/C++ project that utilizes &lt;a href="https://cmake.org">cmake&lt;/a> one
will sooner or later need to organize the available build options into profiles
than enable multiple features in a convenient manners. Two of the ways to
achieve that is the use of cmake
&lt;a href="https://cmake.org/cmake/help/book/mastering-cmake/chapter/CMake%20Cache.html">cache&lt;/a>
files and cmake
&lt;a href="https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html">presets&lt;/a>.&lt;/p>
&lt;p>Let&amp;rsquo;s start with setting a common ground for this test using the &lt;a href="https://gitlab.kitware.com/vtk/vtk">vtk&lt;/a>
repository:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">git clone https://gitlab.kitware.com/vtk/vtk
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cd vtk/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git switch -d v9.1.0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git submodule init
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git submodule update --recursive
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>VTK has already a number of documented build
&lt;a href="https://gitlab.kitware.com/vtk/vtk/-/blob/v9.1.0/Documentation/dev/build.md">options&lt;/a>
on top of the ones that cmake provides for every project.&lt;/p></description></item><item><title>Generating compile commands with cmake</title><link>https://ctsolakis.com/2020/07/13/cmake-export-compile-commands/</link><pubDate>Mon, 13 Jul 2020 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2020/07/13/cmake-export-compile-commands/</guid><description>&lt;p>&lt;a href="https://www.cmake.org">cmake&lt;/a> offers the option to generate a
&lt;a href="https://clang.llvm.org/docs/JSONCompilationDatabase.html">compilation database in json format&lt;/a>
using the option &lt;code>CMAKE_EXPORT_COMPILE_COMMANDS=YES&lt;/code>. The database holds
essentially the command, paths and compilers flags used to compile each file of
a project. The generated file (usually called &lt;code>compile_commands.json&lt;/code>) can be
used in conjunction with various code completion tools like
&lt;a href="http://ycm-core.github.io/YouCompleteMe/">YouCompleteMe&lt;/a> and Visual Studio&amp;rsquo;s
&lt;a href="https://code.visualstudio.com/docs/cpp/faq-cpp#_how-do-i-get-intellisense-to-work-correctly">IntelliSense&lt;/a>
in order to offer more complete information, completion and errors about the
code.&lt;/p></description></item><item><title>The official cmake tutorial</title><link>https://ctsolakis.com/2020/06/29/cmake-official-tutorial/</link><pubDate>Mon, 29 Jun 2020 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2020/06/29/cmake-official-tutorial/</guid><description>&lt;p>There are many resources, posts and articles about using
&lt;a href="https://www.cmake.org">cmake&lt;/a> and writing modern cmake code. Unfortunately
for a new user it is sometimes difficult to locate the proper resource that contains
no deprecated options or any other non-recommended practices. One of the quickest and
simplest resource I became aware recently is the official &lt;a href="https://cmake.org/cmake/help/latest/guide/tutorial/index.html">tutorial&lt;/a>
that lives in the documentation of &lt;a href="https://cmake.org/cmake/help/latest/index.html">cmake&lt;/a>.&lt;/p></description></item><item><title>Using ccache to speedup compilation of C/C++</title><link>https://ctsolakis.com/2020/06/23/ccache-with-ccmake/</link><pubDate>Tue, 23 Jun 2020 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2020/06/23/ccache-with-ccmake/</guid><description>&lt;p>&lt;a href="https://ccache.dev/">ccache&lt;/a> is a utility that caches intermediate files during
compilation offering significant speedups. It is especially useful if you
are switching between two branches of the same project see below.&lt;/p>
&lt;p>To use it, prepend it before the compiler i.e. Use &lt;code>ccache gcc&lt;/code> instead of
&lt;code>gcc ...&lt;/code> . If you are using &lt;a href="https://cmake.org">cmake&lt;/a> with a version greater
that 3.4 you can use the option &lt;code>-DCMAKE_CXX_COMPILER_LAUNCHER=ccache&lt;/code> for
older version you can modify the compiler settings or use the variable
&lt;code>RULE_LAUNCH_COMPILE&lt;/code> for more see
&lt;a href="https://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake">here&lt;/a>.&lt;/p></description></item><item><title>Change pixels in 2D/3D images</title><link>https://ctsolakis.com/2020/02/20/itk-change-pixel/</link><pubDate>Thu, 20 Feb 2020 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2020/02/20/itk-change-pixel/</guid><description>&lt;p>Similar to an older &lt;a href="https://ctsolakis.com/2015/03/18/remove-white-pixels/">post&lt;/a>.
One can modify 2D/3D images in order to
change specific pixels /voxels. This became useful recently while trying to
remove a tissue from a segmented image. For something more complicated you may
want to use Slicer, but for simple cases like this a python script enough.
Appended you can also find the corresponding C++ code. Keep in mind that python
handles all supported PixelTypes automatically while for the C++ one needs
to update the PixelType typedef and the dimension variable.&lt;/p></description></item><item><title>Thousands separator in C++</title><link>https://ctsolakis.com/2019/10/08/thousands-separator-cpp/</link><pubDate>Tue, 08 Oct 2019 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2019/10/08/thousands-separator-cpp/</guid><description>&lt;p>As you print more and more numbers in the screen it may become cumbersome
to count digits just to see is if you are in the range of millions or 100&amp;rsquo;s of
millions. Visually grouping digits can simmplify things. There is
a pleathora of ways to do this in C++ but the one I find the best is the one provided
by the standand C++ library through the &lt;code>std::numpunct&lt;/code> object. Here is a small example that uses groups digits using commas.&lt;/p></description></item><item><title>#ifdef in Latex documents</title><link>https://ctsolakis.com/2019/06/11/ifdef-in-latex/</link><pubDate>Tue, 11 Jun 2019 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2019/06/11/ifdef-in-latex/</guid><description>&lt;p>Consider the case where you want to generate slightly different versions of a
document out of single latex file. This could be needed when using different
document templates or if you want to switch on/off commentary in your document. You may want
different introduction or order of chapters based on each particular case. A way
to do it is using conditionals that exists available in plain TeX. For example&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-latex" data-lang="latex">&lt;span class="line">&lt;span class="cl">&lt;span class="k">\documentclass&lt;/span>&lt;span class="nb">{&lt;/span>article&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\newif\ifanswers&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">%\answerstrue 
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">&lt;/span>&lt;span class="k">\begin&lt;/span>&lt;span class="nb">{&lt;/span>document&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">question : what is the expected complexity of quicksort for an array of integers ?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\vspace&lt;/span>&lt;span class="nb">{&lt;/span>1cm&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\ifanswers&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">answer &lt;span class="s">$&lt;/span>&lt;span class="nb">o&lt;/span>&lt;span class="o">(&lt;/span>&lt;span class="nb">n&lt;/span>&lt;span class="nv">\log&lt;/span>&lt;span class="nb"> n&lt;/span>&lt;span class="o">)&lt;/span>&lt;span class="s">$&lt;/span> where &lt;span class="s">$&lt;/span>&lt;span class="nb">n&lt;/span>&lt;span class="s">$&lt;/span> is the numer of integers.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\fi&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\vspace&lt;/span>&lt;span class="nb">{&lt;/span>1cm&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">question : give the definition of an abelian group .
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\vspace&lt;/span>&lt;span class="nb">{&lt;/span>1cm&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\ifanswers&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">answer : an abelian group is a set, &lt;span class="s">$&lt;/span>&lt;span class="nb">a&lt;/span>&lt;span class="s">$&lt;/span>, together with an operation &lt;span class="s">$&lt;/span>&lt;span class="nv">\cdot&lt;/span>&lt;span class="s">$&lt;/span> that ...
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\vspace&lt;/span>&lt;span class="nb">{&lt;/span>1cm&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\fi&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">\end&lt;/span>&lt;span class="nb">{&lt;/span>document&lt;span class="nb">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Enabling conditionals can be achieved by commenting/uncommenting
the 3rd line either by hand or using a makefile:&lt;/p></description></item><item><title>Keep running until crash with gdb</title><link>https://ctsolakis.com/2019/03/21/rerun-until-crash-gdb/</link><pubDate>Thu, 21 Mar 2019 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2019/03/21/rerun-until-crash-gdb/</guid><description>&lt;p>Many times when trying to catch a bug , or to validate that your parallel code
runs correctly you wish to run your code again and again and again until break on an assertion
or even better until you persuade yourself that your code is good enough. Once more,
stakoverflow has the answer for us:&lt;/p>
&lt;pre>&lt;code>set $n = 100
while $n-- &amp;gt; 0
 printf &amp;quot;starting program\n&amp;quot;
 run
 if $_siginfo
 printf &amp;quot;Received signal %d, stopping\n&amp;quot;, $_siginfo.si_signo
 loop_break
 else
 printf &amp;quot;program exited\n&amp;quot;
 end
end
&lt;/code>&lt;/pre>
&lt;p>If you use it often save it in a file and launch it using&lt;/p></description></item><item><title>How about stopping sending your public keys ?</title><link>https://ctsolakis.com/2019/03/19/how-about-stopping-sending-your-public-keys/</link><pubDate>Tue, 19 Mar 2019 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2019/03/19/how-about-stopping-sending-your-public-keys/</guid><description>&lt;p>Did you know that when connecting to a server wish &lt;code>ssh&lt;/code> it will first send &lt;strong>all&lt;/strong> your public ssh keys and then
it will promt you for a password ? Sure it is just public keys, but still. See here for more &lt;a href="https://github.com/FiloSottile/whosthere">https://github.com/FiloSottile/whosthere&lt;/a>&lt;/p></description></item><item><title>Adding support for new mesh formats in ParaView</title><link>https://ctsolakis.com/2018/11/25/adding-support-new-mesh-formats-paraview/</link><pubDate>Sun, 25 Nov 2018 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2018/11/25/adding-support-new-mesh-formats-paraview/</guid><description>&lt;p>The architecture of ParaView allows extending its functionality by creating
plugins which can be loaded as dynamic libraries without recompiling ParaView.&lt;/p>
&lt;p>The main mesh filetypes we are handling in our lab are
&lt;a href="http://www.simcenter.msstate.edu/software/downloads/doc/ug_io/3d_grid_file_type_ugrid.html">&lt;code>.ugrid&lt;/code>&lt;/a>
generated by AFLR3 and used widely within FUN3D,
&lt;a href="https://github.com/LoicMarechal/libMeshb/blob/master/Documentation/libMeshb7.pdf">&lt;code>.meshb&lt;/code>&lt;/a>
from INRIA Gamma Team and &lt;a href="https://su2code.github.io/docs_v7/Mesh-File">&lt;code>.su2&lt;/code>&lt;/a>
from the SU2 solver. Unfortunately there is no support for these from
Paraview. Fortunately there is documentation for creating readers (&lt;a href="https://www.paraview.org/Wiki/ParaView/Plugin_HowTo">plugin
guides&lt;/a>).&lt;/p>
&lt;p>Here is the boilerplate for writting a reader for an unstructred grid based on the &lt;a href="https://www.paraview.org/Wiki/Writing_ParaView_Readers">Paraview wiki&lt;/a>.&lt;/p></description></item><item><title>Podcast series on history of AI</title><link>https://ctsolakis.com/2018/09/30/thinking-machines-podcast/</link><pubDate>Sun, 30 Sep 2018 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2018/09/30/thinking-machines-podcast/</guid><description>&lt;p>In this series created by the &lt;a href="https://wondery.com/">wondery&lt;/a> network the host will transport you to the days or early AI, from the lonely &lt;a href="https://en.wikipedia.org/wiki/ELIZA">ELIZA&lt;/a>, to Apple&amp;rsquo;s Siri, and from &lt;a href="https://en.wikipedia.org/wiki/Deep_Blue_(chess_computer)">Deep Blue&lt;/a> to &lt;a href="https://en.wikipedia.org/wiki/AlphaGo">AlphaGo&lt;/a>.&lt;/p>
&lt;p>&lt;a href="https://art19.com/shows/american-innovations-podcast/episodes/6b47f3a6-075e-4489-965b-bf8adbb8f1fa">Episode 1 : Thinking Machines : Artificial Intelligence&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://art19.com/shows/american-innovations-podcast/episodes/27dc1eb9-114f-4d21-921c-f78351a468c8">Episode 2 : Thinking Machines : How Do You Make a Computer Blink&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://art19.com/shows/american-innovations-podcast/episodes/af86982e-5a62-45ae-b225-7a5eba1269e6">Episode 3 : Thinking Machines : Siri-ous Business&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://art19.com/shows/american-innovations-podcast/episodes/fb8dba7a-6918-4167-85b6-8f8ce460f267">Episode 4 : Thinking Machines : I learn Therefore I am&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://art19.com/shows/american-innovations-podcast/episodes/421bbb6c-3076-4172-8f34-8e5826f81d65">Episode 5 : Thinking Machines : Passing For Human&lt;/a>&lt;/p></description></item><item><title>Extract Cell types from mesh in Paraview</title><link>https://ctsolakis.com/2018/04/17/extract-cell-types-paraview/</link><pubDate>Tue, 17 Apr 2018 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2018/04/17/extract-cell-types-paraview/</guid><description>&lt;p>It is often usefull to select cells by their type for visualization in
Paraview. Visualizing boundary layer meshes for example or extracting the
surface elements of a mesh can be done by using the following script in the
&lt;em>Programmable filter&lt;/em> of Paraview.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">input&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="bp">self&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetUnstructuredGridInput&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="bp">self&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetUnstructuredGridOutput&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># copy all curent data&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetPointData&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">PassData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">input&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetPointData&lt;/span>&lt;span class="p">())&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetCellData&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">PassData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">input&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetCellData&lt;/span>&lt;span class="p">())&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># create an array holding the VTK cell type id of each element&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">cellTypes&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">vtk&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">vtkUnsignedCharArray&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">cellTypes&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">DeepCopy&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">input&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetCellTypesArray&lt;/span>&lt;span class="p">())&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">cellTypes&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">SetName&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;Cell Types&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">GetCellData&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">AddArray&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">cellTypes&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Even simpler you can import this file (&lt;a href="https://ctsolakis.com/code/export_cell_types.cpd">export_cell_types.cpd&lt;/a>) from the menu &lt;em>Tools&amp;gt;Manage Custom Filters&amp;hellip; &amp;gt; Import&lt;/em>.&lt;/p></description></item><item><title>Simple macros in ParaView</title><link>https://ctsolakis.com/2017/09/06/simple-macros-in-paraview/</link><pubDate>Wed, 06 Sep 2017 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2017/09/06/simple-macros-in-paraview/</guid><description>&lt;p>If you use &lt;a href="https://www.paraview.org/">ParaView&lt;/a> often you may want to automate some of your workflows.
One way to do this is writing a macro using the Python interpreter that ships with ParaView. Here,
is an example of extracting all elements from a tetrahedral mesh that have a minimum dihedral angle
less that 5 degrees.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">paraview.simple&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="o">*&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">#### disable automatic camera reset on &amp;#39;Show&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">paraview&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">simple&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">_DisableFirstRenderCameraReset&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># get selection&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">G&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">GetActiveSource&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># create quality Data&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># set min dihedraql angle as criterion&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">M&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">MeshQuality&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">Input&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">G&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">TetQualityMeasure&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;Minimum Dihedral Angle&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># select it&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">SetActiveSource&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">M&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Create selector&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">S&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">SelectionQuerySource&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">QueryString&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;Quality &amp;lt;=5&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Create Extractor&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">E&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">ExtractSelection&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">Input&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">M&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">Selection&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">S&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">Show&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">Render&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">#### uncomment the following to render all views&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># RenderAllViews()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># alternatively, if you want to write images, you can use SaveScreenshot(...).&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Another advantage of this approach is that you can run it in a headless environment using the
&lt;code>pvpython&lt;/code> interpreter that ships with ParaView.&lt;/p></description></item><item><title>Experience at ATPESC</title><link>https://ctsolakis.com/2017/09/05/experience-at-atpesc/</link><pubDate>Tue, 05 Sep 2017 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2017/09/05/experience-at-atpesc/</guid><description>&lt;p>During the first half of August we took part in the Argonne Training Program on
Extreme Scale Computing (ATPESC) and worked for a few days in the Argonne
Leading Computing Facilities center (ALCF) just outside of Chicago, Illinois.
The training consisted of lectures and presentations on software and hardware
advances as well as hands-on exercises using the supercomputers of Argonne. We
had the chance to meet people working on some of the most influential
high-performance computing projects like core members of the MPI Forum or the
OpenMP committee.&lt;/p></description></item><item><title>Type selector using template specialization</title><link>https://ctsolakis.com/2017/05/20/type-selector-using-templates/</link><pubDate>Sat, 20 May 2017 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2017/05/20/type-selector-using-templates/</guid><description>&lt;p>In an effort to contribute back to the great &lt;a href="https://github.com/lava/matplotlib-cpp">matplotlib-cpp&lt;/a>
library I came across the need of having to create a mechanism that can select between
different types in C++. This was needed in order to allow passing data from C++ to
python without any copies using the numpy library. The only caveat in this case in
that numpy requires to know the type you are passing. Since the matplotlib-cpp library is
template-based there is
a nice compile-time way to do it using &lt;a href="https://en.cppreference.com/w/cpp/language/template_specialization">template specialization&lt;/a>.
In simple terms it boils down to creating a base case for all the types you do
not support and specialize for the types you care. Using a simple struct to
hold the type completes the whole construct. The final result is :&lt;/p></description></item><item><title>Usefull GCC compilation flags</title><link>https://ctsolakis.com/2017/04/25/gcc-usefull-compilation-flags/</link><pubDate>Tue, 25 Apr 2017 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2017/04/25/gcc-usefull-compilation-flags/</guid><description>&lt;p>Having the &lt;code>-Wall&lt;/code> flag enabled by default can potentially save lots of time and headaches when
programming in C/C++. Same other usefull flags are :&lt;/p>
&lt;ul>
&lt;li>&lt;code>-Wduplicated-cond &lt;/code> : Warn about duplicated condition in if-else-if chains.&lt;/li>
&lt;li>&lt;code>-Wduplicated-branches&lt;/code> : Warn when an if-else has identical branches.&lt;/li>
&lt;li>&lt;code>-Wlogical-op&lt;/code> : Warn about use of logical operations where a bitwise operation probably was intended.&lt;/li>
&lt;li>&lt;code>-Wnull-dereference&lt;/code>: Warn when the compiler detects paths that dereferences a null pointer.&lt;/li>
&lt;li>&lt;code>-Wjump-misses-init&lt;/code>: Warn if a goto statement or a switch statement jumps forward across the initialization of a variable, or jumps backward to a label after the variable has been initialized.&lt;/li>
&lt;/ul>
&lt;p>&lt;a href="https://kristerw.blogspot.com/2017/09/useful-gcc-warning-options-not-enabled.html">source&lt;/a>&lt;/p></description></item><item><title>Embracing ssh-agent</title><link>https://ctsolakis.com/2016/11/10/embracing-sshagent/</link><pubDate>Thu, 10 Nov 2016 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2016/11/10/embracing-sshagent/</guid><description>&lt;p>&lt;code>ssh-agent&lt;/code> helps with managing ssh keys, it can keep track of unlocked
identity ssh keys making possible to enter the passphrase only once
and use the unlocked key for all upcoming ssh connections. You can make it even
more flexible by &lt;a href="https://superuser.com/questions/141044/sharing-the-same-ssh-agent-among-multiple-login-sessions">Sharing the same &lt;code>ssh-agent&lt;/code> among multiple login
sessions&lt;/a>.
Below is the best answer in my opinion, that I have used successfully may times.&lt;/p>
&lt;pre>&lt;code>function sshagent_findsockets {
 find /tmp -uid $(id -u) -type s -name agent.\* 2&amp;gt;/dev/null
}

function sshagent_testsocket {
 if [ ! -x &amp;quot;$(which ssh-add)&amp;quot; ] ; then
 echo &amp;quot;ssh-add is not available; agent testing aborted&amp;quot;
 return 1
 fi

 if [ X&amp;quot;$1&amp;quot; != X ] ; then
 export SSH_AUTH_SOCK=$1
 fi

 if [ X&amp;quot;$SSH_AUTH_SOCK&amp;quot; = X ] ; then
 return 2
 fi

 if [ -S $SSH_AUTH_SOCK ] ; then
 ssh-add -l &amp;gt; /dev/null
 if [ $? = 2 ] ; then
 echo &amp;quot;Socket $SSH_AUTH_SOCK is dead! Deleting!&amp;quot;
 rm -f $SSH_AUTH_SOCK
 return 4
 else
 echo &amp;quot;Found ssh-agent $SSH_AUTH_SOCK&amp;quot;
 return 0
 fi
 else
 echo &amp;quot;$SSH_AUTH_SOCK is not a socket!&amp;quot;
 return 3
 fi
}

function sshagent_init {
 # ssh agent sockets can be attached to a ssh daemon process or an
 # ssh-agent process.

 AGENTFOUND=0

 # Attempt to find and use the ssh-agent in the current environment
 if sshagent_testsocket ; then AGENTFOUND=1 ; fi

 # If there is no agent in the environment, search /tmp for
 # possible agents to reuse before starting a fresh ssh-agent
 # process.
 if [ $AGENTFOUND = 0 ] ; then
 for agentsocket in $(sshagent_findsockets) ; do
 if [ $AGENTFOUND != 0 ] ; then break ; fi
 if sshagent_testsocket $agentsocket ; then AGENTFOUND=1 ; fi
 done
 fi

 # If at this point we still haven't located an agent, it's time to
 # start a new one
 if [ $AGENTFOUND = 0 ] ; then
 eval `ssh-agent`
 fi

 # Clean up
 unset AGENTFOUND
 unset agentsocket

 # Finally, show what keys are currently in the agent
 ssh-add -l
}
&lt;/code>&lt;/pre>
&lt;p>&lt;a href="https://superuser.com/a/141241">source&lt;/a>&lt;/p></description></item><item><title>Linediff : Comparing files snippet by snippet</title><link>https://ctsolakis.com/2016/10/09/linediff/</link><pubDate>Sun, 09 Oct 2016 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2016/10/09/linediff/</guid><description>&lt;p>When performing big code changes like refactoring, comparing files can become
tedious and time consuming. One way to reduce the load is to compare the file
&lt;em>function by function&lt;/em> or even &lt;em>snippet by snippet&lt;/em> since, most of the time this is what you actually need.
A plugin for vim that works very closely to the default diff tool of git &lt;a href="http://vimdoc.sourceforge.net/htmldoc/diff.html">vimdiff&lt;/a>
is &lt;a href="https://github.com/AndrewRadev/linediff.vim">linediff.vim&lt;/a>.&lt;/p>
&lt;p>&lt;strong>Cheetsheet&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;code>^V&lt;/code> and use movement commands to select text&lt;/li>
&lt;li>&lt;code>:Linediff&lt;/code> to put selected text into buffer&lt;/li>
&lt;li>repeat for second snippet&lt;/li>
&lt;li>Use &lt;code>diffget&lt;/code> and &lt;code>diffput&lt;/code> and rest of vimdiff commands as usual&lt;/li>
&lt;li>Save both buffers once done&lt;/li>
&lt;/ul></description></item><item><title>Evaluating mesh volume from surface</title><link>https://ctsolakis.com/2015/10/30/evaluate-mesh-volume-from-surface/</link><pubDate>Fri, 30 Oct 2015 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2015/10/30/evaluate-mesh-volume-from-surface/</guid><description>&lt;p>One of the first tests one needs to implement when generating meshes is a volume test.
The main idea like in many other tests is to evaluate the same quantity in two
different ways and then compare the results. If everything is correct the results should
be close up to some rounding precision error.&lt;/p>
&lt;p>When dealing with surface vs volume calculation a familiar method from multi-variable calculus
is the Divergence theorem [1] :&lt;/p></description></item><item><title>Removing white pixels from figures</title><link>https://ctsolakis.com/2015/03/18/remove-white-pixels/</link><pubDate>Wed, 18 Mar 2015 00:00:00 +0000</pubDate><author>ctsol001@odu.edu (Christos Tsolakis)</author><guid>https://ctsolakis.com/2015/03/18/remove-white-pixels/</guid><description>&lt;p>Quite often, especially when you are working with presentations, you may realize
that you need to remove the white background from your figures. One way is to
use any photo editing software like Gimp for example and remove the background.
But if you have a lot of files and you don&amp;rsquo;t need smoothing or any other effect
you can also use a simple script like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="ch">#!/usr/bin/env python &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">#source : http://stackoverflow.com/a/765829&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">PIL&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">Image&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">sys&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">white&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">255&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">255&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">255&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">255&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">transparent&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">255&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">255&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">255&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="n">infile&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">sys&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">argv&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">:]:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">img&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Image&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">open&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">infile&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">img&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">img&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">convert&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;RGBA&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pixdata&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">img&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">load&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">y&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">xrange&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">img&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">size&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">]):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">x&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">xrange&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">img&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">size&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">]):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">pixdata&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">x&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="n">white&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pixdata&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">x&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">transparent&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">img&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">save&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">infile&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="s2">&amp;#34;_modified&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;PNG&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;a href="http://stackoverflow.com/a/765829">source&lt;/a>&lt;/p></description></item></channel></rss>