当前位置:网站首页>Compile openfoam solver with cmake
Compile openfoam solver with cmake
2022-07-26 00:40:00 【jedi-knight】
The goal is
OpenFoam Bring their own wmake The command can compile the solver written by yourself . But if you want to use OpenFoam With other libraries ( such as OpenNN) Joint development , Then it is necessary Use CMake Management project .
This article gives specific operation methods :
https://blog.csdn.net/weixin_43940314/article/details/123771467
Because this article is in OpenFoam8 Implemented below , If OpenFoam9, It needs a little modification
Code
CMake The code is as follows :
cmake_minimum_required(VERSION 2.8.12)
if (DEFINED ENV{
WM_PROJECT})
message("Using $ENV{WM_PROJECT}-$ENV{WM_PROJECT_VERSION}")
set(WM_PATH, ${
CMAKE_SOURCE_DIR})
else()
message(FATAL_ERROR "OpenFOAM environment not set. Aborting.")
endif ()
project(testFHC) # Project name
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OpenFOAM_VERSION $ENV{
WM_PROJECT_VERSION})
set(OpenFOAM_DIR $ENV{
WM_PROJECT_DIR})
set(OpenFOAM_LIB_DIR $ENV{
FOAM_LIBBIN})
set(OpenFOAM_SRC $ENV{
FOAM_SRC})
set(DEFINITIONS_COMPILE "-std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -fPIC ") # Requirements for compilation
add_definitions("${DEFINITIONS_COMPILE}")
include_directories(
${
OpenFOAM_SRC}/finiteVolume/lnInclude
${
OpenFOAM_SRC}/meshTools/lnInclude
${
OpenFOAM_SRC}/fvModels/lnInclude
${
OpenFOAM_SRC}/thermophysicalModels/solidThermo/lnInclude
lnInclude
.
${
OpenFOAM_SRC}/OpenFOAM/lnInclude
${
OpenFOAM_SRC}/OSspecific/POSIX/lnInclude
) # Dependent header directory
link_directories(${
OpenFOAM_LIB_DIR} ${
OpenFOAM_LIB_DIR}/dummy ${
OpenFOAM_LIB_DIR}/${
PATH_LIB_OPENMPI})
add_executable(${
PROJECT_NAME} fhcFoam.C burnback.C) # Add executable
target_link_libraries(${
PROJECT_NAME} OpenFOAM dl m Pstream finiteVolume fvModels fvConstraints meshTools)
Explain the following :set Used to set variables and paths add_definitions Used for setting up g++ A series of parameters adopted by the compiler , If these parameters are not set correctly , It is likely to cause compilation failure include_directories Used to set the header file directory , according to openFoam Fill in the actual requirements of the solver link_directories Used to set the directory of library files , Don't change add_executable Source file for adding solver , There are several C Just fill in a few names in the document target_link_libraries Used to add library files that need to be linked , Fill in as needed
边栏推荐
猜你喜欢

8 tips - database performance optimization, yyds~

Comparing the seven distributed transaction schemes, I prefer Alibaba's open source Seata (principle + Practice)

Hcip day 12

Verilog语法基础HDL Bits训练 06

Redis命令参考手册 - Key

【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源

Hoops exchange helps hybrid computational fluid dynamics software build 3D format import and read function | customer case

HNOI2012矿场搭建

找出单身狗(力扣260)

Redis夺命十二问,你能扛到第几问?
随机推荐
Research on text classification of e-commerce comments based on mffmb
找出单身狗(力扣260)
sql语句练习
Research on the integrated data quality management system and technical framework under the scenario of data circulation and transaction
YOLOV2 YOLO9000
HCIP第十二天
GOM and GEE engine black screen does not display the interface, and the solution of equipping map monsters
YOLOV3
[oops framework] random number generation management
分布式事务和Seata的AT模式原理
YOLOV3
How much data can a list store?
生物JC UVSSA复合物缓解MYC驱动的转录压⼒ English
8 tips to adjust database performance optimization, yyds
Introduction of MySQL transactions
[oops framework] network module websocket
The way of understanding JS: what is prototype chain
前缀异或和,异或差分数组
进程与线程
Use localdate class to complete calendar design