Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #include <finiteVolume/fvCFD.H>
00070 #include <OpenFOAM/cyclicPolyPatch.H>
00071
00072
00073
00074
00075 int main(int argc, char *argv[])
00076 {
00077 # include <OpenFOAM/addRegionOption.H>
00078 timeSelector::addOptions();
00079 argList::validArgs.append("fieldName");
00080 argList::validArgs.append("patchName");
00081 # include <OpenFOAM/setRootCase.H>
00082 # include <OpenFOAM/createTime.H>
00083 instantList timeDirs = timeSelector::select0(runTime, args);
00084 # include <OpenFOAM/createNamedMesh.H>
00085
00086 word fieldName(args.additionalArgs()[0]);
00087 word patchName(args.additionalArgs()[1]);
00088
00089 forAll(timeDirs, timeI)
00090 {
00091 runTime.setTime(timeDirs[timeI], timeI);
00092 Info<< "Time = " << runTime.timeName() << endl;
00093
00094 IOobject fieldHeader
00095 (
00096 fieldName,
00097 runTime.timeName(),
00098 mesh,
00099 IOobject::MUST_READ
00100 );
00101
00102
00103 if (fieldHeader.headerOk())
00104 {
00105 mesh.readUpdate();
00106
00107 label patchi = mesh.boundaryMesh().findPatchID(patchName);
00108 if (patchi < 0)
00109 {
00110 FatalError
00111 << "Unable to find patch " << patchName << nl
00112 << exit(FatalError);
00113 }
00114
00115
00116 if (isA<cyclicPolyPatch>(mesh.boundaryMesh()[patchi]))
00117 {
00118 Info<< " Cyclic patch vector area: " << nl;
00119 label nFaces = mesh.boundaryMesh()[patchi].size();
00120 vector sum1 = vector::zero;
00121 vector sum2 = vector::zero;
00122 for (label i=0; i<nFaces/2; i++)
00123 {
00124 sum1 += mesh.Sf().boundaryField()[patchi][i];
00125 sum2 += mesh.Sf().boundaryField()[patchi][i+nFaces/2];
00126 }
00127 reduce(sum1, sumOp<vector>());
00128 reduce(sum2, sumOp<vector>());
00129 Info<< " - half 1 = " << sum1 << ", " << mag(sum1) << nl
00130 << " - half 2 = " << sum2 << ", " << mag(sum2) << nl
00131 << " - total = " << (sum1 + sum2) << ", "
00132 << mag(sum1 + sum2) << endl;
00133 Info<< " Cyclic patch area magnitude = "
00134 << gSum(mesh.magSf().boundaryField()[patchi])/2.0 << endl;
00135 }
00136 else
00137 {
00138 Info<< " Area vector of patch "
00139 << patchName << '[' << patchi << ']' << " = "
00140 << gSum(mesh.Sf().boundaryField()[patchi]) << endl;
00141 Info<< " Area magnitude of patch "
00142 << patchName << '[' << patchi << ']' << " = "
00143 << gSum(mesh.magSf().boundaryField()[patchi]) << endl;
00144 }
00145
00146
00147 if (fieldHeader.headerClassName() == volScalarField::typeName)
00148 {
00149 Info<< " Reading " << volScalarField::typeName << " "
00150 << fieldName << endl;
00151
00152 volScalarField field(fieldHeader, mesh);
00153
00154 Info<< " Integral of " << fieldName
00155 << " over vector area of patch "
00156 << patchName << '[' << patchi << ']' << " = "
00157 << gSum
00158 (
00159 mesh.Sf().boundaryField()[patchi]
00160 *field.boundaryField()[patchi]
00161 )
00162 << nl;
00163
00164 Info<< " Integral of " << fieldName
00165 << " over area magnitude of patch "
00166 << patchName << '[' << patchi << ']' << " = "
00167 << gSum
00168 (
00169 mesh.magSf().boundaryField()[patchi]
00170 *field.boundaryField()[patchi]
00171 )
00172 << nl;
00173 }
00174 else if
00175 (
00176 fieldHeader.headerClassName() == surfaceScalarField::typeName
00177 )
00178 {
00179 Info<< " Reading " << surfaceScalarField::typeName << " "
00180 << fieldName << endl;
00181
00182 surfaceScalarField field(fieldHeader, mesh);
00183 scalar sumField = gSum(field.boundaryField()[patchi]);
00184
00185 Info<< " Integral of " << fieldName << " over patch "
00186 << patchName << '[' << patchi << ']' << " = "
00187 << sumField << nl;
00188 }
00189 else
00190 {
00191 FatalError
00192 << "Only possible to integrate "
00193 << volScalarField::typeName << "s "
00194 << "and " << surfaceScalarField::typeName << "s"
00195 << nl << exit(FatalError);
00196 }
00197 }
00198 else
00199 {
00200 Info<< " No field " << fieldName << endl;
00201 }
00202
00203 Info<< endl;
00204 }
00205
00206 Info<< "End\n" << endl;
00207
00208 return 0;
00209 }
00210
00211
00212