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 / OOP_F2003_Part_1.md
Created August 13, 2019 11:26 — forked from n-s-k/OOP_F2003_Part_1.md
Object-Oriented Programming in Fortran 2003 Part 1: Code Reusability
from pyzotero import zotero
zot = zotero.Zotero('000000000', 'user', 'AAAAAAAAAAAAA')
print(zot.count_items())
tags_to_keep = ['writting','english']
tags = zot.everything(zot.tags())
tags_to_remove = list(set(tags).difference(tags_to_keep))
while len(tags_to_remove)>0:
tags = zot.everything(zot.tags())
tags_to_remove = list(set(tags).difference(tags_to_keep))
@zhulianhua
zhulianhua / preplotAll.ps1
Created September 13, 2018 21:44
powershell for loop
for ($i=0; $i -lt 21; $i++)
{
$stra = $i*5000
$filename = 'CFILE_' + $stra.ToString() + '.dat'
preplot $filename
}
@zhulianhua
zhulianhua / image_ascii.m
Created June 6, 2018 13:50
matlab 图像二进制化并保存为ASCII文件
IMG = imread('xxx.jpg'); % image data
L = im2bw(IMG); % image data to logical data
I = int8(L); % convert to 8 bit integer
dlmwrite('data.dat', I, ' ') % write ascii file, using space(' ') as delimeter
% open data.dat to view it
@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;
}
//展开函数
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 / 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 |
#------------------------------------------------------------------------------
```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 / 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 zhulianhua121@gmail.com
# Switch to current working directory
export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)
@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
---------