1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Calculates the total forces on a patch:
29 total force in each direction (x, y and z)
34 \*---------------------------------------------------------------------------*/
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42 # include "setRootCase.H"
44 # include "createTime.H"
46 # include "createMesh.H"
50 Info<< "Time: " << runTime.timeName() << nl << endl;
52 volSymmTensorField sigma
67 vector netForce = vector::zero;
69 forAll(mesh.boundary(), patchID)
71 vectorField n = mesh.boundary()[patchID].nf();
72 const vectorField& Sf = mesh.boundary()[patchID].Sf();
73 const symmTensorField& sigmaPatch = sigma.boundaryField()[patchID];
75 vector totalForce = sum(Sf & sigmaPatch);
76 netForce += totalForce;
77 scalar totalNormalForce = sum(n & (Sf & sigmaPatch));
78 vector totalShearForce = sum((I -sqr(n)) & (Sf & sigmaPatch));
80 Info << "Patch: " << mesh.boundary()[patchID].name() << nl
81 << "\tTotal Force:\t\t" << totalForce << " N\n"
82 << "\tTotal Normal Force:\t" << totalNormalForce << " N\n"
83 << "\tTotal Shear Force:\t" << totalShearForce << " N\n" << endl;
86 Info << nl << "Net force on model is " << netForce << " N" << endl;
90 Info << nl << "End" << endl;
96 // ************************************************************************* //