OpenFOAM用户指南-3.0.1

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

开源CFD工具箱
用户指南
3.0.1版
2016年04月28日
版权声明©2011-2015 OpenFOAM Foundation Ltd.
作者:Christopher J. Greenshields, CFD Direct Ltd.
译者:李东岳、田春来(第5.5.2节)、李建治(第2.3节)、周后村(第一章)
本指南遵守:Creative Commons Attribution - NonCommercial NoDerivs 3.0 Unported License.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-
existing works, such as a translation, adaptation, derivative work, arrangement of
music or other alterations of a literary or artistic work, or phonogram or performance
and includes cinematographic adaptations or any other form in which the Work may
be recast, transformed, or adapted including in any form recognizably derived from
the original, except that a work that constitutes a Collection will not be considered an
Adaptation for the purpose of this License. For the avoidance of doubt, where the
Work is a musical work, performance or phonogram, the synchronization of the Work
in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as encyclopedias
and anthologies, or performances, phonograms or broadcasts, or other works or
subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves,
which together are assembled into a collective whole. A work that constitutes a
Collection will not be considered an Adaptation (as defined above) for the purposes of this License.
c. "Distribute" means to make available to the public the original and copies of the
Work through sale or other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work
under the terms of this License.
e. "Original Author" means, in the case of a literary or artistic work, the individual,
individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore;
(ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of
broadcasts, the organization that transmits the broadcast.
f. "Work" means the literary and/or artistic work offered under the terms of this License
including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or
entertainment in dumb show; a musical composition with or without words; a
cinematographic work to which are assimilated works expressed by a process
analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied art; an
illustration, map, plan, sketch or three-dimensional work relative to geography,
topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered
a literary or artistic work.
g. "You" means an individual or entity exercising rights under this License who has not
previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
h. "Publicly Perform" means to perform public recitations of the Work and to
communicate to the public those public recitations, by any means or process,
including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these
Works from a place and at a place individually chosen by them; to perform the Work
to the public by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to broadcast and
rebroadcast the Work by any means including signs, sounds or images.
i. "Reproduce" means to make copies of the Work by any means including without
limitation by sound or visual recordings and the right of fixation and reproducing
fixations of the Work, including storage of a protected performance or phonogram in
digital form or other electronic medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to
Reproduce the Work as incorporated in the Collections; and,
b. to Distribute and Publicly Perform the Work including as incorporated in Collections.
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d).
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms of this License.
You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or
impose any terms on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that recipient under the
terms of the License. You may not sublicense the Work. You must keep intact all
notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights
granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested.
b. You may not exercise any of the rights granted to You in Section 3 above in any
manner that is primarily intended for or directed toward commercial advantage or
private monetary compensation. The exchange of the Work for other copyrighted
works by means of digital file-sharing or otherwise shall not be considered to be
intended for or directed toward commercial advantage or private monetary
compensation, provided there is no payment of any monetary compensation in
connection with the exchange of copyrighted works.
c. If You Distribute, or Publicly Perform the Work or Collections, You must, unless a
request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably
practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other
contributing authors. For the avoidance of doubt, You may only use the credit
required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original
Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
d. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or compulsory
licensing scheme cannot be waived, the Licensor reserves the exclusive right
to collect such royalties for any exercise by You of the rights granted under
this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing
scheme can be waived, the Licensor reserves the exclusive right to collect
such royalties for any exercise by You of the rights granted under this
License if Your exercise of such rights is for a purpose or use which is
otherwise than noncommercial as permitted under Section 4(b) and
otherwise waives the right to collect royalties through any statutory or
compulsory licensing scheme; and,
iii. Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member
of a collecting society that administers voluntary licensing schemes, via that
society, from any exercise by You of the rights granted under this License
that is for a purpose or use which is otherwise than noncommercial as
permitted under Section 4(b).
e. Except as otherwise agreed in writing by the Licensor or as may be otherwise
permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the
Work either by itself or as part of any Collections, You must not distort, mutilate,
modify or take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate automatically upon any
breach by You of the terms of this License. Individuals or entities who have received
Collections from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full compliance with those
licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is perpetual (for
the duration of the applicable copyright in the Work). Notwithstanding the above,
Licensor reserves the right to release the Work under different license terms or to
stop distributing the Work at any time; provided, however that any such election will
not serve to withdraw this License (or any other license that has been, or is required
to be, granted under the terms of this License), and this License will continue in full
force and effect unless terminated as stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor
offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
b. If any provision of this License is invalid or unenforceable under applicable law, it
shall not affect the validity or enforceability of the remainder of the terms of this
License, and without further action by the parties to this agreement, such provision
shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
c. No term or provision of this License shall be deemed waived and no breach
consented to unless such waiver or consent shall be in writing and signed by the
party to be charged with such waiver or consent.
d. This License constitutes the entire agreement between the parties with respect to the
Work licensed here. There are no understandings, agreements or representations
with respect to the Work not specified here. Licensor shall not be bound by any
additional provisions that may appear in any communication from You. This License
may not be modified without the mutual written agreement of the Licensor and You.
e.The rights granted under, and the subject matter referenced, in this License were
drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of
1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant jurisdiction in which the
License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
目录
版权声明 (2)
第一章 (15)
第二章 (17)
2.1 顶盖驱动流 (17)
2.1.1 前处理 (18)
2.1.1.1 网格生成 (18)
2.1.1.2 边界和初始条件 (20)
2.1.1.3 物理特性 (21)
2.1.1.4 控制 (22)
2.1.1.5 离散方法和矩阵求解器设置 (23)
2.1.2 查看网格 (23)
2.1.3 运行算例 (24)
2.1.4 后处理 (25)
2.1.4.1 等值面和云图 (25)
2.1.4.2 矢量图 (27)
2.1.4.3 绘制流线图 (29)
2.1.5 网格细化 (29)
2.1.5.1 使用存在的算例创造新算例 (29)
2.1.5.2 生成细网格 (29)
2.1.5.3 投影算例结果 (31)
2.1.5.4 控制参数 (32)
2.1.5.5 后台运行 (32)
2.1.5.6 在细网格上绘制矢量 (32)
2.1.5.7 绘图 (33)
2.1.6 网格非均匀分布 (35)
2.1.6.1 创建非均匀化网格 (36)
2.1.6.2 调整时间步 (37)
2.1.6.3 投影场 (38)
2.1.7 增加雷诺数 (38)
2.1.7.1 前处理 (38)
2.1.7.2 运行算例 (39)
2.1.8 高雷诺数流动 (40)
2.1.8.1 前处理 (40)
2.1.8.2 运行 (42)
2.1.9 改变算例几何 (42)
2.1.10 后处理 (46)
2.2 带孔盘体应力分析 (46)
2.2.1 网格生成 (47)
2.2.1.1 边界和初始条件 (50)
2.2.1.2 物理特性 (51)
2.2.1.3 热物理特性 (51)
2.2.1.4 控制 (51)
2.2.1.5 离散格式和求解器控制 (52)
2.2.2 运行 (54)
2.2.3 后处理 (54)
2.2.4 练习 (56)
2.2.4.1 增加网格数量 (56)
2.2.4.2 引入网格非均匀化 (56)
2.2.4.3 改变平板尺寸 (56)
2.3 溃坝 (56)
2.3.1 生成网格 (57)
2.3.2 边界条件 (59)
2.3.3 设置初始场 (59)
2.3.4 流体特性 (60)
2.3.5 湍流模型 (61)
2.3.6 时间步长控制 (61)
2.3.7 离散格式 (62)
2.3.8 矩阵求解器控制 (63)
2.3.9 运行程序 (63)
2.3.10 后处理 (64)
2.3.11 并行运行 (64)
2.3.12 算例的并行后处理 (67)
第三章 (69)
3.1 OpenFOAM编程语言 (69)
3.1.1 普适性编程语言 (69)
3.1.2 面向对象和C++ (70)
3.1.3 方程呈现 (70)
3.1.4 求解器代码 (71)
3.2 编译程序和库 (71)
3.2.1 头文件:.H (71)
3.2.2 使用wmake进行编译 (73)
3.2.2.1 包含文件头 (73)
3.2.2.2 链接库 (74)
3.2.2.3 编译源文件 (75)
3.2.2.4 运行wmake (75)
3.2.2.5 wmake环境变量设置 (76)
3.2.3 移除依赖包文件:wclean和rmdepall (76)
3.2.4 编译实例:pisoFoam求解器 (77)
3.2.5 调试与优化 (79)
3.2.6使用自定义库 (80)
3.3 运行程序 (81)
3.4 并行计算 (81)
3.4.1 网格分解与初始场数据 (81)
3.4.2 运行分解算例 (84)
3.4.3 多硬盘数据阵列分布 (84)
3.4.4 并行后处理 (85)
3.4.4.2 分解场后处理 (85)
3.5 标准求解器 (85)
3.6 标准工具 (90)
3.7 标准库 (97)
第四章 (105)
4.1 OpenFOAM文件结构 (105)
4.2 基本输入输出格式 (106)
4.2.1 通用语法规则 (106)
4.2.2 字典 (106)
4.2.3头文件 (107)
4.2.4 链表 (108)
4.2.5 Scalar标量、Vector矢量、Tensor张量 (109)
4.2.6 量纲 (109)
4.2.7 单位类型 (110)
4.2.8 场 (110)
4.2.9 指令和宏替换 (111)
4.2.10 #include和#inputMode指令 (112)
4.2.11 #codeStream指令 (112)
4.3 时间和输入输出控制 (113)
4.4 离散格式 (116)
4.4.1 插值格式(interpolationSchemes) (117)
4.4.1.1 严格有界标量格式 (118)
4.4.1.2 针对矢量场的格式 (118)
4.4.2 面法向梯度格式(snGradSchemes) (119)
4.4.3 梯度格式(gradSchemes) (120)
4.4.4 拉普拉斯格式(laplacianSchemes) (121)
4.4.5 散度格式 (121)
4.4.6 时间格式 (122)
4.4.7 通量计算 (122)
4.5 求解和算法控制 (123)
4.5.1 矩阵求解器 (123)
4.5.1.1 求解误差 (124)
4.5.1.2 预条件双共轭梯度求解器 (125)
4.5.1.3 光顺矩阵求解器 (125)
4.5.1.4 GAMG (125)
4.5.2 低松弛 (126)
4.5.3 PISO和SIMPLE算法 (127)
4.5.3.1 参考压力 (127)
4.5.4 其它参数 (128)
第五章 (129)
5.1 网格 (129)
5.1.1 网格规范以及限制 (129)
5.1.1.1 点 (130)
5.1.1.3 网格单元 (131)
5.1.1.5 边界 (131)
5.1.2 polyMesh (131)
5.1.3 cellShape (132)
5.1.4 一维、二维以及轴对称问题 (133)
5.2 边界 (133)
5.2.1 在OpenFOAM中指定边界条件 (135)
5.2.2 基本类型 (136)
5.2.3 主要类型 (138)
5.2.4 衍生类型 (138)
5.3 blockMesh网格生成程序 (140)
5.3.1 编写blockMeshDict文件 (140)
5.2.1.1 顶点 (141)
5.3.1.2 边 (142)
5.3.1.3 块 (142)
5.3.1.4 block多重非均匀处理 (143)
5.3.1.5 边界 (145)
5.3.2 多块网格 (146)
5.3.3 少于8个顶点的block (148)
5.3.4 运行blockMesh (149)
5.4 snappyHexMesh网格生成工具 (149)
5.4.1 snappyHexMesh网格生成 (149)
5.4.2 创建六面体背景网格 (151)
5.4.3 特征边和特征面网格切分 (152)
5.4.4 网格移除 (154)
5.4.5 指定区域网格细化 (154)
5.4.6 表面对齐 (155)
5.4.7 网格边界层 (155)
5.4.8 网格质量控制 (158)
5.5 网格转换 (158)
5.5.1 fluentMeshToFoam (159)
5.5.2 starToFoam (160)
5.5.2.1 转换STAR-CD网格的一般建议 (160)
5.5.2.2 消除多余数据 (160)
5.5.2.3 去掉默认边界条件 (161)
5.5.2.4 模型重新编号 (162)
5.5.2.5 写入数据 (163)
5.5.2.6 .vrt文件可能的问题 (163)
5.5.2.7 转换为OpenFOAM可用格式 (164)
5.5.3 gambitToFoam (164)
5.5.4 ideasToFoam (164)
5.5.5 cfx4ToFoam (165)
5.6 不同几何上的投影场 (165)
5.6.2 非连续场投影 (165)
5.6.3 并行投影 (167)
第六章 (169)
6.1 paraFoam (169)
6.1.1 paraFoam概述 (169)
6.1.2 Properties 面板 (170)
6.1.3 display面板 (172)
6.1.4 工具栏 (173)
6.1.5 效果展示 (173)
6.1.5.1 View设置 (173)
6.1.5.2 常规设定 (174)
6.1.6 云图绘制 (174)
6.1.6.1 剖面 (174)
6.1.7 矢量图绘制 (174)
6.1.7.1 在网格中心绘制 (175)
6.1.8 流线图 (175)
6.1.9 输出图片 (175)
6.1.10 动画输出 (175)
6.2 附加函数工具 (176)
6.2.1 使用函数工具 (178)
6.2.2 预定义函数工具包 (179)
6.3 使用Fluent来后处理 (181)
6.4 使用Fieldview后处理 (182)
6.5 使用EnSight进行后处理 (183)
6.5.1转换数据为EnSight格式 (183)
6.5.2 ensight74FoamExec插件 (183)
6.5.2.1 EnSight用户插件 (183)
6.5.2.2 使用用户自定义插件 (184)
6.6 提取数据 (184)
6.7 监控和管理进程 (187)
6.7.1 运行进程的foamJob脚本 (188)
6.7.2 监控进程的foamLog脚本 (188)
第七章 (191)
7.1 热物理模型 (191)
7.1.1 热物理模型库以及混合模型 (192)
7.1.2 传递模型 (193)
7.1.3 热动力学模型 (193)
7.1.4 组分的量 (194)
7.1.5 状态方程 (195)
7.1.6能量方程变量选择 (196)
7.1.7热物理模型数据属性 (196)
7.2 湍流模型 (197)
7.2.1 模型系数 (198)
7.3 流变模型 (199)
7.3.1 牛顿流变模型 (199)
7.3.2 Bird-Carreau流变模型 (199)
7.3.3 Cross幂率流变模型 (200)
7.3.4 幂率模型 (200)
7.3.5 Herschel-Bulkley流变模型 (201)
第一章
导论
本手册是OpenFOAM(开源场运算与操作C++类库)使用指南。

本手册详细描述了OpenFOAM的基本操作,首先通过第二章一系列教程的练习,再在后续的章节对OpenFOAM 中包含的各类工具组件进行了详细地描述。

首先,OpenFOAM就是一个C++类库,用于创建可执行文件,比如应用程序(application)。

应用程序分成两类:求解器(solver)与工具(utilities)。

其中求解器是为了解决特定的连续介质力学问题而设计的;工具则是为了执行包括数据操作等任务而设计的。

OpenFOAM包含了大量的求解器和工具,牵涉的问题也比较广泛,其将在第三章进行详尽的描述。

OpenFOAM的一个特点是用户可以通过一些必要的知识(数学、物理和编程技术等)创建新的求解器和工具。

OpenFOAM需要前处理和后处理环境。

OpenFOAM本身包含前处理和后处理接口,以确保不同环境之间数据传输的一致性。

图1.1是OpenFOAM的结构示意图。

在第四章中,将对前处理和如何运行算例进行详细的阐述,第五章将阐述如何利用OpenFOAM自带的网格划分工具来生成网格,以及如何将第三方软件生成的网格进行格式转换。

第六章介绍后处理。

图 1.1:OpenFOAM总体结构示意图
第二章
教程
这一章我们描述如何设置算例、如何进行模拟以及如何对OpenFOAM算例进行后处理,主要目的是给用户提供一个如何运行OpenFOAM的基本概念。

$FOAM_TUTORIALS目录里面有许多算例可以用来展示如何使用各种求解器,以及如何使用OpenFOAM附带的各种工具。

在运行算例之前,用户必须首先确保它们正确的安装了OpenFOAM。

教程里的例子描述了如何使用前处理器blockMesh1,如何进行算例设置,如何使求解器运行起来,以及如何使用paraFoam进行后处理。

对于使用第三方后处理工具的用户,他们有两种选择:要么直接查阅paraFoam教程,要么跳至第6章查看相关描述。

所有的算例教程,都位于OpenFOAM的安装目录中。

教程中的例子依据流体类型有序的整理为一系列的文件夹,并通过求解器的名字再次分类。

例如,所有icoFoam求解器的算例都存储在incompressible/icoFoam文件夹下,其中incomprehensible代表流体类型。

如果用户想要运行一些例子,我们建议用户把教程下的例子拷贝到本地的run文件夹下,可以在终端这样执行2:
mkdir –p $FOAM_RUN
cp –r $FOAM_TUTORIALS $FOAM_RUN
2.1 顶盖驱动流
在这个教程中,我们讲述如何对一个绝热二维方腔的不可压缩流算例进行前处理、运行、以及后处理。

几何如图2.1所示,方腔所有的边界都是壁面,顶部壁面以1m/s的速度在x方向移动,其它壁面均为固定壁面。

开始,我们假定流体为层流,并使用icoFoam在一个均匀网格上求解绝热不可压层流。

接下来,我们将研究网格非均匀化以及壁面网格非均匀化对计
1网格生成工具
2对于初次使用OpenFOAM的用户,由于是在linux下运行,请注意命令的大小写以及不要遗漏空格。

全书类似的命令全部在终端执行(通过Ctrl+T打开)。

算结果的影响。

最后,增加雷诺数,使用另一个求解器:pisoFoam3来求解绝热不可压湍流。

图2.1:顶盖驱动流的几何
2.1.1 前处理
我们需要编辑算例文件来对OpenFOAM的算例进行设置。

用户需要选择一个文本编辑器来进行编辑,例如emacs, vi, gedit, kate, nedit等。

OpenFOAM允许对算例文件进行编辑,这样对一个初学者来说,使用文本文档里面的关键词来输入输出是简单易懂的。

运行算例需要一系列的数据:网格、场、物性、控制参数等。

正如4.1节所说,OpenFOAM 中这些数据存储在算例目录下的一系列文件中,而不是像其它CFD软件那样把它们存储在单一文件中。

每个算例目录都有一个合适的名字。

例如,第一个教程我们简单的称其为cavity。

在准备编辑算例文件以及运行第一个cavity算例之前,用户应该在终端运行一下命令来切换到算例目录下4:
cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity
2.1.1.1 网格生成
OpenFOAM采用三维笛卡尔坐标体系,并且所有的算例网格都是三维的5。

默认情况下,OpenFOAM在三个维度上求解算例,但是如果指定某些面的边界(例如垂直于第三个方向的平面)条件为“empty”,那么它就可以用来求解二维算例。

cavity几何由一个xy平面上边长为0.1米的正方形组成。

最开始我们使用均一的20*20网格。

block结构参见图2.2. 我们采用OpenFOAM提供的blockMesh来生成网格,它通过读取指定的字典文件来生成网格,这个字典文件位于算例文件夹下的constant/ployMesh文件夹下。

blockMeshDict文件信息如下所示:
3本手册中所有xxxFoam均为某个求解器的名字
4在终端切换
5这并不是说明都是三维算例,在OpenFOAM中,2D算例的网格在第三个方向有一定厚度
1 / *-----------------------------------------------------------------*- C++ -*---------------------------------------------------------------------------------*\
2 | ========= |
3 | \\ / Field | OpenFOAM: The Open Source CFD Toolbox |
4 | \\ / Operation | Version: 2.3.0 |
5 | \\ / And | Web: |
6 | \\/ Manipulation | |
7 \*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
8 FoamFile
9 {
10 version 2.0;
图2.2:cavity算例的block结构
11 format ascii;
12 class dictionary;
13 object blockMeshDict;
14 }
15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16
17 convertToMeters 0.1;
18
19 vertices
20 (
21 (0 0 0)
22 (1 0 0)
23 (1 1 0)
24 (0 1 0)
25 (0 0 0.1)
26 (1 0 0.1)
27 (1 1 0.1)
28 (0 1 0.1)
29 );
30
31 blocks
32 (
33 hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
34 );
35
36 edges
37 (
38 );
39
40 boundary
41 (
42 movingWall
43 {
44 type wall;
45 faces
46 (
47 (3 7 6 2)
48 );
49 }
50 fixedWalls
51 {
52 type wall;
53 faces
54 (
55 (0 4 7 3)
56 (2 6 5 1)
57 (1 5 4 0)
58 );
59 }
60 frontAndBack
61 {
62 type empty;
63 faces
64 (
65 (0 3 2 1)
66 (4 5 6 7)
67 );
68 }
69 );
70
71 mergePatchPairs
72 (
73 );
74
75 // ************************************************************************* //
文件的第一行到第七行是文件头信息,然后具体的字典信息通过的FoamFile后的({...})来指定。

在手册的剩余部分中:
为了避免赘述和节省空间,在引用具体的算例字典文件时,文件头,包括FoamFile子字典,都将省略
这个文件首先指定各个block顶点的坐标;然后通过顶点编号来定义block,最后,定义边界面。

用户可以查阅5.3节来详细了解blockMeshDict的具体意义。

网格通过在这个算例目录下运行blockMesh命令来生成。

在算例目录下,通过在终端简单地键入:
blockMesh
来完成,blockMesh命令会把运行的情况输出到终端。

blockMeshDict中的任何错误blockMesh 都会检测到并在终端输出错误,并告诉用户第几行错了。

目前我们运行这个算例的时候,不会有错误。

2.1.1.2 边界和初始条件
一旦网格生成完毕,用户可以查看这个算例的初始场信息。

在这个算例中,我们从0秒开始计算,因此初始的场信息存储在cavity目录下的0文件夹下。

0文件夹下又包含两个文件,p和U,它们是压力场和速度场,它们的初值和边界条件必须指定。

下面我们来看一下p文件:
17 dimensions [0 2 -2 0 0 0 0];
18
19 internalField uniform 0;
20
21 boundaryField
22 {
23 movingWall
24 {
25 type zeroGradient;
26 }
27
28 fixedWalls
29 {
30 type zeroGradient;
31 }
32
33 frontAndBack
34 {
35 type empty;
36 }
37 }
38
39 // ************************************************************************* //
场文件中有3个主要信息:
●dimensions 指定场的单位,此处为运动压力6,单位为m²s-2. 用户可查阅4.2.6以
获取更多信息;
●internalField 内部场可以采用用一个值就可以描述的均匀场;或者每个网格的数据
都需要指定的非均匀场(请查阅4.2.8节);
●boundaryField 指定边界场信息,包括边界条件以及所有边界面所需的信息(请查
阅4.2.8节);
对于这个cavity算例,边界场由walls组成,并分为两个patches,(1) fixedWalls,其用来指定固定边界,即cavity几何的底部和侧面。

(2) movingWall,cavity几何的上部。

作为壁面,压力边界条件均为zeroGradient,意味着压力的法相梯度为0。

frontAndBack面即为2D 算例的前后面,因此必须指定为empty。

在这个算例中(以后我们也会经常遇到),初始场我们都设置为uniform。

这里的压力为运动压力,作为不可压缩流,它的绝对值是没有意义的。

因此我们设置其为0。

这样比较简单7。

用户可以采用同样的方法来查看0/U文件。

dimensions是速度的单位。

内部场初始化为0,对于速度来说,这个值必须是一个矢量,即:uniform (0 0 0)。

请查阅4.2.5节以获取更多信息。

速度场和压力场的frontAndBack都为empty, 其它的patchs均为壁面:fixedWalls我们指定无滑移边界条件,因此为fixedValue,以及value uniform (0 0 0)。

我们假设顶部的壁面以每秒1米的速度在x方向移动,这是一个固定速度即fixedValue,其具体的值为uniform(1 0 0)。

2.1.1.3 物理特性
算例的物理特性存储在以…Properties为后缀的文件中,对于icoFoam算例,唯一需要给定的参数即为运动粘度,它存储在transportProperties字典文件中。

用户可以打开transport-Properties文件来查看运动粘度是否设置正确。

运动粘度的关键词为nu,类似于希腊字母υ的发音。

我们的算例雷诺数为10,雷诺数如下定义:
Re=d|U|
(2.1)
6即为压力除以密度之后的压力
7本算例压力边界条件全部为zeroGradient,因此需要设置压力参考点和参考值。

此处压力设置0,10,100均可。

不可压缩流中关心的是相对压力而不是绝对压力。

d和|U|分别是特征长度和速度,ϑ为运动粘度。

此处d为0.1m,|U|为1m/s,运动粘度为0.0 1m2/s。

所以雷诺数为10。

正确地指定运动粘度场应该如下所示:
17
18 nu nu [ 0 2 -1 0 0 0 0 ] 0.01;
19
20
21 // ************************************************************************* //
2.1.1.4 控制
在controlDict字典内,我们可以对时间步、输入输出时间、场数据的读取和写入来进行控制。

用户应该查阅这个文件,作为一个算例的控制文件,它位于system文件夹下。

起始时间、终止时间以及求解时间步必须要进行设定。

OpenFOAM提供了灵活的时间步控制,请查阅 4.3节。

在这个教程里我们打算在t = 0的时候开始进行计算,这意味着OpenFOAM需要读取0文件夹下的场数据,请查阅4.1节来获取更多有关算例文件结构的相关信息。

因此我们设定startFrom关键字信息为startTime,然后指定startTime为0。

运算结束的时候,我们希望能达到稳定的状态,即流体在空腔内循环。

一个通用准则是,层流下流体应该穿过(循环)计算域10次。

在这个算例中,我们没有进口和出口,因此流体没有穿过计算域。

因此结束时间应该设置为在空腔内循环10次的时间。

例如1s。

实际上,我们发现0.5s就可以了,故我们设置结束时间为0.5s。

我们通过把stopAt关键字指定为endTime然后把endTime指定为0.5来完成。

现在我们需要设定时间步,即deltaT。

当运行icoFoam的时候,为了达到数值稳定以及时间计算精度,库郎数8应该小于1。

每个网格的库郎数这样定义:
Co=δt|U|
(2.2)
δt为时间步,|U|为网格内的速度模量,δx为速度方向的网格长度。

由于流体域内速度并不均一,为了保证库郎数在各处都小于1,我们依据最大速度和最小网格尺寸来计算库郎数,在保证其小于1的前提下指定时间步。

在这个算例中网格大小是固定的,因此在顶盖附近,速度接近1m/s的地方库郎数最大,网格大小为:
δx=d
n
=
0.1
20
=0.005m(2.3)
为了使库郎数在整个流体域都小于或等于1. 时间步必须小于或等于:
δt=Co δx
||
=
1∗0.005
=0.005s(2.4)
随着计算的进行,我们希望在某个固定的时间间隔下写入数据。

以便我们可以在后处理中进行查看。

对于如何对写入时间步进行设定有很多选择,它可以通过writeControl关键字来控制。

我们决定在0.1s, 0.2s, …, 0.5s写入我们的结果。

由于计算时间步为0.005s,因此我们需
8Courant number。

相关文档
最新文档