Skip to content

Instantly share code, notes, and snippets.

View mrklein's full-sized avatar

Alexey Matveichev mrklein

View GitHub Profile
from scipy.spatial import Delaunay
from matplotlib.tri import Triangulation
data = N.loadtxt(filename)
x = 100*data[:, xidx]
y = 100*data[:, yidx]
pts = N.column_stack((x, y))
tri = Delaunay(pts)
mtri = Triangulation(x, y, tri.simplices.copy())
data = N.loadtxt(filename)
x = 100*data[:, xidx]
y = 100*data[:, yidx]
fl = data[:, flidx]
asp = 4.5/(xlim[1] - xlim[0])
P.figure(figsize=(8, 8*asp))
P.clf()
P.tricontour(x, y, fl, [0.5], colors='black')
Traceback (most recent call last):
File "./plot.py", line 116, in <module>
plot_planes(s)
File "./plot.py", line 75, in plot_planes
P.tricontour(x, y, fl, [0.5], colors='black')
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 3090, in tricontour
ret = ax.tricontour(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 8922, in tricontour
return mtri.tricontour(self, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/tri/tricontour.py", line 280, in tricontour
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'
@mrklein
mrklein / Makefile
Created October 6, 2014 15:23
Arithmetics
leading_zero_strip = $(shell echo $$(echo $(1) | sed 's/^0*//'))
__plus = $(shell echo $$(($(1) + $(2))))
plus = $(call __plus,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2)))
__minus = $(shell echo $$(($(1) - $(2))))
minus = $(call __minus,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2)))
__mult = $(shell echo $$(($(1) * $(2))))
mult = $(call __mult,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2)))
@mrklein
mrklein / atkin.c
Last active August 29, 2015 14:07
Sieve of Atkin in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
#include <math.h>
#define CLOCKTYPE CLOCK_MONOTONIC
uint64_t* sieve_of_atkin_f(uint64_t n);
@mrklein
mrklein / gist:07249c2e80c27f476ca4
Created December 1, 2014 17:31
Part of Bouygues Telecom Bbox web interface
function CheckIPString(Str,inCouldBeEmpty)
{
if (Str == "") return inCouldBeEmpty;
var regExpIP = new RegExp("^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$");
if (!regExpIP.test(Str)) return false;
var ipArray = Str.split(".");
for (var i = 0; i < 4; i++) {
if ((Math.floor(ipArray[i]) < 0) || (Math.floor(ipArray[i]) > 247)) return false;
}
@mrklein
mrklein / plot_vtk.py
Last active December 17, 2024 13:09
Plot VTK with matplotlib
#!/usr/bin/env python
import os
import numpy as np
import vtk
import matplotlib.pyplot as plt
def load_velocity(filename):
if not os.path.exists(filename):
@mrklein
mrklein / vtk-unstructured-grid-plot.py
Last active September 22, 2022 12:07
Read, cut and plot VTK file with python-vtk and matplotlib
%matplotlib inline
filename = 'vtk-plot_0.vtk'
import vtk
from numpy import zeros
import matplotlib.pyplot as plt
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(filename)
#include "fvCFD.H"
#include "uniformSet.H"
#include "meshSearch.H"
#include "constants.H"
using Foam::constant::mathematical::pi;
int main(int argc, char *argv[])