25 Jul 2018

C++ I/O Tips: Parsing Huge Text File

收藏到CSDN网摘

问题提出


最近项目需要读取mesh文件,基本做过CFD的都知道,几千万Elements的mesh文件动辄几个Gb,庞大的体积让各种操作都很不方便.而获取数据需要与磁盘打交道,作为后续处理的第一步,是一切的开端.如果需要读取的文件是二进制格式,会有些帮助.但是不同的网格划分软件大都有其自有格式,等于是带着枷锁跳舞.

注意:这里的测试使用的都是文本文件,可能不适用于二进制文件读写.

下文使用的开发环境: VS2013 + Win10 + i7 CPU/16G Ram.
测试数据是ICEM导出的Star-CD的vrt格式.这种格式可以看作是文本文件,每一行一组数据表示一个Node(也就是一个三维点): Node_ID X Y Z.Mesh有多少个Node,文件就有多少行.

14 Jun 2018

Get Matlab Version

收藏到CSDN网摘

Matlab provides loads of useful functions for scientific computing. However, the functions might be added or deprecated from version to version. To write more robust codes, it's always a good practice to deal with different cases. An if...else... clause would be enough for this purpose.

9 Feb 2018

Get the latest release folder from a directory

收藏到CSDN网摘
Sometimes, we might need to find the latest release folder from a software repository according to the time stamp of the folder property. This could be done by extracting all the time stamps and sort them accordingly. MATLAB provides several function to do this nicely.

16 Jan 2018

Scroll to the last line of text edit in Matlab

收藏到CSDN网摘
Matlab's edit UIControl provide some flexibilities for displaying information, while setting the Max-Min>1 it supports multiple line. However, the caret is alwasy set to 0 position in the first line which is very annoy while you would like to show dynamic updated information to the user. To implement this capability, the underlying Java class has to be digged out. Yair M. Altman's findjobj.m function works perfectly to obtain those kind of information. Then, all we need to do is providing the Matlab UIControl's handle and set caret to the document length.

22 Dec 2017

Maxmise plot in matplotlib

收藏到CSDN网摘

To make the plot maxmised, different commands need to be used according to the current backends used by matplotlib:

Save plot without displaying in Matplotlib

收藏到CSDN网摘
By using Matplotlib, data can be easily plotted in the same way as in Matlab. But sometimes you might need to plot thousands of plots in a bug loop and save those intermediate results. The interactive display could be an issue that makes your machine not only slow but also useless. Someone suggests 'plt.ioff()' to turn off interactive mode. It may work in some cases (according to the feedbacks on Stackoverflow). For me, no magic happened. After searching the internet, the most straightforward solution would be...