有了上一篇的基础,就很容易做到添加新的湍流模型了,这里分别给出对四类湍流模型增加新模型的方法。探索过程不详述了,仅给出结果。
3. 添加新模型的方法。
添加湍流模型,关键的有两个,一是如果将新湍流模型添加到合适的 hashTable,以便能被求解器调用,另一个是 Make/files 和 Make/options 的写法以使湍流模型能被编译。
这里不给出具体湍流模型的代码,仅给出 Make 的写法,以及一个 .C
文件。编译湍流模型的时候,新建一个目录,将需要编译的湍流模型代码、这里给出的对应类型的 .C
文件和 Make 文件夹都拷贝到新建的目录,然后运行 wmake libso
即可。
3.1 单相不可压缩湍流模型
- makeTuebulenceModels.C
1 | #include "IncompressibleTurbulenceModel.H" |
Make/files
1
2
3makeTuebulenceModels.C
LIB = $(FOAM_USER_LIBBIN)/libTestincompressibleTurbulenceModelsMake/options
1
2
3
4
5
6
7
8
9
10
11
12EXE_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
3.2 单相可压缩湍流模型
makeTurbulenceModels.C
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#include "CompressibleTurbulenceModel.H"
#include "compressibleTransportModel.H"
#include "fluidThermo.H"
#include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H"
#include "ThermalDiffusivity.H"
#include "EddyDiffusivity.H"
#include "RASModel.H"
#include "LESModel.H"
#define makeRASModel(Type) \
makeTemplatedTurbulenceModel \
(fluidThermoCompressibleTurbulenceModel, RAS, Type)
#define makeLESModel(Type) \
makeTemplatedTurbulenceModel \
(fluidThermoCompressibleTurbulenceModel, LES, Type)
namespace Foam
{
typedef ThermalDiffusivity<CompressibleTurbulenceModel<fluidThermo> > fluidThermoCompressibleTurbulenceModel;
typedef RASModel<EddyDiffusivity<fluidThermoCompressibleTurbulenceModel> > RASfluidThermoCompressibleTurbulenceModel;
typedef LESModel<EddyDiffusivity<fluidThermoCompressibleTurbulenceModel> > LESfluidThermoCompressibleTurbulenceModel;
}
// -------------------------------------------------------------------------- //
// RAS models
// -------------------------------------------------------------------------- //
#include "mykEpsilon.H"
makeRASModel(mykEpsilon);
#include "mybuoyantKEpsilon.H"
makeRASModel(mybuoyantKEpsilon);
// -------------------------------------------------------------------------- //
// LES models
// -------------------------------------------------------------------------- //
#include "mySmagorinsky.H"
makeLESModel(mySmagorinsky);Make/files
1
2
3makeTurbulenceModels.C
LIB = $(FOAM_USER_LIBBIN)/libTestcompressibleTurbulenceModelsMake/options
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
LIB_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lsolidThermo \
-lsolidSpecie \
-lturbulenceModels \
-lspecie \
-lfiniteVolume \
-lmeshTools
注意,由于在 TurbulenceModels/compressible/lnInclude
和 TurbulenceModels/turbulenceModels/lnInclude
两个目录下,都存在 makeTurbulenceModel.H
头文件,内容是不一样的,这里需要 include 的是前者,所以在 Make/options
里, TurbulenceModels/compressible/lnInclude
一定要写在前面才能编译成功。
3.3 多相不可压缩湍流模型
DPMTurbulenceModels.C
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#include "PhaseIncompressibleTurbulenceModel.H"
#include "singlePhaseTransportModel.H"
#include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H"
//#include "laminar.H"
#include "turbulentTransportModel.H"
#include "LESModel.H"
#define makeRASModel(Type) \
makeTemplatedTurbulenceModel \
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, RAS, Type)
#define makeLESModel(Type) \
makeTemplatedTurbulenceModel \
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, LES, Type)
namespace Foam
{
typedef PhaseIncompressibleTurbulenceModel<singlePhaseTransportModel> singlePhaseTransportModelPhaseIncompressibleTurbulenceModel;
typedef RASModel<singlePhaseTransportModelPhaseIncompressibleTurbulenceModel> RASsinglePhaseTransportModelPhaseIncompressibleTurbulenceModel;
typedef LESModel<singlePhaseTransportModelPhaseIncompressibleTurbulenceModel> LESsinglePhaseTransportModelPhaseIncompressibleTurbulenceModel;
}
#include "mykEpsilon.H"
makeRASModel(mykEpsilon);
#include "mySmagorinsky.H"
makeLESModel(mySmagorinsky);Make/files
1
2
3DPMTurbulenceModels.C
LIB = $(FOAM_USER_LIBBIN)/libTestDPMTurbulenceModelsMake/options
1
2
3
4
5
6
7
8
9
10EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
注意,这里的湍流模型是给 DPMFoam
求解器用的,如果要给其他求解器写湍流模型,可能需要做些修改。
3.4 多相可压缩湍流模型
phaseCompressibleTurbulenceModels.C
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#include "PhaseCompressibleTurbulenceModel.H"
#include "phaseModel.H"
#include "twoPhaseSystem.H"
#include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H"
#include "ThermalDiffusivity.H"
#include "EddyDiffusivity.H"
//#include "laminar.H"
#include "RASModel.H"
#include "LESModel.H"
#define makeRASModel(Type) \
makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, RAS, Type)
#define makeLESModel(Type) \
makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, LES, Type)
namespace Foam
{
typedef ThermalDiffusivity<PhaseCompressibleTurbulenceModel<phaseModel> > phaseModelPhaseCompressibleTurbulenceModel;
typedef RASModel<EddyDiffusivity<phaseModelPhaseCompressibleTurbulenceModel> > RASphaseModelPhaseCompressibleTurbulenceModel;
typedef LESModel<EddyDiffusivity<phaseModelPhaseCompressibleTurbulenceModel> > LESphaseModelPhaseCompressibleTurbulenceModel;
}
#include "mykEpsilon.H"
makeRASModel(mykEpsilon);
#include "mySmagorinsky.H"
makeLESModel(mySmagorinsky);
#include "myphasePressureModel.H"
makeTurbulenceModel
(phaseModelPhaseCompressibleTurbulenceModel, RAS, myphasePressureModel);Make/files
1
2
3
4phaseCompressibleTurbulenceModels.C
phasePressureModel/myphasePressureModel.C
LIB = $(FOAM_USER_LIBBIN)/libTestphaseCompressibleTurbulenceModelsMake/options
1
2
3
4
5
6
7
8
9
10
11EXE_INC = \
-I$(WM_PROJECT_DIR)/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/lnInclude \
-I$(WM_PROJECT_DIR)/applications/solvers/multiphase/twoPhaseEulerFoam/interfacialModels/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/transportModel \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
注意,这里的湍流模型是给求解器 twoPhaseEulerFoam
用的,如果要给其他求解器开发湍流模型,可能需要做些修改。