安装
在Ubuntu系统安装Python 3
Ubuntu may ship with Python 3, as the default Python installation. 如果没有则需要安装。
安装pip3
Complete the following steps to install pip (pip3
) for Python 3:
- Start by updating the package list using the following command:
sudo apt update
- Use the following command to install pip for Python 3:
sudo apt install python3-pip
The command above will also install all the dependencies required for building Python modules.
- Once the installation is complete, verify the installation by checking the pip version:
pip3 --version
安装PyFoam
sudo apt-get install gnuplot gnuplot-x11 #安装Gnuplot
pip3 install PyFoam # 安装PyFoam
在终端中将默认运行环境切换到Python 3
update-alternatives --remove python /usr/bin/python2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
以上命令移除Python 2并将Python 3的优先级设为10.
测试安装是否成功:
pyFoamListCases.py
若安装成功且当前目录没有OpenFOAM案例,则返回No cases found
。
或者使用pyFoamVersion.py
测试安装成功与否。
安装swak4foam
安装mercurial
sudo apt install mercurial
下载swak4foam
hg clone http://hg.code.sf.net/p/openfoam-extend/swak4Foam swak4Foam
#Go into swak4Foam's main source folder
cd swak4Foam
# This next command will take a while...
./Allwmake
#Run it a second time for getting a summary of the installation
./Allwmake > log.make 2>&1
测试swak4Foam是否安装成功:
funkySetFields
安装文本编辑器Emacs
2023-04-07 How to Install Emacs Editor in Ubuntu 20.04 – LinuxWays
PyFoam使用
pyFoamCloneCase.py
pyFoamCloneCase.py $FOAM_TUTORIALS/heatTransfer/buoyantPimpleFoam/hotRoom 01baseCase
cd 01baseCase
ls
rm All*
mv 0 0.org
cat PyFoamHistory
pyFoamPrepareCase.py
pyFoamPrepareCase.py
is a utility to set up cases in a reproducible way:
There are two versions of a training presentation on this
- One with cats https://bit.ly/pyFPrepCats and Alternate URL https://openfoamwiki.net/images/b/b8/BernhardGschaider-OFW10_pyFoamPrepareCase.pdf
- Improved but without cats https://bit.ly/pyFPrepNoCats or Alternate URL https://openfoamwiki.net/images/9/97/BernhardGschaider-OFW13_pyFoamPrepareCase.pdf
pyFoamPlotRunner.py
Starting the simulation with residual plots by pyFoamPlotRunner.py
:
pyFoamPlotRunner.py --clear --progress --auto --hardcopy --prefix=firstRun auto
pyFoamPlotWatcher.py
Looking at the curves again: "replay" the simulation process parameters but not re-run the simulation by pyFoamPlotWatcher.py
:
pyFoamPlotWatcher.py --with-all --hardcopy --prefix=firstRunWatch PyFoamRunner.buoyantPimpleFoam.logfile
这个命令会复现计算过程中的残差曲线、库朗数等曲线图。
pyFoamPVSnapshot.py (暂未学会如何使用)
pyFoamPVSnapshot.py
: creates a visualization state file:
pyFoamPVSnapshot.py . --state=hotWithStreamlines.pvsm --time=200 --latest
快速获取场数据的统计分布fieldReport
fieldReport -time 2000 T
fieldReport -time 0: -doBoundary -csvName numbers T #将结果导出到csv文件
ls *csv #查看导出的csv文件名
cat numbers_T_region0.csv #查看其中的数据
清理不必要的结果 pyFoamClearCase.py
pyFoamClearCase.py --verbose-clear --keep-last .
Comments | NOTHING