16 #include "timeSelector.H"
17 #include "TimePaths.H"
21 #include "simpleControl.H"
22 #include "fvOptions.H"
23 #include "singlePhaseTransportModel.H"
31 Info <<
"Computing forces...." << endl;
36 "List of patch names to compute");
41 "Time instance to compute, if not provided runs all times");
46 "Freestream density");
48 #include "setRootCase.H"
49 #include "createTime.H"
51 if (!
args.optionFound(
"time"))
53 Info <<
"Time not set, running all times." << endl;
57 autoPtr<TimePaths> timePaths;
58 timePaths = autoPtr<TimePaths>::New(
args.rootPath(),
args.caseName());
60 const instantList timeDirs(timeSelector::select(timePaths->times(),
args));
62 List<wordRe> patchNames;
63 if (
args.optionFound(
"patchNames"))
65 patchNames = wordReList(
args.optionLookup(
"patchNames")());
69 Info <<
"patchNames not set! Exit." << endl;
74 if (
args.optionFound(
"rho"))
76 rho = readScalar(
args.optionLookup(
"rho")());
80 Info <<
"Density not set! Defaulting to 1.0." << endl;
85 runTime.setTime(timeDirs[iTime].value(), 0);
87 #include "createMesh.H"
91 volVectorField forcePerS(
99 dimensionedVector(
"forcePerS", dimensionSet(1, -1, -2, 0, 0, 0, 0), vector::zero),
100 fixedValueFvPatchScalarField::typeName);
105 vector forces(vector::zero);
107 const surfaceVectorField::Boundary& Sfb =
mesh.Sf().boundaryField();
108 const surfaceScalarField::Boundary& magSfb =
mesh.magSf().boundaryField();
110 volSymmTensorField devRhoReff(
112 IOobject::groupName(
"devRhoReff",
U.group()),
113 mesh.time().timeName(),
117 -nuEff * dev(twoSymm(fvc::grad(
U))));
119 const volSymmTensorField::Boundary& devRhoReffb = devRhoReff.boundaryField();
121 vector totalForce(vector::zero);
125 label patchI =
mesh.boundaryMesh().findPatchID(patchNames[cI]);
128 Info <<
"ERROR: Patch name " << patchNames[cI] <<
" not found in constant/polyMesh/boundary! Exit!" << endl;
132 const fvPatch& patch =
mesh.boundary()[patchI];
134 vectorField fN(Sfb[patchI] *
p.boundaryField()[patchI] *
rho);
136 vectorField fT(Sfb[patchI] & devRhoReffb[patchI] *
rho);
141 forces.x() = fN[faceI].x() + fT[faceI].x();
142 forces.y() = fN[faceI].y() + fT[faceI].y();
143 forces.z() = fN[faceI].z() + fT[faceI].z();
146 forcePerS.boundaryFieldRef()[patchI][faceI] = forces / magSfb[patchI][faceI];
148 totalForce.x() += forces.x();
149 totalForce.y() += forces.y();
150 totalForce.z() += forces.z();
155 Info <<
"Total force: " << totalForce << endl;
157 Info <<
"Computing forces.... Completed!" << endl;