【OpenFOAM】学习module1

M1-overview OpenFOAM

of9

1.programming new solvers

            solve
            (
                fvm::ddt(T) - fvm::laplacian(DT, T)
            );

2.directory organization

键入tut,跳转到教程目录
类似的alias,查看方法:

vim $WM_PROJECT_DIR/etc/config.sh/alias

列出所有和OpenFOAM相关的alias

alias | grep -i "FOAM"

application:
solver,求解器代码
test,测试OpenFOAM类的一些测试案例
utilities,小工具(前处理、后处理、网格…)
bin:
shell脚本(foamInfo, paraFOam…)
doc:
user guide
programmer’s guide
Doxygen,在Allwmake这一步时间20分钟

firefox README.html
sudo apt-get install doxygen graphviz
doxygen -w html header.html footer.html customdoxygen.css
./Allwmake
cd ./html
firefox index.html

bin:
super dictionary controlDict
src:
this is the core of OpenFOAM
finiteVolume/lnInclude, fvCFD,h
tutorials:
interFoam

wmake:
wamke/rules,available compilers

3. search source code

find $WM_PROJECT_DIR -type d -name "*fvPatch*"
find $WM_PROJECT_DIR -type f -name "*fvPatch*"
grep -r -n "LES" $FOAM_SOLVERS
find $FOAM_TUTORIALS -iname "*dict" 
 find $FOAM_TUTORIALS -type f | xargs grep 'slip' 
 find $FOAM_SRC -name "*slip*"
 find $WM_PROJECT_DIR -type f | xargs grep -sl 'noParallel'

4. structure of an OpenFOAM application/utility

/OpenFOAM/OpenFOAM-9/applications/solvers/incompressible/icoFoam
.
├── createFields.H
├── icoFoam.C
└── Make
├── files
└── options
icoFoam.C

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );

        if (piso.momentumPredictor())
        {
            solve(UEqn == -fvc::grad(p));
        }

Make/files
solverName name and location of the output file

icoFoam.C

EXE = $(FOAM_APPBIN)/icoFoam

Make/options
specifies directions to research for include files and libraries to link the solver against

EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools

surfaceAutoPatch

surfaceAutoPatch -doc
surfaceAutoPatch -help

case: tut icoFoam/cavity
├── 0
│ ├── p
│ └── U
├── constant
│ ├── polyMesh
│ │ ├── boundary
│ │ ├── faces
│ │ ├── neighbour
│ │ ├── owner
│ │ └── points
│ └── transportProperties
└── system
├── blockMeshDict
├── controlDict
├── fvSchemes
└── fvSolution

case: OF9/101OF/cavity2D

bash ./run_all.sh

在这里插入图片描述
case: of2206 tut verificationAndValidation/multiphase/interIsoFoam/porousDamBreak

./Allrun
./plot
cd plots
gwenview surface_compare.png

在这里插入图片描述5. 使用OpenFOAM
建立网格,检查网格checkMesh,避免之后计算发散
求解
后处理
画图

blockMesh
checkMesh
icoFoam
postProcess -func sampleDict -latestTime
gnuplot gnuplot/gnuplot_script
paraview

icoFoam是基础的求解器
用pisoFoam或者pimpleFoam是等效于icoFoam的,并且会有更多特征

#!/bin/bash

foamCleanTutorials
blockMesh | tee log.blockMesh
checkMesh | tee log.checkMesh

icoFoam | tee log.icoFoam
#pisoFoam | tee log.solver
foamLog log.icoFoam
gnuplot
set logscale y
plot 'logs/p_0' using 1:2 with lines
plot 'logs/p_0' using 1:2 with lines, 'logs/pFinalRes_0' using 1:2 with lines
reset
plot ‘logs/CourantMax_0’ u 1:2 w l
set logscale y
plot [30:50][] 'logs/Ux_0' u 1:2 w l title 'Ux','logs/Uy_0' u 1:2 w l title 'Uy'
exit

在这里插入图片描述

在这里插入图片描述

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          writeNow;
#This will stop your simulation and will save the current time-step or iteration.

endTime         1.5;

deltaT          0.005;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;
#By setting the keyword runTimeModifiable to true, you will be able to modify most of the dictionaries on-the-fly

清除案例文件夹

foamCleanTutorials
# erase the mesh and the solution,also erase the processorN

foamCleanPolyMesh
#only erase the mesh

foamListTimes -rm
#erasing the saved solutions

foamListTimes –rm -processor
#erase the solution saved in the processorN
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值