我又回来了,这次发现虽然写了用坐标去计算不同点的阻力系数,但是实际计算中发现还是均一的,以为是定义的变量被重新赋值了,重写了所有的中间变量发现也没办法解决,目前认为是坐标计算的不对或者openfoam porosityModel不支持非均一的阻力系数设置
如果想用场自定义阻力需要如何操作呢?直接改求解器加入源项,然后在0文件夹写初始场?
forAll(cells, i)
{
gamma_[zoneI][i] = Zero;
scalar x = mesh_.C()[i].x();
scalar y = mesh_.C()[i].y();
scalar z = mesh_.C()[i].z();
scalar dir = y;
if (xxx)
{
gamma_[zoneI][i].xx() = xxx;
gamma_[zoneI][i].yy() = xxx;
gamma_[zoneI][i].zz() = xxx;
}
D_[zoneI][i] = Zero;
D_[zoneI][i].xx() += pow(gamma_[zoneI][i].xx(), 1/3) * dXYZ_.value().x();
D_[zoneI][i].yy() += pow(gamma_[zoneI][i].yy(), 1/3) * dXYZ_.value().y();
D_[zoneI][i].zz() += pow(gamma_[zoneI][i].zz(), 1/3) * dXYZ_.value().z();
D_[zoneI][i] = coordSys_.R().transformTensor(D_[zoneI][i]);
// leading 0.5 is from 1/2*rho
F_[zoneI][i] = Zero;
F_[zoneI][i].xx() += 0.5 * fXYZ_.value().x();
F_[zoneI][i].yy() += 0.5 * fXYZ_.value().y();
F_[zoneI][i].zz() += 0.5 * fXYZ_.value().z();
F_[zoneI][i] = coordSys_.R().transformTensor(F_[zoneI][i]);
}