Co.C
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 #include "calc.H"
00038 #include "fvc.H"
00039
00040
00041
00042 namespace Foam
00043 {
00044 tmp<volScalarField> Co(const surfaceScalarField& Cof)
00045 {
00046 const fvMesh& mesh = Cof.mesh();
00047
00048 tmp<volScalarField> tCo
00049 (
00050 new volScalarField
00051 (
00052 IOobject
00053 (
00054 "Co",
00055 mesh.time().timeName(),
00056 mesh
00057 ),
00058 mesh,
00059 dimensionedScalar("0", Cof.dimensions(), 0)
00060 )
00061 );
00062
00063 volScalarField& Co = tCo();
00064
00065
00066 const unallocLabelList& owner = mesh.owner();
00067 const unallocLabelList& neighbour = mesh.neighbour();
00068
00069 forAll(owner, facei)
00070 {
00071 label own = owner[facei];
00072 label nei = neighbour[facei];
00073
00074 Co[own] = max(Co[own], Cof[facei]);
00075 Co[nei] = max(Co[nei], Cof[facei]);
00076 }
00077
00078 forAll(Co.boundaryField(), patchi)
00079 {
00080 Co.boundaryField()[patchi] = Cof.boundaryField()[patchi];
00081 }
00082
00083 return tCo;
00084 }
00085 }
00086
00087
00088 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
00089 {
00090 bool writeResults = !args.optionFound("noWrite");
00091
00092 IOobject phiHeader
00093 (
00094 "phi",
00095 runTime.timeName(),
00096 mesh,
00097 IOobject::MUST_READ
00098 );
00099
00100 if (phiHeader.headerOk())
00101 {
00102 autoPtr<surfaceScalarField> CoPtr;
00103
00104 Info<< " Reading phi" << endl;
00105 surfaceScalarField phi(phiHeader, mesh);
00106 Info<< " Calculating Co" << endl;
00107
00108 if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
00109 {
00110
00111 volScalarField rho
00112 (
00113 IOobject
00114 (
00115 "rho",
00116 runTime.timeName(),
00117 mesh,
00118 IOobject::MUST_READ
00119 ),
00120 mesh
00121 );
00122
00123 CoPtr.set
00124 (
00125 new surfaceScalarField
00126 (
00127 IOobject
00128 (
00129 "Cof",
00130 runTime.timeName(),
00131 mesh,
00132 IOobject::NO_READ
00133 ),
00134 (
00135 mesh.surfaceInterpolation::deltaCoeffs()
00136 * (mag(phi)/(fvc::interpolate(rho)*mesh.magSf()))
00137 * runTime.deltaT()
00138 )
00139 )
00140 );
00141 }
00142 else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
00143 {
00144
00145 CoPtr.set
00146 (
00147 new surfaceScalarField
00148 (
00149 IOobject
00150 (
00151 "Cof",
00152 runTime.timeName(),
00153 mesh,
00154 IOobject::NO_READ
00155 ),
00156 (
00157 mesh.surfaceInterpolation::deltaCoeffs()
00158 * (mag(phi)/mesh.magSf())
00159 * runTime.deltaT()
00160 )
00161 )
00162 );
00163 }
00164 else
00165 {
00166 FatalErrorIn(args.executable())
00167 << "Incorrect dimensions of phi: " << phi.dimensions()
00168 << abort(FatalError);
00169 }
00170
00171 Info<< "Co max : " << max(CoPtr()).value() << endl;
00172
00173 if (writeResults)
00174 {
00175 CoPtr().write();
00176 Co(CoPtr())().write();
00177 }
00178 }
00179 else
00180 {
00181 Info<< " No phi" << endl;
00182 }
00183
00184 Info<< "\nEnd\n" << endl;
00185 }
00186
00187
Copyright © 2000-2009 OpenCFD Ltd