OpenFOAM编程findCell的诡异问题,对同一坐标寻找cell结果不一致
-
@李东岳 在 OpenFOAM编程findCell的诡异问题,对同一坐标寻找cell结果不一致 中说:
另外你没用过primitiveMesh的findCell()试试么,这种
point a(1,2,3); mesh.findCell(a);
我几年前记得在某个SCI里面看到过说meshSearch好像效率低,不过具体细节我忘了
老师,mesh search和mesh的findCell我都是用了的,一样的结果,都是循环外单独找那两个点是对的,循环内就不对,是重复的CellID
-
-
@oitocfd 之前写过一个小函数,具体是在dpmfoam里用到的,是寻找一个颗粒所在的cell label以及这个cell周围的一圈cell label,不知道能不能帮到你。
template<class Type> const Foam::labelList& Foam::interpolationCellAround<Type>::cellpointCells ( const label celli, DynamicList<label>& storage ) const { const labelList& cPoints = this->psi_.mesh().cellPoints()[celli]; storage.clear(); forAll(cPoints, i) { const label pointi = cPoints[i]; const labelList& pointcellsi = this->psi_.mesh().pointCells()[pointi]; forAll(pointcellsi, j) { storage.append(pointcellsi[j]); } } // Filter duplicates if (storage.size() > 1) { sort(storage); label n = 1; for (label i = 1; i < storage.size(); i++) { if (storage[i-1] != storage[i]) { storage[n++] = storage[i]; } } // truncate addressed list storage.setSize(n); } return storage; } template<class Type> const Foam::labelList& Foam::interpolationCellAround<Type>::cellpointCells(const label celli) const { return cellpointCells(celli, labels_); } interpolationCellAround是自定义的类,主要是函数的实现。
-
-
应该是精度的问题,polyMesh 的findCell 的原型为:findCell(const point & p,const cellDecomposition decompMode = CELL_TETS) 默认是使用polyMesh里的八叉树进行空间搜索的,vector每个点是一个双精度值,有效数字大约有11位置,而Info只输出了部分有效数字,感觉你直接这样写出来,就会损失精度
vector tmpKnotPoint(1.5,0.72,1.359); vector point1(1.47727,0.694583,1.30181); vector point2(1.5,0.694583,1.30181); 如果网格尺寸很小的话可能造成差异,
还有就是,我的记得polyMesh 网格索引树默认的精度是1e-3 如果你的网格尺寸小的话你可以调整一下,具体的你可以去看indexedOctree<>这个类的实现
2021年11月22日 21:51
15/15
2022年1月1日 12:46