Pimple中对速度场的操作
-
各位老师好,
我在pimple的速度场中自己添加了一个扰动变量,编译可以通过,但是运行算例时会报错。
检查了很久不知道问题出在哪里,请大家帮忙。
这个是我在pimple算法的UEqn.H文件中添加的扰动UB:// Solve the Momentum equation MRF.correctBoundaryVelocity(U); tmp<fvVectorMatrix> tUEqn ( fvm::ddt(U) + fvm::div(phiB, U)+ fvm::div(phi, UB) + MRF.DDt(U) + turbulence->divDevReff(U) == fvOptions(U) ); fvVectorMatrix& UEqn = tUEqn.ref();
单纯增加了一项变量,所以在主函数里面做了定义:
// Define phiB and UB volVectorField UB ( IOobject ( "UB", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh, dimensionedVector("UB", dimVelocity, vector::zero) ); surfaceScalarField phiB ( IOobject ( "phiB", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh );
编译是能够顺利通过的,运行算例的时候报错如下:
--> FOAM FATAL ERROR: (openfoam-2206) Incompatible fields for operation [U] + [UB] From void Foam::checkMethod(const Foam::fvMatrix<Type>&, const Foam::fvMatrix<Type>&, const char*) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 1886. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::error::simpleExit(int, bool) at ??:? #2 void Foam::checkMethod<Foam::Vector<double> >(Foam::fvMatrix<Foam::Vector<double> > const&, Foam::fvMatrix<Foam::Vector<double> > const&, char const*) in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam #3 ? in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam #4 ? in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam #5 ? in /lib/x86_64-linux-gnu/libc.so.6 #6 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 #7 ? in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam Aborted (core dumped)
提示场不匹配,所以我在循环的前后把两个场都打印了:
Starting time loop UB field type: N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE U field type: N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE UB field dimension: [0 1 -1 0 0 0 0] U field dimension: [0 1 -1 0 0 0 0] Courant Number mean: 0 max: 0 Time = 0.005 UB field type: N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE U field type: N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE UB field dimension: [0 1 -1 0 0 0 0] U field dimension: [0 1 -1 0 0 0 0] PIMPLE: iteration 1 From Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 360 Constructing fvMatrix<Type> for field U From Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 360 Constructing fvMatrix<Type> for field U From Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 360 Constructing fvMatrix<Type> for field UB From Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 360 Constructing fvMatrix<Type> for field U From Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 360 Constructing fvMatrix<Type> for field U From Foam::fvMatrix<Type>::~fvMatrix() [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 458 Destroying fvMatrix<Type> for field U --> FOAM FATAL ERROR: (openfoam-2206) Incompatible fields for operation [U] + [UB] From void Foam::checkMethod(const Foam::fvMatrix<Type>&, const Foam::fvMatrix<Type>&, const char*) [with Type = Foam::Vector<double>] in file /home/lb/v2206/OpenFOAM-v2206/src/finiteVolume/lnInclude/fvMatrix.C at line 1886. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::error::simpleExit(int, bool) at ??:? #2 void Foam::checkMethod<Foam::Vector<double> >(Foam::fvMatrix<Foam::Vector<double> > const&, Foam::fvMatrix<Foam::Vector<double> > const&, char const*) in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam #3 ? in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam #4 ? in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam #5 ? in /lib/x86_64-linux-gnu/libc.so.6 #6 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 #7 ? in ~/v2206/OpenFOAM-v2206/platforms/linux64GccDPInt32Opt/bin/dirpimpleFoam Aborted (core dumped)
可以看到初始状态的两个场是类型一致的
UB field type: N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE U field type: N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE UB field dimension: [0 1 -1 0 0 0 0] U field dimension: [0 1 -1 0 0 0 0]
但是进入第一个速度修正之后就报错了,说明这里出了问题。但是根据我自己的理解,后面的速度修正是通过添加网格运动,压力边界这些源项进行的,并没有改变速度的类型。或许变成矩阵了,但这些操作同时作用在两个场上,不知道问题出现在哪里。
后面我又用icofoam做了相同的修改,是可以运行的,感觉是在网格运动上吗,但是调试代码中也没有出现对应的报错,十分困扰。