16 #include "timeSelector.H"
17 #include "TimePaths.H"
21 #include "simpleControl.H"
22 #include "fvOptions.H"
23 #include "fluidThermo.H"
31 Info <<
"Computing forces...." << endl;
36 "List of patch names to compute");
41 "Time instance to compute, if not provided runs all times");
43 #include "setRootCase.H"
44 #include "createTime.H"
46 if (!
args.optionFound(
"time"))
48 Info <<
"Time not set, running all times." << endl;
52 autoPtr<TimePaths> timePaths;
53 timePaths = autoPtr<TimePaths>::New(
args.rootPath(),
args.caseName());
55 const instantList timeDirs(timeSelector::select(timePaths->times(),
args));
57 List<wordRe> patchNames;
58 if (
args.optionFound(
"patchNames"))
60 patchNames = wordReList(
args.optionLookup(
"patchNames")());
64 Info <<
"patchNames not set! Exit." << endl;
70 runTime.setTime(timeDirs[iTime].value(), 0);
72 #include "createMesh.H"
76 volVectorField forcePerS(
84 dimensionedVector(
"forcePerS", dimensionSet(1, -1, -2, 0, 0, 0, 0), vector::zero),
85 fixedValueFvPatchScalarField::typeName);
90 vector forces(vector::zero);
92 const surfaceVectorField::Boundary& Sfb =
mesh.Sf().boundaryField();
93 const surfaceScalarField::Boundary& magSfb =
mesh.magSf().boundaryField();
95 volSymmTensorField devRhoReff(
97 IOobject::groupName(
"devRhoReff",
U.group()),
98 mesh.time().timeName(),
102 (-
rho * nuEff) * dev(twoSymm(fvc::grad(
U))));
104 const volSymmTensorField::Boundary& devRhoReffb = devRhoReff.boundaryField();
106 vector totalForce(vector::zero);
110 label patchI =
mesh.boundaryMesh().findPatchID(patchNames[cI]);
113 Info <<
"ERROR: Patch name " << patchNames[cI] <<
" not found in constant/polyMesh/boundary! Exit!" << endl;
117 const fvPatch& patch =
mesh.boundary()[patchI];
119 vectorField fN(Sfb[patchI] *
p.boundaryField()[patchI]);
121 vectorField fT(Sfb[patchI] & devRhoReffb[patchI]);
126 forces.x() = fN[faceI].x() + fT[faceI].x();
127 forces.y() = fN[faceI].y() + fT[faceI].y();
128 forces.z() = fN[faceI].z() + fT[faceI].z();
131 forcePerS.boundaryFieldRef()[patchI][faceI] = forces / magSfb[patchI][faceI];
133 totalForce.x() += forces.x();
134 totalForce.y() += forces.y();
135 totalForce.z() += forces.z();
140 Info <<
"Total force: " << totalForce << endl;
142 Info <<
"Computing forces.... Completed!" << endl;