|
[Sponsors] |
The results of findCell are different out and in for-loop |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 23, 2021, 05:27 |
The results of findCell are different out and in for-loop
|
#1 |
New Member
Shuo Mi
Join Date: Nov 2020
Location: London
Posts: 19
Rep Power: 5 |
Hello everyone,
I came across a problem when I wrote my own solver. I need to use findCell to find the which cell that my point is in. But for the same point, the results of findCell are different out and in my for-loop. Code:
#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; } HTML Code:
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) I have no idea about this. I tried mesh.findCell, the same results. Could anyone tell me what's wrong in this piece of code? Thanks so much! |
|
Tags |
openfoam; findcell; |
|
|