@BlookCFD 谢谢您的指点,我有看了一眼程序,我理解错了,OF里面是通过计算barycentric displacement来获得barycentric coordinates的,我一直被src/lagrangian/basic/particle/particle.C里面的一句代码给误导了,现贴出来:
particle.C 1062-1096 OpenFOAM6
void Foam::particle::correctAfterInteractionListReferral(const label celli)
{
// Get the position from the barycentric data
const vector pos(coordinates_.b(), coordinates_.c(), coordinates_.d());
// Create some arbitrary topology for the supplied cell
celli_ = celli;
tetFacei_ = mesh_.cells()[celli_][0];
tetPti_ = 1;
facei_ = -1;
// Get the reverse transform and directly set the coordinates from the
// position. This isn't likely to be correct; the particle is probably not
// in this tet. It will, however, generate the correct vector when the
// position method is called. A referred particle should never be tracked,
// so this approximate topology is good enough. By using the nearby cell we
// minimize the error associated with the incorrect topology.
coordinates_ = barycentric(1, 0, 0, 0);
if (mesh_.moving())
{
Pair<vector> centre;
FixedList<scalar, 4> detA;
FixedList<barycentricTensor, 3> T;
movingTetReverseTransform(0, centre, detA, T);
coordinates_ += (pos - centre[0]) & T[0]/detA[0];
}
else
{
vector centre;
scalar detA;
barycentricTensor T;
stationaryTetReverseTransform(centre, detA, T);
coordinates_ += (pos - centre) & T/detA;
}
}
其中的这句代码
coordinates_ += (pos - centre) & T/detA;
其实前面已经先定义了
coordinates_ = barycentric(1, 0, 0, 0);
后面计算单点的barycentric coordinates其实还是用的barycentric displacement的概念来转换的。
困扰了我两周的问题终于解决了,现在异常开心,在此对@东岳 和@BlookCFD 表示万分感谢。