OpenFoam-6 导入并编译一个新湍流模型

本文参考了以下链接
http://hassankassem.me/posts/newturbulencemodel/#new-version
https://pingpong.chalmers.se/public/courseId/7056/lang-en/publicPage.do?item=3256524
https://www.cfd-online.com/Forums/openfoam-programming-development/181508-addition-new-turbulence-models-giviing-errors.html#post660305
https://www.cfd-online.com/Forums/openfoam/199105-error-during-add-turbulence-model-openfoam-5-0-a.html
https://www.cfd-online.com/Forums/openfoam-programming-development/191446-symbol-lookup-error-simplefoam.html

一 准备原始模型

首先,在终端在定位到你的工作目录,然后执行以下操作(如果你不熟悉命令行操作,也可以按注释进行图形界面的操作)

#从$FOAM_SRC/TurbulenceModels/turbulenceModels/RAS/ 中复制kOmegaSST文件夹并改名为newkOmegaSST
cp  -r $FOAM_SRC/TurbulenceModels/turbulenceModels/RAS/kOmegaSST $FOAM_RUN/newkOmegaSST
# 进入你新建的文件夹
cd newkOmegaSST
# 将文件夹中的kOmegaSST.H命名为newkOmegaSST.H
mv kOmegaSST.H newkOmegaSST.H
# 将文件夹中的kOmegaSST.C命名为newkOmegaSST.C
mv kOmegaSST.C newkOmegaSST.C
# 复制 $FOAM_SRC/TurbulenceModels/incompressible中的Make文件夹到你的工作目录
cp -r $FOAM_SRC/TurbulenceModels/incompressible/Make/ .
cp -r $FOAM_SRC/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C maketurbulentTransportModels.C

二 修改编译配置

在前述操作中,你从OpenFOAM的源文件中复制了一个名为turbulentTransportModels.C的文件,并将其命名为maketurbulentTransportModels.C
现在打开该文件,仅保留第一个#include声明及第一个宏命令,其余内容全部删除,并添加下述内容:

#include "newkOmegaSST.H"
makeRASModel(newkOmegaSST);

修改完成后的文件如下所示

接着你应当修改Make文件夹下的files文件
首先打开这个文件,并清空里面的内容,并加入如下代码,最后保存退出
这段代码表示了.so文件的生成路径,也可以生成在当前目录下,需要调用的时候指定.so文件所在目录就行

maketurbulentTransportModels.C
LIB = $(FOAM_USER_LIBBIN)/libmyincompressibleTurbulenceModels

如下图所示


对Make文件夹下的options作如下操作
清空该文件原始内容,并添加如下代码,保存退出.

EXE_INC = \-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \-I$(LIB_SRC)/transportModels \-I$(LIB_SRC)/finiteVolume/lnInclude \-I$(LIB_SRC)/meshTools/lnInclude \LIB_LIBS = \-lincompressibleTransportModels \-lturbulenceModels \-lfiniteVolume \-lmeshTools

如下图所示

三 修改.H 和.C 文件

采用gedit命令分别打开newkOmegaSST.H和newkOmegaSST.C文件,将原有出现kOmegaSST的地方使用newkOmegaSST进行替换,但使用sed命令进行替换时需要注意不要将基类替换,这里需要替换的地方较少我采用手动替换,以便清楚展示。
newkOmegaSST.H

/*---------------------------------------------------------------------------*\=========                 |\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox\\    /   O peration     | Website:  https://openfoam.org\\  /    A nd           | Copyright (C) 2016-2018 OpenFOAM Foundation\\/     M anipulation  |
-------------------------------------------------------------------------------
LicenseThis file is part of OpenFOAM.OpenFOAM is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.OpenFOAM is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public Licensefor more details.You should have received a copy of the GNU General Public Licensealong with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.\*---------------------------------------------------------------------------*/#include "newkOmegaSST.H"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //namespace Foam
{
namespace RASModels
{// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //template<class BasicTurbulenceModel>
newkOmegaSST<BasicTurbulenceModel>::newkOmegaSST
(const alphaField& alpha,const rhoField& rho,const volVectorField& U,const surfaceScalarField& alphaRhoPhi,const surfaceScalarField& phi,const transportModel& transport,const word& propertiesName,const word& type
)
:Foam::kOmegaSST<eddyViscosity<RASModel<BasicTurbulenceModel>>,BasicTurbulenceModel>(type,alpha,rho,U,alphaRhoPhi,phi,transport,propertiesName)
{if (type == typeName){this->printCoeffs(type);}
}// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //} // End namespace RASModels
} // End namespace Foam// ************************************************************************* //

newkOmegaSST.H

/*---------------------------------------------------------------------------*\=========                 |\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox\\    /   O peration     | Website:  https://openfoam.org\\  /    A nd           | Copyright (C) 2016-2018 OpenFOAM Foundation\\/     M anipulation  |
-------------------------------------------------------------------------------
LicenseThis file is part of OpenFOAM.OpenFOAM is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.OpenFOAM is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public Licensefor more details.You should have received a copy of the GNU General Public Licensealong with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.ClassFoam::RASModels::kOmegaSSTDescriptionSpecialisation for RAS of the generic kOmegaSSTBase base class.For more information, see Description of kOmegaSSTBase.HSee alsoFoam::kOmegaSSTSourceFileskOmegaSST.C\*---------------------------------------------------------------------------*/#ifndef newkOmegaSST_H
#define newkOmegaSST_H#include "kOmegaSSTBase.H"
#include "RASModel.H"
#include "eddyViscosity.H"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //namespace Foam
{
namespace RASModels
{/*---------------------------------------------------------------------------*\Class kOmegaSST Declaration
\*---------------------------------------------------------------------------*/template<class BasicTurbulenceModel>
class newkOmegaSST
:public Foam::kOmegaSST<eddyViscosity<RASModel<BasicTurbulenceModel>>,BasicTurbulenceModel>
{public:typedef typename BasicTurbulenceModel::alphaField alphaField;typedef typename BasicTurbulenceModel::rhoField rhoField;typedef typename BasicTurbulenceModel::transportModel transportModel;//- Runtime type informationTypeName("newkOmegaSST");// Constructors//- Construct from componentsnewkOmegaSST(const alphaField& alpha,const rhoField& rho,const volVectorField& U,const surfaceScalarField& alphaRhoPhi,const surfaceScalarField& phi,const transportModel& transport,const word& propertiesName = turbulenceModel::propertiesName,const word& type = typeName);//- Destructorvirtual ~newkOmegaSST(){}
};// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //} // End namespace RASModels
} // End namespace Foam// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository#include "newkOmegaSST.C"
#endif// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif// ************************************************************************* //

四 编译

定位到newkOmegaSST文件夹,wclean,wmake进行编译
如图所示

五 调用新模型计算

复制simpleFoam中的pitzDaily算例至$FOAM_RUN文件夹,在system文件夹中的controlDict文件中添加以下语句

libs ("libmyincompressibleTurbulenceModels.so");

如图所示

如果之前自定义了生成的.so文件路径,则需要加上路径。

接下来打开constant文件夹中的turbulenceProperties替换湍流模型为newkOmegaSST

定位到pitzDaily文件夹,在终端执行计算命令,成功出现结果。

OpenFoam-6 导入并编译一个新湍流模型相关推荐

  1. 操原作业(一)Ubuntu系统编译一个新的内核

    操作系统原理这门课布置了一项作业,要求在Ubuntu系统中编译一个新的内核.下面介绍怎么在Ubuntu系统中编译一个新的内核. 安装Ubuntu系统 如何安装win10+Ubuntu双系统,我已经在上 ...

  2. (26) 降雨量预测-一个基准和一个新的模型

    交通预见未来(26): TrajGRU降雨量预测-一个基准和一个新的模型 1.文章信息 <Deep Learning for Precipitation Nowcasting: A Benchm ...

  3. TrajGRU降雨量预测: 一个基准和一个新的模型

    前面看过ConvLSTM的文章: 初识ConvLSTM, 这篇文章和ConvLSTM算是姊妹篇吧,先大概看看,后面有时间再仔细研读~ 1.文章信息 <Deep Learning for Prec ...

  4. linux卸载libxml2,请问把libxml2删除了,在编译一个新的libxml后yum使用不了,怎么回事呢?...

    jjk334 于 2013-05-31 16:33:38发表: [root@localhost ~]# yum list There was a problem importing one of th ...

  5. 如何快速弄懂一个新模型_如何评估创业项目是否靠谱?一个新的模型 | 创创锦囊...

    要判断一个创业项目是否靠谱,是否能拥有广阔的市场和巨大的增长潜力,不仅是投资人关心的话题,更是每一个创业者在创业过程中不断思考的问题. 投资人关注大趋势.大机会,遵循自上而下的思维模型,在心仪的赛道上 ...

  6. ROS学习笔记4(编译一个ROS Package)

    文章目录 1 准备工作 2 使用catkin_make 3 编译一个package 1 准备工作 在所有的系统依赖项都安装好之后,就可以编译一个新的package了. 注意:如果是使用apt方式安装的 ...

  7. IDEA中导入一个新项目,出现了Cannot resolve symbol 'String'

    问题描述:使用IDEA导入一个新项目,出现了String字体样式变成红色,并且提示,如下图所示: 解决办法:本人IDEA版本是IntelliJ IDEA 2018.1.5 (Ultimate Edit ...

  8. OpenFOAM修改湍流模型之后出现#duplicate entry的解决办法

    OpenFOAM修改湍流模型之后出现#duplicate entry的解决办法 参考文章: OpenFOAM-Duplicate Entry 解决办法:link 如何在OF6中添加新的湍流模型? :l ...

  9. TensorFlow 教程 --进阶指南--3.6增加一个新 Op

    预备知识: 对 C++ 有一定了解. 已经下载 TensorFlow 源代码并有能力编译它. 如果现有的库没有涵盖你想要的操作, 你可以自己定制一个. 为了使定制的 Op 能够兼容原有的库 , 你必须 ...

最新文章

  1. LeetCode简单题之最小绝对差
  2. 食品行业ERP选型 需把握关键的20%
  3. c++ 读文件_Linux文件(文件夹)详解
  4. GDCM:LCNumeric的测试程序
  5. Flink的基于ValueState的状态机
  6. LeetCode(38): 报数
  7. 一个简单的Map Iterator性能测试
  8. oracle将字符串转化为blob,oracle String类型转换成blob类型插入
  9. python 计算每日累计_5分钟学会用Python可视化数据分析美股
  10. 怎么调节手机的刷新率_价格均在2000元内,5G网络配高刷新率屏幕手机怎么选
  11. 我的设计模型之适配器模式
  12. php接收post数据 json数据,PHP接收post数据并解析json的简单实例
  13. 初识Python必看基础知识~ 续(6)九层之台,起于垒土,肝肝肝~
  14. ora-01652无法通过128(在表空间temp中)扩展temp段
  15. 小人有三种,这种最阴险,最好策略不是硬杠
  16. 计算机的c盘是硬盘吗,笔记本固态硬盘是c盘吗_笔记本电脑SSD固态硬盘就是C盘吗-win7之家...
  17. ubuntu grub深入剖析个性设置
  18. oracle数据库优化之统计分析
  19. 省时省力的PDF编辑技巧,不会实在可惜
  20. 飞拓无限助力猫眼娱乐,共同推动电影平台商业化

热门文章

  1. 期货成交量与持仓量(期货成交量与持仓量的秘密)
  2. 分析一下onedns系统
  3. class torch.optim.lr_scheduler.LambdaLR
  4. 小程序API的Promise化
  5. 第七讲:4.智能物联网开关——角度倾斜报警实验例程
  6. Android默认音乐,控制Android或任何其他音乐播放器的默认音乐播放器
  7. Vue style里面使用scoped属性并@import引入外部css, 作用域是全局的解决方案
  8. 几种常见的RAID工作模式讨论
  9. 2021周记07:新的一年正式开始
  10. python生成春联图片,并包装为GUI工具