Contrib/swak4Foam/Example sectionalForces

From OpenFOAMWiki

To calculate the forces on selected parts of a patch, insert the following into the "functions" section in controlDict file,

 
forcesSectional
{	
	type patchExpression;
	outputControl timeStep;
	enabled true;
	outputInterval 10;
	patches (
		cylinder      // change to your name or names of patch
	);
 
	variables (
	"position=0;"         
	"rho=1000;"
	"nu=1.0E-06;"
	"pressure_force= p*rho*normal()*area();"
	"viscous_force= -rho*nu*snGrad(U)*area();"
	"forces= pressure_force+viscous_force;"
	);
 
  expression "( pos().z > position-3 && pos().z < position+3) ? forces : vector(0,0,0)";
  accumulations ( sum );
}

That would sum up the force for all faces which are within the range of -3<z<3 on patch "cylinder".