2012-09-11 15:42:55 +00:00
|
|
|
//- write force displacement to file
|
|
|
|
|
|
|
|
label leftPatchID = mesh.boundaryMesh().findPatchID("leftClamp");
|
|
|
|
if(leftPatchID == -1)
|
2013-10-11 13:31:14 +00:00
|
|
|
{
|
2012-09-11 15:42:55 +00:00
|
|
|
FatalError << "Cannot find patch left for calculating force" << endl;
|
2013-10-11 13:31:14 +00:00
|
|
|
}
|
2012-09-11 15:42:55 +00:00
|
|
|
|
|
|
|
//- calculate force in x direction on leftClamp patch
|
2013-10-11 13:31:14 +00:00
|
|
|
scalar leftForce = gSum(
|
2015-05-17 15:11:30 +00:00
|
|
|
vector(1, 0, 0) &
|
|
|
|
(mesh.boundary()[leftPatchID].Sf() & sigma.boundaryField()[leftPatchID])
|
|
|
|
);
|
2012-09-11 15:42:55 +00:00
|
|
|
|
|
|
|
//- patchIntegrate utility integrates it this way but this is worng because the sigma tensor should
|
|
|
|
//- be dotted with the surface normal to give the actual traction/force
|
|
|
|
//- you cannot just take the component of the sigma tensor
|
|
|
|
//scalar leftForcePatchIntegrateMethod = gSum(
|
2015-05-17 15:11:30 +00:00
|
|
|
// mesh.magSf().boundaryField()[leftPatchID]
|
|
|
|
// *sigma.boundaryField()[leftPatchID].component(symmTensor::XY)
|
|
|
|
// );
|
2012-09-11 15:42:55 +00:00
|
|
|
|
|
|
|
vector gaugeU1 = vector::zero;
|
|
|
|
vector gaugeU2 = vector::zero;
|
|
|
|
if(gaugeFaceID1 != -1)
|
2013-10-11 13:31:14 +00:00
|
|
|
{
|
2012-09-11 15:42:55 +00:00
|
|
|
gaugeU1 = U.boundaryField()[gaugeFacePatchID1][gaugeFaceID1];
|
2013-10-11 13:31:14 +00:00
|
|
|
}
|
2012-09-11 15:42:55 +00:00
|
|
|
if(gaugeFaceID2 != -1)
|
2013-10-11 13:31:14 +00:00
|
|
|
{
|
2012-09-11 15:42:55 +00:00
|
|
|
gaugeU2 = U.boundaryField()[gaugeFacePatchID2][gaugeFaceID2];
|
2013-10-11 13:31:14 +00:00
|
|
|
}
|
2012-09-11 15:42:55 +00:00
|
|
|
|
|
|
|
//- reduce across procs
|
|
|
|
reduce(gaugeU1, sumOp<vector>());
|
|
|
|
reduce(gaugeU2, sumOp<vector>());
|
|
|
|
|
|
|
|
Pout << "gaugeU1 is " << gaugeU1 << nl
|
2013-10-11 13:31:14 +00:00
|
|
|
<< "gaugeU2 is " << gaugeU2 << endl;
|
2012-09-11 15:42:55 +00:00
|
|
|
|
|
|
|
scalar gaugeDisp = mag(gaugeU1 - gaugeU2);
|
|
|
|
|
|
|
|
//- write to file
|
|
|
|
if(Pstream::master())
|
2013-10-11 13:31:14 +00:00
|
|
|
{
|
2012-09-11 15:42:55 +00:00
|
|
|
OFstream& forceDispFile = *filePtr;
|
|
|
|
forceDispFile << 1000*gaugeDisp << "\t" << -1*leftForce << endl;
|
2013-10-11 13:31:14 +00:00
|
|
|
}
|