MacOS原生OpenFOAM App: 用户指南¶
摘要
OpenFOAM是一款开源的CFD软件,功能很强大,而且可扩展性非常强。这里的可扩展性指的是在OpenFOAM的基础上可以自己开发各种求解器解决一些特定的问题。然而,OpenFOAM也存在开源软件的普遍问题:学习曲线较陡。尤其是软件安装,这第一步就会劝退一大批人。不论是OpenFOAM官网还是一些网上的教程,针对MacOS系统下的安装全都是基于Docker或者其他的虚拟机。其逻辑都是通过虚拟机虚拟出Linux系统,然后再虚拟的Linux系统里面使用OF。这种方式存在很多问题,最大的问题就是运行效率低,自己开发求解器的时候不容易调试。所以,最好的解决方案就是在MacOS系统下从OF源码编译出原生的程序,但是几乎所有平台都没有给出这种解决方案!即使找到了某种方式进行编译,也是非常麻烦,需要解决很多第三方依赖库和编译器的问题,非常浪费时间还不一定能搞定!基于此,本人花了一些时间将OpenFOAM的主流的版本编译为原生的app,解决了以上所有的这些繁琐的问题,非常容易使用。尤其对于一些初学者或者编程不太熟悉的用户,以前可能从来无法实现或者需要很长时间才能实现的问题,现在可以在一分钟之内解决问题。本文主要介绍如何下载和使用OpenFOAM app。下面是详细介绍文本,同时也配有亲手操作的演示视频。
1. 下载¶
下载很简单,访问 OpenFOAM MacOS 网站,查看可用版本并通过 解锁 按钮进行相应的下载操作(如下截图所示)。如果网站上没有列出您的目标版本,可以发送请求到|myemail|进行私人定制。
2. 安装¶
如果第一步完成,则相应的软件下载链接通过邮件发送给您。比如OpenFOAM-9的Apple Silicon芯片版本(下面的过程全部以此版本为例进行讲解),下载得到的app文件为 OpenFOAM-9-darwin-arm64.dmg
镜像文件。双击打开即可得到如下图所示的内容,与常规的MacOS的app安装一样,只需要简单地将 :code:OpenFOAM-9 拖入左边的 Applications
目录即可完成安装。
拖入完成之后,即可在LaunchPad中发现OpenFOAM-9 app,如下图所示:
app的文件列表¶
安装完成之后的app位于路径 /Applications/OpenFOAM-9.app/Contents
中,其中的文件列表如下图所示。其中 MacOS
目录中存放初始化脚本; Resources/bin
中存放所有的可执行文件; Resources/lib
中存放所有的动态库文件; Resources/etc
中存放所有的环境配置文件; Resources/OpenFOAM-9.sparsebundle
为存放源代码的Case sensitive镜像文件(用于存放OpenFOAM源代码的,因为OF的源代码的文件名是区分大小写的,然而MacOS的默认文件系统是不区分文件名大小写的,所以通过创建一个区分大小写的disk image是比较明智的选择)。
/Applications/OpenFOAM-9.app/Contents
├── Info.plist
├── MacOS
│ └── OpenFOAM-9
├── Resources
│ ├── OpenFOAM-9.icns
│ ├── bin
│ │ ├── PDRFoam
│ │ ├── PDRMesh
│ │ ├── SRFPimpleFoam
│ │ ├── SRFSimpleFoam
│ │ ├── XiEngineFoam
│ │ ├── XiFoam
│ │ ├── adiabaticFlameT
│ │ ├── adjointShapeOptimisationFoam
│ │ ├── ansysToFoam
│ │ ├── applyBoundaryLayer
│ │ ├── attachMesh
│ │ ├── autoPatch
│ │ ├── autoRefineMesh
│ │ ├── blockMesh
│ │ ├── boundaryFoam
│ │ ├── boxTurb
│ │ ├── buoyantPimpleFoam
│ │ ├── buoyantReactingFoam
│ │ ├── buoyantSimpleFoam
│ │ ├── cavitatingFoam
│ │ ├── cfx4ToFoam
│ │ ├── changeDictionary
│ │ ├── checkMesh
│ │ ├── chemFoam
│ │ ├── chemkinToFoam
│ │ ├── chtMultiRegionFoam
│ │ ├── coldEngineFoam
│ │ ├── collapseEdges
│ │ ├── combinePatchFaces
│ │ ├── compressibleInterFoam
│ │ ├── compressibleMultiphaseInterFoam
│ │ ├── createBaffles
│ │ ├── createExternalCoupledPatchGeometry
│ │ ├── createPatch
│ │ ├── datToFoam
│ │ ├── decomposePar
│ │ ├── deformedGeom
│ │ ├── denseParticleFoam
│ │ ├── dnsFoam
│ │ ├── driftFluxFoam
│ │ ├── dsmcFoam
│ │ ├── dsmcInitialise
│ │ ├── electrostaticFoam
│ │ ├── engineCompRatio
│ │ ├── engineFoam
│ │ ├── engineSwirl
│ │ ├── equilibriumCO
│ │ ├── equilibriumFlameT
│ │ ├── extrude2DMesh
│ │ ├── extrudeMesh
│ │ ├── extrudeToRegionMesh
│ │ ├── faceAgglomerate
│ │ ├── financialFoam
│ │ ├── flattenMesh
│ │ ├── fluent3DMeshToFoam
│ │ ├── fluentMeshToFoam
│ │ ├── foamDataToFluent
│ │ ├── foamDictionary
│ │ ├── foamFormatConvert
│ │ ├── foamListTimes
│ │ ├── foamMeshToFluent
│ │ ├── foamSetupCHT
│ │ ├── foamToEnsight
│ │ ├── foamToEnsightParts
│ │ ├── foamToGMV
│ │ ├── foamToStarMesh
│ │ ├── foamToSurface
│ │ ├── foamToTetDualMesh
│ │ ├── foamToVTK
│ │ ├── gambitToFoam
│ │ ├── gmshToFoam
│ │ ├── icoFoam
│ │ ├── ideasUnvToFoam
│ │ ├── insideCells
│ │ ├── interFoam
│ │ ├── interMixingFoam
│ │ ├── kivaToFoam
│ │ ├── laplacianFoam
│ │ ├── magneticFoam
│ │ ├── mapFields
│ │ ├── mapFieldsPar
│ │ ├── mdEquilibrationFoam
│ │ ├── mdFoam
│ │ ├── mdInitialise
│ │ ├── mergeBaffles
│ │ ├── mergeMeshes
│ │ ├── mhdFoam
│ │ ├── mirrorMesh
│ │ ├── mixtureAdiabaticFlameT
│ │ ├── modifyMesh
│ │ ├── moveDynamicMesh
│ │ ├── moveEngineMesh
│ │ ├── moveMesh
│ │ ├── mshToFoam
│ │ ├── multiphaseEulerFoam
│ │ ├── multiphaseInterFoam
│ │ ├── netgenNeutralToFoam
│ │ ├── noise
│ │ ├── nonNewtonianIcoFoam
│ │ ├── objToVTK
│ │ ├── orientFaceZone
│ │ ├── particleFoam
│ │ ├── particleTracks
│ │ ├── patchSummary
│ │ ├── pdfPlot
│ │ ├── pimpleFoam
│ │ ├── pisoFoam
│ │ ├── plot3dToFoam
│ │ ├── polyDualMesh
│ │ ├── porousSimpleFoam
│ │ ├── postChannel
│ │ ├── postProcess
│ │ ├── potentialFoam
│ │ ├── potentialFreeSurfaceFoam
│ │ ├── reactingFoam
│ │ ├── reconstructPar
│ │ ├── reconstructParMesh
│ │ ├── redistributePar
│ │ ├── refineHexMesh
│ │ ├── refineMesh
│ │ ├── refineWallLayer
│ │ ├── refinementLevel
│ │ ├── removeFaces
│ │ ├── renumberMesh
│ │ ├── rhoCentralFoam
│ │ ├── rhoParticleFoam
│ │ ├── rhoPimpleFoam
│ │ ├── rhoPorousSimpleFoam
│ │ ├── rhoSimpleFoam
│ │ ├── rotateMesh
│ │ ├── sammToFoam
│ │ ├── scalarTransportFoam
│ │ ├── selectCells
│ │ ├── setFields
│ │ ├── setSet
│ │ ├── setWaves
│ │ ├── setsToZones
│ │ ├── shallowWaterFoam
│ │ ├── simpleFoam
│ │ ├── singleCellMesh
│ │ ├── smapToFoam
│ │ ├── snappyHexMesh
│ │ ├── solidDisplacementFoam
│ │ ├── solidEquilibriumDisplacementFoam
│ │ ├── splitBaffles
│ │ ├── splitCells
│ │ ├── splitMesh
│ │ ├── splitMeshRegions
│ │ ├── star3ToFoam
│ │ ├── star4ToFoam
│ │ ├── steadyParticleTracks
│ │ ├── stitchMesh
│ │ ├── subsetMesh
│ │ ├── surfaceAdd
│ │ ├── surfaceAutoPatch
│ │ ├── surfaceBooleanFeatures
│ │ ├── surfaceCheck
│ │ ├── surfaceClean
│ │ ├── surfaceCoarsen
│ │ ├── surfaceConvert
│ │ ├── surfaceFeatureConvert
│ │ ├── surfaceFeatures
│ │ ├── surfaceFind
│ │ ├── surfaceHookUp
│ │ ├── surfaceInertia
│ │ ├── surfaceLambdaMuSmooth
│ │ ├── surfaceMeshConvert
│ │ ├── surfaceMeshConvertTesting
│ │ ├── surfaceMeshExport
│ │ ├── surfaceMeshImport
│ │ ├── surfaceMeshInfo
│ │ ├── surfaceMeshTriangulate
│ │ ├── surfaceOrient
│ │ ├── surfacePointMerge
│ │ ├── surfaceRedistributePar
│ │ ├── surfaceRefineRedGreen
│ │ ├── surfaceSplitByPatch
│ │ ├── surfaceSplitByTopology
│ │ ├── surfaceSplitNonManifolds
│ │ ├── surfaceSubset
│ │ ├── surfaceToPatch
│ │ ├── surfaceTransformPoints
│ │ ├── temporalInterpolate
│ │ ├── tetgenToFoam
│ │ ├── thermoFoam
│ │ ├── topoSet
│ │ ├── transformPoints
│ │ ├── twoLiquidMixingFoam
│ │ ├── viewFactorsGen
│ │ ├── vtkUnstructuredToFoam
│ │ ├── writeMeshObj
│ │ └── zipUpMesh
│ ├── etc
│ │ ├── README.org
│ │ ├── bashrc
│ │ ├── caseDicts
│ │ │ ├── annotated
│ │ │ │ ├── PDRMeshDict
│ │ │ │ ├── adiabaticFlameTDict
│ │ │ │ ├── autoRefineMeshDict
│ │ │ │ ├── changeDictionaryDict
│ │ │ │ ├── collapseDict
│ │ │ │ ├── createBafflesDict
│ │ │ │ ├── createPatchDict
│ │ │ │ ├── decomposeParDict
│ │ │ │ ├── equilibriumFlameTDict
│ │ │ │ ├── extrude2DMeshDict
│ │ │ │ ├── extrudeMeshDict
│ │ │ │ ├── extrudeToRegionMeshDict
│ │ │ │ ├── foamDataToFluentDict
│ │ │ │ ├── foamyHexMeshDict
│ │ │ │ ├── foamyQuadMeshDict
│ │ │ │ ├── mapFieldsDict
│ │ │ │ ├── mirrorMeshDict
│ │ │ │ ├── mixtureAdiabaticFlameTDict
│ │ │ │ ├── modifyMeshDict
│ │ │ │ ├── particleTrackDict
│ │ │ │ ├── pdfDict
│ │ │ │ ├── postChannelDict
│ │ │ │ ├── refineMeshDict
│ │ │ │ ├── renumberMeshDict
│ │ │ │ ├── selectCellsDict
│ │ │ │ ├── setFieldsDict
│ │ │ │ ├── setWavesDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ ├── surfaceFeaturesDict
│ │ │ │ ├── surfaceHookUpDict
│ │ │ │ ├── surfaceSubsetDict
│ │ │ │ ├── toleranceDict
│ │ │ │ ├── topoSetDict
│ │ │ │ ├── viewFactorsDict
│ │ │ │ └── wallFunctionDict
│ │ │ ├── general
│ │ │ │ ├── coordinateSystem
│ │ │ │ │ ├── cartesianXY
│ │ │ │ │ ├── cartesianXZ
│ │ │ │ │ ├── cartesianYZ
│ │ │ │ │ └── cylindrical
│ │ │ │ ├── fvConstraints
│ │ │ │ │ ├── limitPressure
│ │ │ │ │ └── limitTemperature
│ │ │ │ ├── fvModels
│ │ │ │ │ └── porosity
│ │ │ │ │ └── porousZone
│ │ │ │ ├── fvSolution
│ │ │ │ │ └── relaxationFactors
│ │ │ │ │ ├── steadyState
│ │ │ │ │ └── transient
│ │ │ │ └── workflow
│ │ │ │ ├── Allclean
│ │ │ │ ├── Allmesh
│ │ │ │ └── Allrun
│ │ │ ├── mesh
│ │ │ │ ├── generation
│ │ │ │ │ ├── collapseDict
│ │ │ │ │ ├── extrudeMeshDict
│ │ │ │ │ ├── foamyHexMeshDict
│ │ │ │ │ ├── meshQualityDict
│ │ │ │ │ ├── meshQualityDict.cfg
│ │ │ │ │ ├── snappyHexMeshDict
│ │ │ │ │ └── snappyHexMeshDict.cfg
│ │ │ │ └── manipulation
│ │ │ │ ├── AMI
│ │ │ │ │ ├── createBafflesDict
│ │ │ │ │ └── createPatchDict
│ │ │ │ ├── baffles
│ │ │ │ │ └── createBafflesDict
│ │ │ │ ├── patches
│ │ │ │ │ └── createPatchDict
│ │ │ │ └── refineRegion
│ │ │ │ ├── refineMeshDict
│ │ │ │ └── topoSetDict
│ │ │ ├── postProcessing
│ │ │ │ ├── combustion
│ │ │ │ │ ├── Qdot
│ │ │ │ │ └── XiReactionRate
│ │ │ │ ├── control
│ │ │ │ │ ├── stopAtClockTime
│ │ │ │ │ ├── stopAtFile
│ │ │ │ │ ├── time
│ │ │ │ │ ├── timeStep
│ │ │ │ │ └── writeObjects
│ │ │ │ ├── fields
│ │ │ │ │ ├── CourantNo
│ │ │ │ │ ├── Lambda2
│ │ │ │ │ ├── MachNo
│ │ │ │ │ ├── PecletNo
│ │ │ │ │ ├── Q
│ │ │ │ │ ├── age
│ │ │ │ │ ├── components
│ │ │ │ │ ├── ddt
│ │ │ │ │ ├── div
│ │ │ │ │ ├── enstrophy
│ │ │ │ │ ├── fieldAverage
│ │ │ │ │ ├── fieldAverage.cfg
│ │ │ │ │ ├── flowType
│ │ │ │ │ ├── grad
│ │ │ │ │ ├── log
│ │ │ │ │ ├── mag
│ │ │ │ │ ├── magSqr
│ │ │ │ │ ├── phaseMap
│ │ │ │ │ ├── randomise
│ │ │ │ │ ├── randomise.cfg
│ │ │ │ │ ├── scale
│ │ │ │ │ ├── shearStress
│ │ │ │ │ ├── streamFunction
│ │ │ │ │ ├── totalEnthalpy
│ │ │ │ │ ├── turbulenceFields
│ │ │ │ │ ├── turbulenceIntensity
│ │ │ │ │ ├── vorticity
│ │ │ │ │ ├── wallHeatFlux
│ │ │ │ │ ├── wallHeatTransferCoeff
│ │ │ │ │ ├── wallShearStress
│ │ │ │ │ ├── writeCellCentres
│ │ │ │ │ ├── writeCellVolumes
│ │ │ │ │ ├── writeVTK
│ │ │ │ │ └── yPlus
│ │ │ │ ├── fieldsOperations
│ │ │ │ │ ├── add
│ │ │ │ │ ├── divide
│ │ │ │ │ ├── multiply
│ │ │ │ │ ├── subtract
│ │ │ │ │ └── uniform
│ │ │ │ ├── forces
│ │ │ │ │ ├── forceCoeffs.cfg
│ │ │ │ │ ├── forceCoeffsCompressible
│ │ │ │ │ ├── forceCoeffsIncompressible
│ │ │ │ │ ├── forceCoeffsIncompressible.cfg
│ │ │ │ │ ├── forces.cfg
│ │ │ │ │ ├── forcesCompressible
│ │ │ │ │ ├── forcesIncompressible
│ │ │ │ │ ├── forcesIncompressible.cfg
│ │ │ │ │ └── phaseForces
│ │ │ │ ├── graphs
│ │ │ │ │ ├── graph.cfg
│ │ │ │ │ ├── graphCell
│ │ │ │ │ ├── graphCell.cfg
│ │ │ │ │ ├── graphUniform
│ │ │ │ │ └── graphUniform.cfg
│ │ │ │ ├── lagrangian
│ │ │ │ │ └── dsmcFields
│ │ │ │ ├── minMax
│ │ │ │ │ ├── cellMax
│ │ │ │ │ ├── cellMax.cfg
│ │ │ │ │ ├── cellMaxMag
│ │ │ │ │ ├── cellMaxMag.cfg
│ │ │ │ │ ├── cellMin
│ │ │ │ │ ├── cellMin.cfg
│ │ │ │ │ ├── cellMinMag
│ │ │ │ │ ├── cellMinMag.cfg
│ │ │ │ │ └── cellMinMax.cfg
│ │ │ │ ├── numerical
│ │ │ │ │ ├── residuals
│ │ │ │ │ └── residuals.cfg
│ │ │ │ ├── pressure
│ │ │ │ │ ├── pressure.cfg
│ │ │ │ │ ├── staticPressureIncompressible
│ │ │ │ │ ├── staticPressureIncompressible.cfg
│ │ │ │ │ ├── totalPressureCompressible
│ │ │ │ │ ├── totalPressureCompressible.cfg
│ │ │ │ │ ├── totalPressureIncompressible
│ │ │ │ │ └── totalPressureIncompressible.cfg
│ │ │ │ ├── probes
│ │ │ │ │ ├── boundaryProbes
│ │ │ │ │ ├── boundaryProbes.cfg
│ │ │ │ │ ├── interfaceHeight
│ │ │ │ │ ├── interfaceHeight.cfg
│ │ │ │ │ ├── internalProbes
│ │ │ │ │ ├── internalProbes.cfg
│ │ │ │ │ ├── probes
│ │ │ │ │ └── probes.cfg
│ │ │ │ ├── solvers
│ │ │ │ │ ├── particles
│ │ │ │ │ ├── phaseScalarTransport
│ │ │ │ │ ├── phaseScalarTransport.cfg
│ │ │ │ │ ├── scalarTransport
│ │ │ │ │ └── scalarTransport.cfg
│ │ │ │ ├── streamlines
│ │ │ │ │ ├── streamlines.cfg
│ │ │ │ │ ├── streamlinesLine
│ │ │ │ │ ├── streamlinesLine.cfg
│ │ │ │ │ ├── streamlinesPatch
│ │ │ │ │ ├── streamlinesPatch.cfg
│ │ │ │ │ ├── streamlinesPoints
│ │ │ │ │ ├── streamlinesPoints.cfg
│ │ │ │ │ ├── streamlinesSphere
│ │ │ │ │ └── streamlinesSphere.cfg
│ │ │ │ ├── surface
│ │ │ │ │ ├── cutPlaneSurface
│ │ │ │ │ ├── cutPlaneSurface.cfg
│ │ │ │ │ ├── isoSurface
│ │ │ │ │ ├── isoSurface.cfg
│ │ │ │ │ ├── patchSurface
│ │ │ │ │ ├── patchSurface.cfg
│ │ │ │ │ └── surface.cfg
│ │ │ │ └── surfaceFieldValue
│ │ │ │ ├── faceZoneAverage
│ │ │ │ ├── faceZoneFlowRate
│ │ │ │ ├── faceZoneValue.cfg
│ │ │ │ ├── patchAverage
│ │ │ │ ├── patchDifference
│ │ │ │ ├── patchDifference.cfg
│ │ │ │ ├── patchFlowRate
│ │ │ │ ├── patchIntegrate
│ │ │ │ ├── patchValue.cfg
│ │ │ │ ├── surfaceDifference.cfg
│ │ │ │ ├── surfaceValue.cfg
│ │ │ │ ├── triSurfaceDifference
│ │ │ │ ├── triSurfaceDifference.cfg
│ │ │ │ ├── triSurfaceValue.cfg
│ │ │ │ └── triSurfaceVolumetricFlowRate
│ │ │ ├── preProcessing
│ │ │ │ ├── decomposeParDict
│ │ │ │ ├── mapFieldsDict
│ │ │ │ └── setFieldsDict
│ │ │ ├── setConstraintTypes
│ │ │ ├── solvers
│ │ │ │ ├── chemistry
│ │ │ │ │ └── TDAC
│ │ │ │ │ ├── chemistryProperties.cfg
│ │ │ │ │ └── chemistryPropertiesFlame.cfg
│ │ │ │ ├── lagrangian
│ │ │ │ │ └── cloudProperties
│ │ │ │ └── scalarTransport
│ │ │ │ ├── s
│ │ │ │ ├── scalarTransportDict
│ │ │ │ └── scalarTransportDict.cfg
│ │ │ └── surface
│ │ │ ├── surfaceFeatureExtractDict.cfg
│ │ │ ├── surfaceFeaturesDict
│ │ │ └── surfaceFeaturesDict.cfg
│ │ ├── cellModels
│ │ ├── codeTemplates
│ │ │ ├── BC
│ │ │ │ ├── BC.C
│ │ │ │ ├── BC.H
│ │ │ │ ├── BCs.C
│ │ │ │ ├── BCs.H
│ │ │ │ ├── BCsFwd.H
│ │ │ │ └── Make
│ │ │ │ ├── files
│ │ │ │ └── options
│ │ │ ├── app
│ │ │ │ ├── Make
│ │ │ │ │ ├── files
│ │ │ │ │ └── options
│ │ │ │ ├── app.C
│ │ │ │ └── createFields.H
│ │ │ ├── dynamicCode
│ │ │ │ ├── Function2Template.C
│ │ │ │ ├── Function2Template.H
│ │ │ │ ├── basicChemistryModel
│ │ │ │ ├── basicChemistryModelTemplate.C
│ │ │ │ ├── codeStreamTemplate.C
│ │ │ │ ├── codedFixedValueFvPatchFieldTemplate.C
│ │ │ │ ├── codedFixedValueFvPatchFieldTemplate.H
│ │ │ │ ├── codedFixedValuePointPatchFieldTemplate.C
│ │ │ │ ├── codedFixedValuePointPatchFieldTemplate.H
│ │ │ │ ├── codedFunction1Template.C
│ │ │ │ ├── codedFunction1Template.H
│ │ │ │ ├── codedFunctionObjectTemplate.C
│ │ │ │ ├── codedFunctionObjectTemplate.H
│ │ │ │ ├── codedFvModelTemplate.C
│ │ │ │ ├── codedFvModelTemplate.H
│ │ │ │ ├── codedMixedFvPatchFieldTemplate.C
│ │ │ │ ├── codedMixedFvPatchFieldTemplate.H
│ │ │ │ ├── fluidReactionThermo
│ │ │ │ ├── fluidReactionThermoTemplate.C
│ │ │ │ ├── fluidThermo
│ │ │ │ ├── fluidThermoTemplate.C
│ │ │ │ ├── psiThermo
│ │ │ │ ├── psiThermoTemplate.C -> fluidThermoTemplate.C
│ │ │ │ ├── psiuReactionThermo
│ │ │ │ ├── psiuReactionThermoTemplate.C
│ │ │ │ ├── rhoReactionThermo -> fluidReactionThermo
│ │ │ │ ├── rhoReactionThermoTemplate.C -> fluidReactionThermoTemplate.C
│ │ │ │ ├── rhoThermo -> fluidThermo
│ │ │ │ └── rhoThermoTemplate.C -> fluidThermoTemplate.C
│ │ │ ├── foamCommentStyles
│ │ │ ├── foamScript
│ │ │ ├── functionObject
│ │ │ │ ├── FUNCTIONOBJECT.C
│ │ │ │ ├── FUNCTIONOBJECT.H
│ │ │ │ └── Make
│ │ │ │ ├── files
│ │ │ │ └── options
│ │ │ ├── source
│ │ │ │ ├── _Template.C
│ │ │ │ ├── _Template.H
│ │ │ │ ├── _TemplateApp.C
│ │ │ │ ├── _TemplateI.H
│ │ │ │ ├── _TemplateIO.C
│ │ │ │ └── foamNewSource
│ │ │ └── template
│ │ │ ├── _TemplateTemplate.C
│ │ │ ├── _TemplateTemplate.H
│ │ │ ├── _TemplateTemplateI.H
│ │ │ ├── _TemplateTemplateIO.C
│ │ │ └── foamNewTemplate
│ │ ├── config.csh
│ │ │ ├── aliases
│ │ │ ├── ensight
│ │ │ ├── example
│ │ │ │ ├── compiler
│ │ │ │ ├── openmpi
│ │ │ │ ├── paraview
│ │ │ │ └── prefs.csh
│ │ │ ├── mac
│ │ │ │ └── paraview
│ │ │ ├── mpi
│ │ │ ├── paraview
│ │ │ ├── settings
│ │ │ └── unset
│ │ ├── config.sh
│ │ │ ├── CGAL
│ │ │ ├── aliases
│ │ │ ├── bash_completion
│ │ │ ├── compiler
│ │ │ ├── ensight
│ │ │ ├── example
│ │ │ │ ├── compiler
│ │ │ │ ├── openmpi
│ │ │ │ ├── paraview
│ │ │ │ └── prefs.sh
│ │ │ ├── functions
│ │ │ ├── gperftools
│ │ │ ├── mac
│ │ │ │ ├── CGAL
│ │ │ │ ├── functions
│ │ │ │ ├── metis
│ │ │ │ ├── paraview
│ │ │ │ └── scotch
│ │ │ ├── metis
│ │ │ ├── mpi
│ │ │ ├── paraview
│ │ │ ├── scotch
│ │ │ ├── settings
│ │ │ └── unset
│ │ ├── controlDict
│ │ ├── cshrc
│ │ ├── paraFoam
│ │ ├── templates
│ │ │ ├── axisymmetricJet
│ │ │ │ ├── 0
│ │ │ │ │ ├── U
│ │ │ │ │ ├── epsilon
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ └── p
│ │ │ │ ├── Allclean
│ │ │ │ ├── Allrun
│ │ │ │ ├── README
│ │ │ │ ├── constant
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ └── transportProperties
│ │ │ │ └── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── controlDict
│ │ │ │ ├── extrudeMeshDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ └── graph
│ │ │ ├── closedVolume
│ │ │ │ ├── 0
│ │ │ │ │ ├── T
│ │ │ │ │ ├── U
│ │ │ │ │ ├── alphat
│ │ │ │ │ ├── epsilon
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ ├── p
│ │ │ │ │ └── p_rgh
│ │ │ │ ├── README
│ │ │ │ ├── constant
│ │ │ │ │ ├── g
│ │ │ │ │ ├── geometry
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ └── thermophysicalProperties
│ │ │ │ └── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── controlDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ ├── meshQualityDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ └── surfaceFeaturesDict
│ │ │ ├── closedVolumeRotating
│ │ │ │ ├── 0
│ │ │ │ │ ├── U
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ └── p
│ │ │ │ ├── README
│ │ │ │ ├── constant
│ │ │ │ │ ├── MRFProperties
│ │ │ │ │ ├── dynamicMeshDict
│ │ │ │ │ ├── geometry
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ ├── rotatingZoneProperties
│ │ │ │ │ └── transportProperties
│ │ │ │ └── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── blockMeshDict-box
│ │ │ │ ├── controlDict
│ │ │ │ ├── createBafflesDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ ├── meshQualityDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ └── surfaceFeaturesDict
│ │ │ ├── compressibleInflowOutflow
│ │ │ │ ├── 0
│ │ │ │ │ ├── T
│ │ │ │ │ ├── U
│ │ │ │ │ ├── alphat
│ │ │ │ │ ├── epsilon
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ └── p
│ │ │ │ ├── README
│ │ │ │ ├── constant
│ │ │ │ │ ├── geometry
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ └── thermophysicalProperties
│ │ │ │ └── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── controlDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ ├── meshQualityDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ └── surfaceFeaturesDict
│ │ │ ├── inflowOutflow
│ │ │ │ ├── 0
│ │ │ │ │ ├── U
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ └── p
│ │ │ │ ├── README
│ │ │ │ ├── constant
│ │ │ │ │ ├── geometry
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ └── transportProperties
│ │ │ │ └── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── controlDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ ├── meshQualityDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ └── surfaceFeaturesDict
│ │ │ ├── inflowOutflowRotating
│ │ │ │ ├── 0
│ │ │ │ │ ├── U
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ └── p
│ │ │ │ ├── README
│ │ │ │ ├── constant
│ │ │ │ │ ├── MRFProperties
│ │ │ │ │ ├── dynamicMeshDict
│ │ │ │ │ ├── geometry
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ ├── rotatingZoneProperties
│ │ │ │ │ └── transportProperties
│ │ │ │ └── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── blockMeshDict-box
│ │ │ │ ├── controlDict
│ │ │ │ ├── createBafflesDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ ├── meshQualityDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ └── surfaceFeaturesDict
│ │ │ └── singleFluidCHT
│ │ │ ├── Allclean
│ │ │ ├── Allmesh
│ │ │ ├── Allrun
│ │ │ ├── README
│ │ │ ├── constant
│ │ │ │ ├── geometry
│ │ │ │ ├── initialConditions
│ │ │ │ └── materialProperties
│ │ │ ├── system
│ │ │ │ ├── blockMeshDict
│ │ │ │ ├── controlDict
│ │ │ │ ├── decomposeParDict
│ │ │ │ ├── fvSchemes
│ │ │ │ ├── fvSolution
│ │ │ │ ├── meshQualityDict
│ │ │ │ ├── snappyHexMeshDict
│ │ │ │ └── surfaceFeaturesDict
│ │ │ └── templates
│ │ │ ├── 0
│ │ │ │ ├── fluid
│ │ │ │ │ ├── G
│ │ │ │ │ ├── T
│ │ │ │ │ ├── U
│ │ │ │ │ ├── alphat
│ │ │ │ │ ├── epsilon
│ │ │ │ │ ├── k
│ │ │ │ │ ├── nut
│ │ │ │ │ ├── omega
│ │ │ │ │ ├── p
│ │ │ │ │ └── p_rgh
│ │ │ │ └── solid
│ │ │ │ └── T
│ │ │ ├── constant
│ │ │ │ ├── fluid
│ │ │ │ │ ├── g
│ │ │ │ │ └── pRef
│ │ │ │ └── solid
│ │ │ │ └── fvModels
│ │ │ ├── materials
│ │ │ │ ├── air
│ │ │ │ │ ├── momentumTransport
│ │ │ │ │ ├── radiationProperties
│ │ │ │ │ ├── thermophysicalProperties
│ │ │ │ │ └── thermophysicalTransport
│ │ │ │ ├── aluminium
│ │ │ │ │ ├── radiationProperties
│ │ │ │ │ └── thermophysicalProperties
│ │ │ │ ├── copper
│ │ │ │ │ ├── radiationProperties
│ │ │ │ │ └── thermophysicalProperties
│ │ │ │ └── water
│ │ │ │ ├── momentumTransport
│ │ │ │ ├── radiationProperties
│ │ │ │ ├── thermophysicalProperties
│ │ │ │ └── thermophysicalTransport
│ │ │ └── system
│ │ │ ├── fluid
│ │ │ │ ├── fvSchemes
│ │ │ │ └── fvSolution
│ │ │ └── solid
│ │ │ ├── fvSchemes
│ │ │ └── fvSolution
│ │ └── thermoData
│ │ ├── therm.dat
│ │ └── thermoData
│ └── lib
│ ├── dummy
│ │ ├── libMGridGen.dylib
│ │ ├── libPstream.dylib
│ │ ├── libmetisDecomp.dylib
│ │ ├── libptscotchDecomp.dylib
│ │ └── libscotchDecomp.dylib
│ ├── libDSMC.dylib
│ ├── libODE.dylib
│ ├── libOSspecific.o
│ ├── libOpenFOAM.dylib
│ ├── libPstream.dylib
│ ├── libVoFClouds.dylib
│ ├── libVoFSurfaceFilm.dylib
│ ├── libatmosphericModels.dylib
│ ├── libbarotropicCompressibilityModel.dylib
│ ├── libblockMesh.dylib
│ ├── libchemistryModel.dylib
│ ├── libcombustionModels.dylib
│ ├── libcompressibleInterPhaseTransportModel.dylib
│ ├── libcompressibleMomentumTransportModels.dylib
│ ├── libcompressibleTwoPhaseChangeModels.dylib
│ ├── libconversion.dylib
│ ├── libdecompose.dylib
│ ├── libdecompositionMethods.dylib
│ ├── libdistributed.dylib
│ ├── libdistributionModels.dylib
│ ├── libdriftFluxRelativeVelocityModels.dylib
│ ├── libdriftFluxTransportModels.dylib
│ ├── libdynamicFvMesh.dylib
│ ├── libdynamicMesh.dylib
│ ├── libengine.dylib
│ ├── libeulerianInterfacialCompositionModels.dylib
│ ├── libeulerianInterfacialModels.dylib
│ ├── libevent_core-2.1.7.dylib
│ ├── libevent_pthreads-2.1.7.dylib
│ ├── libextrude2DMesh.dylib
│ ├── libextrudeModel.dylib
│ ├── libfieldFunctionObjects.dylib
│ ├── libfileFormats.dylib
│ ├── libfiniteVolume.dylib
│ ├── libfluidReactionThermophysicalTransportModels.dylib
│ ├── libfluidThermophysicalModels.dylib
│ ├── libfoamToVTK.dylib
│ ├── libforces.dylib
│ ├── libfvConstraints.dylib
│ ├── libfvModels.dylib
│ ├── libfvMotionSolvers.dylib
│ ├── libgenericPatchFields.dylib
│ ├── libhwloc.15.dylib
│ ├── libimmiscibleIncompressibleTwoPhaseMixture.dylib
│ ├── libincompressibleMomentumTransportModels.dylib
│ ├── libincompressibleTwoPhaseMixture.dylib
│ ├── libinterfaceProperties.dylib
│ ├── liblagrangian.dylib
│ ├── liblagrangianFunctionObjects.dylib
│ ├── liblagrangianParcel.dylib
│ ├── liblagrangianParcelTurbulence.dylib
│ ├── liblaminarFlameSpeedModels.dylib
│ ├── libmeshTools.dylib
│ ├── libmetis.dylib
│ ├── libmetisDecomp.dylib
│ ├── libmolecularMeasurements.dylib
│ ├── libmolecule.dylib
│ ├── libmomentumTransportModels.dylib
│ ├── libmpi.40.dylib
│ ├── libmultiphaseEulerFoamFunctionObjects.dylib
│ ├── libmultiphaseInterFoam.dylib
│ ├── libmultiphaseMixtureThermo.dylib
│ ├── libmultiphaseMomentumTransportModels.dylib
│ ├── libmultiphaseReactions.dylib
│ ├── libmultiphaseSystems.dylib
│ ├── libopen-pal.40.dylib
│ ├── libopen-rte.40.dylib
│ ├── libpairPatchAgglomeration.dylib
│ ├── libphaseCompressibleMomentumTransportModels.dylib
│ ├── libphaseFluidReactionThermophysicalTransportModels.dylib
│ ├── libphaseFluidThermophysicalTransportModels.dylib
│ ├── libphaseIncompressibleMomentumTransportModels.dylib
│ ├── libphaseSystem.dylib
│ ├── libpotential.dylib
│ ├── libptscotch.dylib
│ ├── libptscotchDecomp.dylib
│ ├── libptscotcherrexit.dylib
│ ├── libradiationModels.dylib
│ ├── librandomProcesses.dylib
│ ├── libreactionThermophysicalModels.dylib
│ ├── libreconstruct.dylib
│ ├── libregionModels.dylib
│ ├── librenumberMethods.dylib
│ ├── librhoCentralFoam.dylib
│ ├── librigidBodyDynamics.dylib
│ ├── librigidBodyMeshMotion.dylib
│ ├── librigidBodyState.dylib
│ ├── libsampling.dylib
│ ├── libscotch.dylib
│ ├── libscotchDecomp.dylib
│ ├── libscotcherrexit.dylib
│ ├── libsixDoFRigidBodyMotion.dylib
│ ├── libsixDoFRigidBodyState.dylib
│ ├── libsnappyHexMesh.dylib
│ ├── libsolidDisplacementThermo.dylib
│ ├── libsolidParticle.dylib
│ ├── libsolidThermo.dylib
│ ├── libsolverFunctionObjects.dylib
│ ├── libspecie.dylib
│ ├── libspecieTransfer.dylib
│ ├── libsurfMesh.dylib
│ ├── libsurfaceFilmModels.dylib
│ ├── libthermalBaffleModels.dylib
│ ├── libthermophysicalProperties.dylib
│ ├── libthermophysicalTransportModels.dylib
│ ├── libtopoChangerFvMesh.dylib
│ ├── libtransportModels.dylib
│ ├── libtriSurface.dylib
│ ├── libtwoPhaseChangeModels.dylib
│ ├── libtwoPhaseMixture.dylib
│ ├── libtwoPhaseMixtureThermo.dylib
│ ├── libtwoPhaseProperties.dylib
│ ├── libtwoPhaseSurfaceTension.dylib
│ ├── libuserd-foam.dylib
│ ├── libutilityFunctionObjects.dylib
│ ├── libwaves.dylib
│ └── openmpi-system
│ ├── libPstream.dylib
│ └── libptscotchDecomp.dylib
3. 加载OpenFOAM环境¶
完成以上步骤之后就跟其他所有系统或者平台下使用OpenFOAM没有区别了,只需要加载环境变量就行。
首次安装后的环境加载¶
首次安装后加载环境很容易,只需要打开lunchpad并用鼠标点击 OpenFOAM-9
app ( 图 14 ) 即可。
然后会弹出一个小对话框(如下图所示),提示本需要用户进行安全确认。
对于所有不是App Store里面下载的软件,都会有此提示。只需要在系统的Security & Privacy里面点击允许即可。
备注
细心的同学可能发现,上面的几个截图里面的app名字是OpenFOAM-8-x86_64,这是因为我写这篇博文的时候用的是M1芯片的MacBook,而举例使用的OpenFOAM-9-arm64 app就是本机器下编译的,所以不会出现安全验证的提示。为了给大家展示这个安全验证的提示信息,所以上面的截图运行的x86_64架构的app是另一个Inter芯片的MacBook上编译的。一般情况下,除了开发者自己的电脑,其他人安装app并第一次打开的时候都会出现以上的安全验证提示。
安全验证允许之后,会弹出一个终端窗口(如 图 19 所示),在这个终端窗口里已经自动加载了OpenFOAM环境,可以运行OF自带的求解器,所有的相关的环境变量都有效。总之一句话,在这个终端窗口里可以做所有OpenFOAM的工作。
自动加载OpenFOAM环境¶
通过上面的方式(直接点击OpenFOAM app,在弹出的终端里面进行工作)可以工作,但是如果关闭这个窗口或者在其他的终端窗口里面是没有加载OF环境的,也就意味这无法运行OF的程序。我个人喜欢的一种方式就是在系统环境profile文件里面加入一段代码(如下所示),让其自动加载OpenFOAM环境: 随便打开一个终端都可以使用OpenFOAM 。
# =========== OpenFOAM initialization start ===========
FOAM_DISK_IMAGE=/Applications/OpenFOAM-9.app/Contents/Resources/OpenFOAM-9.sparsebundle
FOAM_MOUNT_POINT=/Volumes/OpenFOAM-9
FOAM_VERSION=9
if [ ! -f ${FOAM_MOUNT_POINT}/etc/bashrc ]; then
hdiutil attach -quiet -mountpoint ${FOAM_MOUNT_POINT} ${FOAM_DISK_IMAGE} && . ${FOAM_MOUNT_POINT}/etc/bashrc
else
source ${FOAM_MOUNT_POINT}/etc/bashrc
fi
# =========== OpenFOAM initialization end ===========
只需要复制以上代码并粘贴到 ~/.bash_profile
文件中并保存即可。这样以后随便打开一个终端都能使用OpenFOAM了,就不用再在Launchpad里面点击OpenFOAM app了。
备注
至此,在Mac系统安装原生OpenFOAM软件几加载环境的步骤就全部完成了,非常容易,一分钟之内就可以完成! 从此开始,在Mac系统下使用OpenFOAM与Linux系统下完全相同。