Skip to content

Instantly share code, notes, and snippets.

View zhulianhua's full-sized avatar
🎯
Focusing

Lianhua Zhu zhulianhua

🎯
Focusing
  • Somewhere
  • Shanghai
View GitHub Profile
@zhulianhua
zhulianhua / square_cylinder.geo
Created September 19, 2016 08:32
Gmsh script for generating structured mesh for flow past a square cylinder (no complete, just a backup)
D = 1.0;
R = D/2.0;
H = 4;
Ll = 4;
Lr = 6;
Lil = 2;
Lir = 2;
Hi = 2;
@zhulianhua
zhulianhua / cell2vtk.py
Last active February 2, 2017 20:46
convert a cell centered tecplot block ascii data to a VTK RECTILINEAR_GRID format data
from numpy import *
#filename = "data.txt"
datadir = "Tr0.8_Kn0.1/GH_16_16_16/"
filename = datadir+"creep3d.dat"
NX = 40
NZ = 40
NY = 80
@zhulianhua
zhulianhua / png2flag.py
Created May 29, 2017 08:52
Convert from PNG image to ASCII flag (0/1) file
import numpy as np
import matplotlib.image as mpimg
def rgb2gray(rgb):
''' Convert rgb to gray '''
return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])
def gray2bin(gray):
''' Convert gray to binary (0,1)'''
#return (gray>0.5).astype('uint8')
@zhulianhua
zhulianhua / of41_user_bashrc.sh
Last active June 12, 2017 13:45
modified OpenFOAM 4.1 etc/bashrc for Archer HPC system
#LHZHU: Changed based on http://www.archer.ac.uk/documentation/software/openfoam/#4.1 compute
#DESC: Let user program compile on /work filesystem
#NOTE: should export CRAYPE_LINK_TYPE=dynamic to compile it, as Archer default use static link
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
@zhulianhua
zhulianhua / DV_NU.py
Created July 3, 2017 19:38
Non-uniform discrete velocity
# coding: utf-8
# Generate non-uniform discrete velocity using a power law distribution
import numpy as np
def nu_dv(lmx, MX, xiMax):
"""
Generate a non-uniform points with a power law distribution
Parameter
---------
@zhulianhua
zhulianhua / job.sh
Last active July 19, 2017 14:38
qsub passing an environment variable via cmd options -v
#!/bin/bash --login
#PBS -N test
#PBS -A e283
#PBS -l select=1
#PBS -l walltime=0:20:00
##PBS -m abe
#PBS -M [email protected]
# Switch to current working directory
export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)
```bash
### OpenMPI
module load compilers/intel/2018_0
./configure --prefix=/home/appLEIWU/MPI/intel/openmpi/2.1.0 CC=/home/appLEIWU/compiler/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icc CXX=/home/appLEIWU/compiler/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icpc F77=/home/appLEIWU/compiler/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort FC=/home/appLEIWU/compiler/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort
make -j 28
sudo make install
### HDF5
CC=/home/appLEIWU/MPI/intel/openmpi/2.1.0/bin/mpicc ./configure --enable-parallel --prefix=/home/appLEIWU/tool/HDF5/intel/openmpi/1.8.5-patch1
make -j 28
@zhulianhua
zhulianhua / bashrc.sh
Created October 15, 2017 08:15
OpenFOAM on Archer HPC : Let user's solver compile from /work directory
#Generated by `cat $LHOME/OpenFOAM/OpenFOAM-4.1/etc/bashrc`
#LHZHU: Changed based on http://www.archer.ac.uk/documentation/software/openfoam/#4.1 compute
#DESC: Let user program compile on /work filesystem
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
void data2D(int mm_, double* T_, double* qx_,double* qy_,double* xcoord_, double* ycoord_, double* dx_, double* dy_, int NumMeshx_, int NumMeshy_ )
{
FILE *fp;
char fname[1000];
int m1,i,j;
int nodes,elements;
int index[M][N];
nodes=0;
elements=0;
@zhulianhua
zhulianhua / C++11-variadic-template
Created April 18, 2018 09:17
C++11 可变参数模板
// blog : https://zhulianhua.wordpress.com/2018/04/18/c11-variadic-template/
#include <iostream>
using namespace std;
//递归终止函数
void print()
{
cout << "empty" << endl;
}
//展开函数