最近在研究边界条件的问题,想复制一个边界条件出来修改编译测试。参考了网上的教程,但是还是有些问题,想请教大家。
OpenFOAM里面的边界条件有些只包括一个C文件,一个H文件,这种边界条件按照网上的教程都可以直接编译。比如fixedFluxPressure,我拷贝到新的文件夹test下,创建一个Make文件夹,在其内部创建files和options文件:
files:
fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
LIB = $(FOAM_USER_LIBBIN)/libUsr
options:
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude\
LIB_LIBS = \
-lfiniteVolume
编译正常。
但是还有一部分的边界条件包含多个C文件和H文件,这种就编译不成功了。以cyclic为例,拷贝$FOAM_SRC/finiteVolume/fields/fvPatchFields/constraint/cyclic 到testcyclic文件夹,test下面生成Make文件夹,Make里面建立files和options:
files:
cyclic/cyclicFvPatchField.C
LIB = $(FOAM_USER_LIBBIN)/libcyclicFvPatchField
options:
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude\
LIB_LIBS = \
-lfiniteVolume
执行wmake libso
wmake libso .
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file cyclicFvPatchField.C
g++ -std=c++11 -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 -I/home/xc15/OpenFOAM/OpenFOAM-7/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/xc15/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude -I/home/xc15/OpenFOAM/OpenFOAM-7/src/OSspecific/POSIX/lnInclude -fPIC -c cyclic/cyclicFvPatchField.C -o Make/linux64GccDPInt32Opt/cyclic/cyclicFvPatchField.o
cyclic/cyclicFvPatchField.C:32:1: error: redefinition of ‘Foam::cyclicFvPatchField<Type>::cyclicFvPatchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&)’
Foam::cyclicFvPatchField<Type>::cyclicFvPatchField
^
In file included from cyclic/cyclicFvPatchField.H:225:0,
from cyclic/cyclicFvPatchField.C:26:
cyclic/cyclicFvPatchField.C:32:1: error: ‘Foam::cyclicFvPatchField<Type>::cyclicFvPatchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&)’ previously declared here
Foam::cyclicFvPatchField<Type>::cyclicFvPatchField
^
cyclic/cyclicFvPatchField.C:44:1: error: redefinition of ‘Foam::cyclicFvPatchField<Type>::cyclicFvPatchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::dictionary&)’
Foam::cyclicFvPatchField<Type>::cyclicFvPatchField
........
make: *** [Make/linux64GccDPInt32Opt/cyclic/cyclicFvPatchField.o] Error 1
error太长,只贴了一部分,但是基本上都是说重复定义和声明
正确的编译方式应该是什么?:mihu: