简要介绍
OpenFOAM(英文 Open Source Field Operation and Manipulation 的缩写,意为开源的场运算和处理软件)是对连续介质力学问题进行数值计算的 C++ 自由软件工具包,其代码遵守 GNU 通用公共许可证。它可进行数据预处理、后处理和自定义求解器,常用于计算流体力学领域。
编译步骤
如果想偷懒,尽量少输入命令行的话,可以参考 dyfluid.com。
安装依赖
参考官方编译步骤,如果使用 Ubuntu 系统,则通过下列命令安装依赖。为了提升网络下载速度,可能需要配置镜像网站,例如中科大镜像、南科大镜像、阿里云镜像等。
| sudo apt install build-essential flex bison git-core cmake zlib1g-dev libboost-system-dev libboost-thread-dev libopenmpi-dev openmpi-bin gnuplot libreadline-dev libncurses-dev libxt-dev
|
如果最后编译时报错找不到 scotch.h
或者 ptscotch.h
,则需继续通过下列命令安装额外依赖。
| sudo apt install libscotch-dev libptscotch-dev
|
编译 OpenFOAM
首先我们从官方仓库下载特定版本的 OpenFOAM,目前最新版本为 OpenFOAM v9.0,配置文件并没有硬编码仓库位置,所以理论上下载在哪里均可。
| git clone https://e.coding.net/dyfluid/OpenFOAM/OpenFOAM-9.git
|
为了让 OpenFOAM 多版本并存,可以利用 alias
命令惰性加载配置文件。
| alias of9="source /<path-to-OpenFOAM-9>/etc/bashrc"
|
最后就可以编译 OpenFOAM 了。
| source /<path-to-OpenFOAM-9>/etc/bashrc # of9
./Allwmake -j
|
stdout + stderr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427 | Compiling enabled on 4 cores
Allwmake /opt/OpenFOAM/OpenFOAM-9
make: Nothing to be done for 'all'.
Allwmake: no ThirdParty directory found - skipping
Allwmake src
same version as previous build
Allwmake src/Pstream
wmake dummy
wmake mpi
Allwmake libo src/OSspecific/POSIX
wmake libo .
wmake OpenFOAM
wmake fileFormats
wmake surfMesh
wmake triSurface
wmake meshTools
Allwmake src/dummyThirdParty
wmake scotchDecomp
wmake ptscotchDecomp
wmake metisDecomp
wmake MGridGen
wmake finiteVolume
wmake lagrangian/basic
wmake lagrangian/distributionModels
wmake genericPatchFields
wmake mesh/extrudeModel
wmake dynamicMesh
Allwmake src/parallel
Allwmake src/parallel/decompose
using SCOTCH_ARCH_PATH=/opt/OpenFOAM/ThirdParty-9/platforms/linux64GccDPInt32/scotch_6.0.9
wmake scotchDecomp
wmake ptscotchDecomp
wmake ptscotchDecomp
Allwmake src/parallel/decompose/metisDecomp
using METIS_ARCH_PATH=/opt/OpenFOAM/ThirdParty-9/platforms/linux64GccDPInt32/metis-5.1.0
wmake decompositionMethods
wmake decompose
Allwmake src/parallel/reconstruct
wmake reconstruct
wmake distributed
wmake dynamicFvMesh
wmake topoChangerFvMesh
wmake conversion
wmake sampling
wmake ODE
wmake randomProcesses
wmake transportModels
Allwmake src/thermophysicalModels
wmake specie
wmake thermophysicalProperties
wmake basic
wmake reactionThermo
wmake laminarFlameSpeed
wmake chemistryModel
wmake barotropicCompressibilityModel
wmake solidThermo
Allwmake src/twoPhaseModels
wmake twoPhaseMixture
wmake interfaceProperties
wmake twoPhaseProperties
wmake incompressibleTwoPhaseMixture
wmake immiscibleIncompressibleTwoPhaseMixture
wmake twoPhaseChange
Allwmake src/MomentumTransportModels
wmake momentumTransportModels
wmake incompressible
wmake compressible
wmake phaseIncompressible
wmake phaseCompressible
Allwmake src/ThermophysicalTransportModels
wmake fluidReactionThermo
wmake phaseFluidThermo
wmake phaseFluidReactionThermo
wmake radiationModels
wmake combustionModels
Allwmake src/regionModels
wmake regionModel
wmake surfaceFilmModels
wmake thermalBaffleModels
Allwmake src/lagrangian
wmake distributionModels
wmake basic
wmake solidParticle
wmake parcel
wmake parcelTurbulence
wmake DSMC
Allwmake src/lagrangian/molecularDynamics
wmake potential
wmake molecularMeasurements
wmake molecule
Allwmake src/mesh
wmake snappyHexMesh
wmake blockMesh
wmake extrudeModel
Allwmake src/renumber
skipping zoltanRenumber
wmake renumberMethods
Allwmake src/fvAgglomerationMethods
wmake pairPatchAgglomeration
wmake fvMotionSolver
wmake engine
wmake fvModels
wmake fvConstraints
Allwmake src/functionObjects
wmake field
wmake forces
wmake lagrangian
wmake utilities
wmake solvers
wmake sixDoFRigidBodyMotion
wmake sixDoFRigidBodyState
wmake rigidBodyDynamics
wmake rigidBodyMeshMotion
wmake rigidBodyState
wmake specieTransfer
wmake atmosphericModels
wmake waves
Allwmake applications
wmake solvers
wmake basic
wmake combustion
wmake compressible
wmake discreteMethods
wmake laplacianFoam
wmake chemFoam
wmake rhoCentralFoam
wmake dsmc
Allwmake applications/solvers/compressible/rhoCentralFoam
wmake BCs
wmake dsmcFoam
wmake coldEngineFoam
wmake molecularDynamics
wmake potentialFoam
wmake mdEquilibrationFoam
wmake scalarTransportFoam
wmake PDRFoam
wmake laminarFlameSpeed
wmake mdFoam
wmake rhoPimpleFoam
wmake SCOPE
wmake PDRModels
wmake dragModels
wmake basic
wmake PDRDragModel
wmake DNS
wmake turbulence
wmake dnsFoam
wmake PDRkEpsilon
wmake XiEqModels
wmake basicXiSubXiEq
wmake XiGModels
wmake basicXiSubG
wmake electromagnetics
wmake rhoSimpleFoam
wmake electrostaticFoam
wmake XiModels
wmake rhoPorousSimpleFoam
wmake algebraic
wmake fixed
wmake transport
wmake XiEqModels
wmake Gulder
wmake instabilityXiEq
wmake financial
wmake SCOPEBlendXiEq
wmake financialFoam
wmake SCOPEXiEq
wmake XiEqModel
wmake XiGModels
wmake magneticFoam
wmake instabilityG
wmake KTS
wmake XiGModel
wmake XiModel
wmake heatTransfer
wmake buoyantPimpleFoam
wmake mhdFoam
wmake incompressible
wmake adjointShapeOptimisationFoam
wmake adjointOutletPressure
wmake adjointOutletVelocity
wmake buoyantSimpleFoam
wmake lagrangian
wmake denseParticleFoam
wmake reactingFoam
wmake boundaryFoam
wmake buoyantReactingFoam
wmake chtMultiRegionFoam
wmake particleFoam
wmake fluid
wmake include
wmake solid
wmake icoFoam
wmake engineFoam
wmake rhoParticleFoam
wmake thermoFoam
wmake nonNewtonianIcoFoam
wmake multiphase
wmake stressAnalysis
wmake cavitatingFoam
wmake solidDisplacementFoam
Allwmake applications/solvers/stressAnalysis/solidDisplacementFoam
wmake solidDisplacementThermo
wmake pimpleFoam
wmake SRFPimpleFoam
wmake XiFoam
wmake XiEngineFoam
wmake compressibleInterFoam
Allwmake applications/solvers/multiphase/compressibleInterFoam
wmake twoPhaseMixtureThermo
wmake surfaceTensionModels
wmake pisoFoam
wmake solidEquilibriumDisplacementFoam
wmake shallowWaterFoam
wmake simpleFoam
wmake twoPhaseChange
wmake SRFSimpleFoam
wmake porousSimpleFoam
wmake compressibleMultiphaseInterFoam
Allwmake applications/solvers/multiphase/compressibleMultiphaseInterFoam
wmake multiphaseMixtureThermo
wmake driftFluxFoam
Allwmake applications/solvers/multiphase/driftFluxFoam
wmake mixtureViscosityModels
wmake compressibleInterPhaseTransportModel
wmake interFoam
wmake interMixingFoam
wmake immiscibleIncompressibleThreePhaseMixture
wmake incompressibleThreePhaseMixture
wmake threePhaseInterfaceProperties
wmake relativeVelocityModels
wmake multiphaseEulerFoam
Allwmake applications/solvers/multiphase/multiphaseEulerFoam
wmake phaseSystems
wmake VoFClouds
wmake VoFSurfaceFilm
wmake multiphaseInterFoam
Allwmake applications/solvers/multiphase/multiphaseInterFoam
wmake multiphaseMixture
wmake potentialFreeSurfaceFoam
wmake twoLiquidMixingFoam
wmake interfacialModels
wmake interfacialCompositionModels
wmake multiphaseCompressibleMomentumTransportModels
wmake multiphaseReactions
Allwmake applications/solvers/multiphase/multiphaseEulerFoam/multiphaseEulerFoam
wmake multiphaseSystems
wmake functionObjects
wmake utilities
wmake mesh
wmake miscellaneous
wmake parallelProcessing
wmake postProcessing
wmake foamDictionary
wmake dataConversion
wmake decomposePar
wmake advanced
wmake foamDataToFluent
wmake autoRefineMesh
wmake foamFormatConvert
wmake collapseEdges
wmake foamToEnsight
wmake reconstructPar
wmake foamListTimes
wmake combinePatchFaces
wmake foamToEnsightParts
wmake reconstructParMesh
wmake patchSummary
wmake modifyMesh
wmake foamToGMV
wmake redistributePar
wmake graphics
wmake ensightFoamReader
Allwmake applications/utilities/postProcessing/graphics/ensightFoamReader
wmake PDRMesh
wmake preProcessing
wmake applyBoundaryLayer
wmake foamToTecplot360
Allwmake applications/utilities/postProcessing/dataConversion/foamToTecplot360
wmake foamToTetDualMesh
wmake refineHexMesh
wmake PVReaders
wmake foamToVTK
Allwmake applications/utilities/postProcessing/graphics/PVReaders
Warning: ParaView not found in /opt/OpenFOAM/ThirdParty-9/platforms/linux64Gcc/ParaView-5.6.3. Skipping.
Allwmake applications/utilities/postProcessing/dataConversion/foamToVTK
wmake boxTurb
wmake foamToVTK
wmake lagrangian
wmake particleTracks
wmake refinementLevel
wmake changeDictionary
wmake steadyParticleTracks
wmake refineWallLayer
wmake removeFaces
wmake createExternalCoupledPatchGeometry
wmake miscellaneous
wmake engineCompRatio
wmake selectCells
wmake dsmcInitialise
wmake smapToFoam
wmake pdfPlot
wmake engineSwirl
wmake splitCells
wmake faceAgglomerate
wmake postChannel
wmake conversion
wmake ansysToFoam
wmake cfx4ToFoam
wmake temporalInterpolate
wmake foamSetupCHT
wmake datToFoam
wmake fluent3DMeshToFoam
wmake noise
wmake mapFields
wmake mapFieldsPar
wmake fluentMeshToFoam
wmake postProcess
wmake surface
wmake surfaceAdd
wmake mdInitialise
wmake foamMeshToFluent
wmake thermophysical
wmake adiabaticFlameT
wmake surfaceAutoPatch
wmake foamToStarMesh
wmake setFields
wmake chemkinToFoam
wmake chemkinReader
wmake surfaceBooleanFeatures
wmake foamToSurface
wmake setWaves
wmake equilibriumCO
wmake gambitToFoam
wmake surfaceCheck
wmake viewFactorsGen
wmake equilibriumFlameT
wmake gmshToFoam
wmake gmsh
wmake surfaceClean
wmake mixtureAdiabaticFlameT
wmake surfaceCoarsen
wmake bunnylod
wmake ideasUnvToFoam
wmake surfaceConvert
wmake unv
wmake kivaToFoam
wmake surfaceFeatureConvert
wmake mshToFoam
wmake surfaceFeatures
wmake testFiles
wmake netgenNeutralToFoam
wmake surfaceFind
wmake surfaceHookUp
wmake plot3dToFoam
wmake sammToFoam
wmake generation
wmake surfaceInertia
Allwmake applications/utilities/mesh/generation
wmake blockMesh
wmake star3ToFoam
wmake star4ToFoam
wmake surfaceLambdaMuSmooth
wmake extrude
wmake extrudeMesh
wmake extrudedMesh
wmake extrudeToRegionMesh
wmake tetgenToFoam
wmake surfaceMeshConvert
wmake manipulation
wmake attachMesh
wmake extrude2DMesh
wmake vtkUnstructuredToFoam
Allwmake applications/utilities/mesh/generation/extrude2DMesh
wmake extrude2DMesh
wmake surfaceMeshConvertTesting
wmake autoPatch
wmake writeMeshObj
wmake surfaceMeshExport
wmake checkMesh
wmake createBaffles
wmake faceSelection
wmake snappyHexMesh
wmake surfaceMeshImport
wmake createPatch
wmake deformedGeom
wmake flattenMesh
wmake insideCells
wmake surfaceMeshInfo
wmake mergeBaffles
wmake mergeMeshes
wmake surfaceMeshTriangulate
wmake mirrorMesh
wmake moveDynamicMesh
wmake moveEngineMesh
wmake surfaceOrient
wmake moveMesh
wmake objToVTK
wmake orientFaceZone
wmake surfacePointMerge
wmake polyDualMesh
wmake refineMesh
wmake renumberMesh
Allwmake applications/utilities/mesh/manipulation/renumberMesh
wmake surfaceRedistributePar
wmake rotateMesh
wmake setSet
wmake surfaceRefineRedGreen
Allwmake applications/utilities/mesh/manipulation/setSet
found <readline/readline.h> -- enabling readline support.
wmake setsToZones
wmake surfaceSplitByPatch
wmake singleCellMesh
wmake splitBaffles
wmake splitMesh
wmake surfaceSplitByTopology
wmake surfaceSplitNonManifolds
wmake test
wmake surfaceSubset
wmake splitMeshRegions
wmake surfaceToPatch
wmake surfaceTransformPoints
wmake stitchMesh
wmake subsetMesh
wmake topoSet
wmake transformPoints
wmake zipUpMesh
|
验证 OpenFOAM
控制台输入 interFoam -help
,如果输出以下相似内容,说明安装成功。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | Usage: interFoam [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-fileHandler <handler>
override the fileHandler
-hostRoots <(((host1 dir1) .. (hostN dirN))>
slave root directories (per host) for distributed running
-libs <(lib1 .. libN)>
pre-load libraries
-listFunctionObjects
List functionObjects
-listFvConstraints
List fvConstraints
-listFvModels List fvModels
-listMomentumTransportModels
List momentumTransportModels
-listScalarBCs List scalar field boundary conditions (fvPatchField<scalar>)
-listSwitches List all available debug, info and optimisation switches
-listVectorBCs List vector field boundary conditions (fvPatchField<vector>)
-noFunctionObjects
do not execute functionObjects
-parallel run in parallel
-postProcess Execute functionObjects only
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
Using: OpenFOAM-9 (see https://openfoam.org)
Build: 9-8cd2ea29e64f
|