This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/applications/solvers/surfaceTracking/bubbleInterTrackFoam/include/writeForces.H

69 lines
1.7 KiB
C
Raw Normal View History

if(Pstream::master())
{
// const scalarField& magSf =
// mesh.magSf().boundaryField()[interface.aPatchID()];
// vectorField n =
// mesh.Sf().boundaryField()[interface.aPatchID()]/magSf;
// const scalarField& P = p.boundaryField()[interface.aPatchID()];
// vectorField pressureForces = magSf*P*n;
// vectorField snGradU =
// U.boundaryField()[interface.aPatchID()].snGrad();
// vectorField viscousForces =
// - interface.muFluidA().value()*magSf*
// (
// snGradU
// + ((n*n)&snGradU)
// + (fac::grad(interface.Us())&interface.aMesh().faceAreaNormals())
// ().internalField()
// );
vector totalPressureForce = -interface.totalPressureForce();
vector totalViscousForce = -interface.totalViscousForce();
vector totalForce = totalPressureForce + totalViscousForce;
vector dragDir;
scalar Uref;
if(mag(UF.value()) > SMALL)
{
dragDir = - UF.value()/mag(UF.value());
Uref = mag(UF.value());
}
else
{
dragDir = interface.g().value()/mag(interface.g().value());
Uref = SMALL;
}
scalar Aref =
sum
(
(dragDir&mesh.Sf().boundaryField()[interface.aPatchID()])*
pos(dragDir&mesh.Sf().boundaryField()[interface.aPatchID()])
);
scalar drag =
(dragDir&totalForce)/
(0.5*interface.rhoFluidA().value()*sqr(Uref)*Aref);
scalar lift =
mag((I - dragDir*dragDir)&totalForce)/
(0.5*interface.rhoFluidA().value()*sqr(Uref)*Aref);
forcesFile << runTime.value() << tab;
forcesFile << drag << tab << lift << endl;
}