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

###Matlab 绘图教程

如何查看帮助

  • 简单帮助用 help命令, 如 查看 contourf 的用法可以用help contourf
  • 详细帮助用doc命令, 如查看plot的用法可以用doc contourf

####一个比较完全的示例

@zhulianhua
zhulianhua / build_gcc_5.2.0.sh
Last active May 29, 2016 14:49
Build gcc-5.2.0 on cluster
##Make build dir
mkdir ~/build/gcc
cd ~/build/gcc
##Download packages
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.14.tar.bz2
@zhulianhua
zhulianhua / pwlInterp2.cpp
Last active September 21, 2015 08:36
2D piece-wise linear interpolation
#include <vector>
class pwlInterp2
{
//priviate
private:
std::vector<double> xd, yd, zd;
int find_posizition(std::vector<double> xxd, double xi )
{
  • 从Gambit里面画好网格后,周期边界设为wall类型,导出网格,然后运行 FluentMeshToFoam,转换成OpenFOAM 里面内部使用的格式。

  • 更改constant/polyMesh/boundary文件中对应的周期patch,即从wall类型改为cyclic, 如下:

          right
          {
             type            cyclic;
             inGroups        1(cyclic);
             nFaces          20;
             startFace       5572;
    

// matchTolerance 1;

@zhulianhua
zhulianhua / getM.c
Created September 29, 2015 01:54
Construct M matrix from given discrete velocity set order for MRT D3Q19 lattice model in lattice Boltzmann method
/*
*construct M from c
*refer to D'Humières, Dominique Ginzburg, Irina Krafczyk, Manfred Lallemand, Pierre Luo, Li-Shi
2012
*/
#include <stdio.h>
#define Q 19

Linux 文件操作

几点说明

  • 常用命令 ls, cp, rm, mv,pwd
  • 目录(directory)对应Windows中的"文件夹"概念;
  • ~代表你的home;
  • .代表当前目录;
  • ..代表当前目录的上一层目录;
  • 命令用法一般都是 命令名 操作对象, 操作对象可以是空格分隔的多个文件/目录
  • 区分绝对路径(/开头)和相对路径,根据实际情况哪个方便用哪个;

Linux 命令行编辑快捷键

初学者在Linux命令窗口(终端)敲命令时,肯定觉得通过输入一串一串的字符的方式来控制计算是效率很低。 但是Linux命令解释器(Shell)是有很多快捷键的,熟练掌握可以极大的提高操作效率。 下面列出最常用的快捷键,这还不是完全版。

  • 命令行快捷键:
    • 常用:
      • Ctrl L :清屏
  • Ctrl M :等效于回车
@zhulianhua
zhulianhua / plainToTecplot.py
Created August 24, 2016 07:32
Convert plain data to Tecplot format
#!/usr/bin/python
import numpy as np
from numpy import *
L = 1.0
N = 60;
dx = L/N;
x = (arange(N) + 0.5)*dx
y = (arange(N) + 0.5)*dx
"""This file contains code for use with "Think Stats",
Copyright 2016 Lianhua Zhu
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
import sys
import gzip
import os
import argparse
@zhulianhua
zhulianhua / tecplot_cellcentered.c
Created September 4, 2016 08:21
store CFD cell centered data in tecplot
if( ( fp=fopen(fname,"w"))==NULL) {printf(" File Open Error\n");exit(1);}
fprintf(fp,"TITLE=%s\n","Cavity_3D");
fprintf(fp,"Variables=%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s \n","X","Y","Z","RHO","Ux","Uy","Uz","Temperature","qx","qy","qz");
fprintf(fp,"Zone I=%d, J=%d, K=%d, DATAPACKING=BLOCK, VARLOCATION=([4,5,6,7,8,9,10,11]=CELLCENTERED) \n",(M),(N),(Q));