数值风云

Openfoam的findcell在for循环里面和外面对于同一坐标结果不一致

各位老师同学好,最近写的一个代码的一个小部分用到了findcell去找点所在的cell,但是发现了一个奇怪的问题。对于两个点,我单独findcell出来结果是对的,但是在循环里面算出来这两个点后再findcell,结果不对。首先,代码我已经把无用的都删了后如下:

#include "fvCFD.H"
#include "meshSearch.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    argList::addBoolOption
    (
        "noOverwrite",
        "increment time to avoid overwriting initial fields"
    );
    #include "setRootCase.H"
    #include "createTime.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    #include "createMesh.H"
IOdictionary blockMeshDict
(
    IOobject
    (
        "blockMeshDict",
        runTime.system(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    )
);  
IOdictionary NetProperties
(
    IOobject
    (
        "NetProperties",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    )
);
const dictionary& NetDict(NetProperties.subDict("deltaFunction"));
const label  nx(blockMeshDict.lookup<scalar>("nx"));
const label  ny(blockMeshDict.lookup<scalar>("ny"));
const label  nz(blockMeshDict.lookup<scalar>("nz"));
const scalar lx(blockMeshDict.lookup<scalar>("lx"));
const scalar ly(blockMeshDict.lookup<scalar>("ly"));
const scalar lz(blockMeshDict.lookup<scalar>("lz"));
const scalar dx = lx/nx;
const scalar dy = ly/ny;
const scalar dz = lz/nz;
const List<label> offSet_
(
    NetDict.lookup("a")
);

meshSearch searchEngine_(mesh);

vector tmpKnotPoint(1.5,0.72,1.359);
vector point1(1.47727,0.694583,1.30181);
vector point2(1.5,0.694583,1.30181);
Pout << "point1 (1.47727 0.694583 1.30181) should be inside cell " << searchEngine_.findCell(point1) << endl;
Pout << "point2(1.5 0.694583 1.30181) should be inside cell " << searchEngine_.findCell(point2) << endl;

vector tmpOffSetPoint;
label num = 0;
forAll(offSet_, zi)
{
    tmpOffSetPoint.z() = tmpKnotPoint.z() + offSet_[zi]*dz;
    forAll(offSet_, yi)
    {
        tmpOffSetPoint.y() = tmpKnotPoint.y() + offSet_[yi]*dy; 
        forAll(offSet_, xi)
        {
            tmpOffSetPoint.x() = tmpKnotPoint.x() + offSet_[xi]*dx;
            label cellId = searchEngine_.findCell(tmpOffSetPoint);
            Pout << num << "  " << cellId << "  " << tmpOffSetPoint  << endl;
        }                    
    }
}

    return 0;
}

输出如下:

point1 (1.47727 0.694583 1.30181) should be inside cell 423586
point2(1.5 0.694583 1.30181) should be inside cell 423587
0  423587  (1.47727 0.694583 1.30181)
0  423587  (1.5 0.694583 1.30181)
0  423785  (1.47727 0.72 1.30181)
0  423785  (1.5 0.72 1.30181)
0  442595  (1.47727 0.694583 1.359)
0  442595  (1.5 0.694583 1.359)
0  442793  (1.47727 0.72 1.359)
0  442793  (1.5 0.72 1.359)

循环里输出的Cell 的Id对于这两个点(1.47727 0.694583 1.30181)和(1.5 0.694583 1.30181)都是423587,但是上面的输出,在for循环外直接输出这两个坐标findcell的结果,那就是一个423586,另一个是423587.

难道是findcell用的方法不对,还是什么其他原因呢?请各位同学老师帮下忙。谢谢!