Did you know that when connecting to a server wish ssh it will first send all 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 https://github.com/FiloSottile/whosthere
Adding support for new mesh formats in ParaView
The architecture of ParaView allows extending its functionality by creating plugins which can be loaded as dynamic libraries without recompiling ParaView.
The main mesh filetypes we are handling in our lab are
.ugrid
generated by AFLR3 and used widely within FUN3D,
.meshb
from INRIA Gamma Team and .su2
from the SU2 solver. Unfortunately there is no support for these from
Paraview. Fortunately there is documentation for creating readers (plugin
guides).
Here is the boilerplate for writting a reader for an unstructred grid based on the Paraview wiki.
[Read More]Podcast series on history of AI
In this series created by the wondery network the host will transport you to the days or early AI, from the lonely ELIZA, to Apple’s Siri, and from Deep Blue to AlphaGo.
Episode 1 : Thinking Machines : Artificial Intelligence
Episode 2 : Thinking Machines : How Do You Make a Computer Blink
Episode 3 : Thinking Machines : Siri-ous Business
Episode 4 : Thinking Machines : I learn Therefore I am
Episode 5 : Thinking Machines : Passing For Human
[Read More]Extract Cell types from mesh in Paraview
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 Programmable filter of Paraview.
input = self.GetUnstructuredGridInput()
output = self.GetUnstructuredGridOutput();
# copy all curent data
output.GetPointData().PassData(input.GetPointData())
output.GetCellData().PassData(input.GetCellData())
# create an array holding the VTK cell type id of each element
cellTypes = vtk.vtkUnsignedCharArray()
cellTypes.DeepCopy(input.GetCellTypesArray())
cellTypes.SetName("Cell Types")
output.GetCellData().AddArray(cellTypes)
Even simpler you can import this file (export_cell_types.cpd) from the menu Tools>Manage Custom Filters… > Import.
[Read More]Simple macros in ParaView
If you use ParaView 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.
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# get selection
G = GetActiveSource()
# create quality Data
# set min dihedraql angle as criterion
M = MeshQuality(Input=G, TetQualityMeasure="Minimum Dihedral Angle")
# select it
SetActiveSource(M)
# Create selector
S = SelectionQuerySource(QueryString = "Quality <=5")
# Create Extractor
E = ExtractSelection(Input = M,Selection = S)
Show()
Render()
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
Another advantage of this approach is that you can run it in a headless environment using the
pvpython interpreter that ships with ParaView.
Experience at ATPESC
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.
[Read More]Type selector using template specialization
In an effort to contribute back to the great matplotlib-cpp 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 template specialization. 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 :
[Read More]Usefull GCC compilation flags
Having the -Wall flag enabled by default can potentially save lots of time and headaches when
programming in C/C++. Same other usefull flags are :
-Wduplicated-cond: Warn about duplicated condition in if-else-if chains.-Wduplicated-branches: Warn when an if-else has identical branches.-Wlogical-op: Warn about use of logical operations where a bitwise operation probably was intended.-Wnull-dereference: Warn when the compiler detects paths that dereferences a null pointer.-Wjump-misses-init: 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.
Embracing ssh-agent
ssh-agent 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 Sharing the same ssh-agent among multiple login
sessions.
Below is the best answer in my opinion, that I have used successfully may times.
function sshagent_findsockets {
find /tmp -uid $(id -u) -type s -name agent.\* 2>/dev/null
}
function sshagent_testsocket {
if [ ! -x "$(which ssh-add)" ] ; then
echo "ssh-add is not available; agent testing aborted"
return 1
fi
if [ X"$1" != X ] ; then
export SSH_AUTH_SOCK=$1
fi
if [ X"$SSH_AUTH_SOCK" = X ] ; then
return 2
fi
if [ -S $SSH_AUTH_SOCK ] ; then
ssh-add -l > /dev/null
if [ $? = 2 ] ; then
echo "Socket $SSH_AUTH_SOCK is dead! Deleting!"
rm -f $SSH_AUTH_SOCK
return 4
else
echo "Found ssh-agent $SSH_AUTH_SOCK"
return 0
fi
else
echo "$SSH_AUTH_SOCK is not a socket!"
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
}
[Read More]Linediff : Comparing files snippet by snippet
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 function by function or even snippet by snippet 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 vimdiff is linediff.vim.
Cheetsheet
^Vand use movement commands to select text:Linediffto put selected text into buffer- repeat for second snippet
- Use
diffgetanddiffputand rest of vimdiff commands as usual - Save both buffers once done