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/solidMechanics/elasticIncrSolidFoam/writeForceDisplacement.H

50 lines
1.4 KiB
C
Raw Normal View History

2012-09-11 15:42:55 +00:00
//- write force displacement to file
label leftPatchID = mesh.boundaryMesh().findPatchID("leftClamp");
if(leftPatchID == -1)
{
2012-09-11 15:42:55 +00:00
FatalError << "Cannot find patch left for calculating force" << endl;
}
2012-09-11 15:42:55 +00:00
//- calculate force in x direction on leftClamp patch
scalar leftForce = gSum
(
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(
// 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)
{
2012-09-11 15:42:55 +00:00
gaugeU1 = U.boundaryField()[gaugeFacePatchID1][gaugeFaceID1];
}
2012-09-11 15:42:55 +00:00
if(gaugeFaceID2 != -1)
{
2012-09-11 15:42:55 +00:00
gaugeU2 = U.boundaryField()[gaugeFacePatchID2][gaugeFaceID2];
}
2012-09-11 15:42:55 +00:00
//- reduce across procs
reduce(gaugeU1, sumOp<vector>());
reduce(gaugeU2, sumOp<vector>());
Pout << "gaugeU1 is " << gaugeU1 << nl
<< "gaugeU2 is " << gaugeU2 << endl;
2012-09-11 15:42:55 +00:00
scalar gaugeDisp = mag(gaugeU1 - gaugeU2);
//- write to file
if(Pstream::master())
{
2012-09-11 15:42:55 +00:00
OFstream& forceDispFile = *filePtr;
forceDispFile << 1000*gaugeDisp << "\t" << -1*leftForce << endl;
}