@Mina-Lee 在 precice tourorials中的受力问题 中说:
@RolandLent precice中没有计算OF力的能力,力都是在OF里计算的。OF中的力也是通过force函数计算的。
pecice只干三件事:
1、引用of中的力变量,提取流固耦合交界面的力变量;引用位移变量。2、precice内部运算。3、覆盖引用的位移变量。
我阅读了第一位回答者的源代码,力的计算是precice的of适配器实现的,我在适配器的forcebase类里边找到了计算力的方法,这里附上计算压力和黏性力的部分
if (solverType_.compare("incompressible") == 0)
{
forceField.boundaryFieldRef()[patchID] =
surface * pb[patchID] * rhob[patchID];
}
else if (solverType_.compare("compressible") == 0)
{
forceField.boundaryFieldRef()[patchID] =
surface * pb[patchID];
}
forceField.boundaryFieldRef()[patchID] +=
surface & devRhoReffb[patchID];
如果是用of的solid求解器就是向您这样的执行方式了
// Check if a force field with the requested name exists.
// If yes (e.g., solids4Foam), bind Force_ to that field.
// If not (e.g., pimpleFoam without the Forces function object), create it.
if (mesh_.foundObject<volVectorField>(nameForce))
{
Force_ =
&const_cast<volVectorField&>(
mesh_.lookupObject<volVectorField>(nameForce));
}
else
{
ForceOwning_.reset(new volVectorField(
IOobject(
nameForce,
mesh_.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE),
mesh,
dimensionedVector(
"fdim",
dimensionSet(1, 1, -2, 0, 0, 0, 0),
Foam::vector::zero)));
Force_ = ForceOwning_.get();
}