OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

Pe.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------* \
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     Pe
00027 
00028 Description
00029     Calculates and writes the Pe number as a surfaceScalarField obtained from
00030     field phi.
00031 
00032     The -noWrite option just outputs the max/min values without writing
00033     the field.
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #include "calc.H"
00038 #include "fvc.H"
00039 
00040 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
00041 #include "incompressible/RAS/RASModel/RASModel.H"
00042 #include "incompressible/LES/LESModel/LESModel.H"
00043 #include "basicPsiThermo.H"
00044 #include "compressible/RAS/RASModel/RASModel.H"
00045 #include "compressible/LES/LESModel/LESModel.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
00050 {
00051     bool writeResults = !args.optionFound("noWrite");
00052 
00053     IOobject phiHeader
00054     (
00055         "phi",
00056         runTime.timeName(),
00057         mesh,
00058         IOobject::MUST_READ
00059     );
00060 
00061     if (phiHeader.headerOk())
00062     {
00063         autoPtr<surfaceScalarField> PePtr;
00064 
00065         Info<< "    Reading phi" << endl;
00066         surfaceScalarField phi(phiHeader, mesh);
00067 
00068         volVectorField U
00069         (
00070             IOobject
00071             (
00072                 "U",
00073                 runTime.timeName(),
00074                 mesh,
00075                 IOobject::MUST_READ
00076             ),
00077             mesh
00078         );
00079 
00080         IOobject RASPropertiesHeader
00081         (
00082             "RASProperties",
00083             runTime.constant(),
00084             mesh,
00085             IOobject::MUST_READ,
00086             IOobject::NO_WRITE
00087         );
00088 
00089         IOobject LESPropertiesHeader
00090         (
00091             "LESProperties",
00092             runTime.constant(),
00093             mesh,
00094             IOobject::MUST_READ,
00095             IOobject::NO_WRITE
00096         );
00097 
00098         Info<< "    Calculating Pe" << endl;
00099 
00100         if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
00101         {
00102             if (RASPropertiesHeader.headerOk())
00103             {
00104                 IOdictionary RASProperties(RASPropertiesHeader);
00105 
00106                 singlePhaseTransportModel laminarTransport(U, phi);
00107 
00108                 autoPtr<incompressible::RASModel> RASModel
00109                 (
00110                     incompressible::RASModel::New
00111                     (
00112                         U,
00113                         phi,
00114                         laminarTransport
00115                     )
00116                 );
00117 
00118                 PePtr.set
00119                 (
00120                     new surfaceScalarField
00121                     (
00122                         IOobject
00123                         (
00124                             "Pe",
00125                             runTime.timeName(),
00126                             mesh,
00127                             IOobject::NO_READ
00128                         ),
00129                         mag(phi)
00130                        /(
00131                             mesh.magSf()
00132                           * mesh.surfaceInterpolation::deltaCoeffs()
00133                           * fvc::interpolate(RASModel->nuEff())
00134                          )
00135                     )
00136                 );
00137             }
00138             else if (LESPropertiesHeader.headerOk())
00139             {
00140                 IOdictionary LESProperties(LESPropertiesHeader);
00141 
00142                 singlePhaseTransportModel laminarTransport(U, phi);
00143 
00144                 autoPtr<incompressible::LESModel> sgsModel
00145                 (
00146                     incompressible::LESModel::New(U, phi, laminarTransport)
00147                 );
00148 
00149                 PePtr.set
00150                 (
00151                     new surfaceScalarField
00152                     (
00153                         IOobject
00154                         (
00155                             "Pe",
00156                             runTime.timeName(),
00157                             mesh,
00158                             IOobject::NO_READ
00159                         ),
00160                         mag(phi)
00161                        /(
00162                             mesh.magSf()
00163                           * mesh.surfaceInterpolation::deltaCoeffs()
00164                           * fvc::interpolate(sgsModel->nuEff())
00165                         )
00166                     )
00167                 );
00168             }
00169             else
00170             {
00171                 IOdictionary transportProperties
00172                 (
00173                     IOobject
00174                     (
00175                         "transportProperties",
00176                         runTime.constant(),
00177                         mesh,
00178                         IOobject::MUST_READ,
00179                         IOobject::NO_WRITE
00180                     )
00181                 );
00182 
00183                 dimensionedScalar nu(transportProperties.lookup("nu"));
00184 
00185                 PePtr.set
00186                 (
00187                     new surfaceScalarField
00188                     (
00189                         IOobject
00190                         (
00191                             "Pe",
00192                             runTime.timeName(),
00193                             mesh,
00194                             IOobject::NO_READ
00195                         ),
00196                         mesh.surfaceInterpolation::deltaCoeffs()
00197                       * (mag(phi)/mesh.magSf())*(runTime.deltaT()/nu)
00198                     )
00199                 );
00200             }
00201         }
00202         else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
00203         {
00204             if (RASPropertiesHeader.headerOk())
00205             {
00206                 IOdictionary RASProperties(RASPropertiesHeader);
00207 
00208                 autoPtr<basicPsiThermo> thermo(basicPsiThermo::New(mesh));
00209 
00210                 volScalarField rho
00211                 (
00212                     IOobject
00213                     (
00214                         "rho",
00215                         runTime.timeName(),
00216                         mesh
00217                     ),
00218                     thermo->rho()
00219                 );
00220 
00221                 autoPtr<compressible::RASModel> RASModel
00222                 (
00223                     compressible::RASModel::New
00224                     (
00225                         rho,
00226                         U,
00227                         phi,
00228                         thermo()
00229                     )
00230                 );
00231 
00232                 PePtr.set
00233                 (
00234                     new surfaceScalarField
00235                     (
00236                         IOobject
00237                         (
00238                             "Pe",
00239                             runTime.timeName(),
00240                             mesh,
00241                             IOobject::NO_READ
00242                         ),
00243                         mag(phi)
00244                        /(
00245                             mesh.magSf()
00246                           * mesh.surfaceInterpolation::deltaCoeffs()
00247                           * fvc::interpolate(RASModel->muEff())
00248                         )
00249                     )
00250                 );
00251             }
00252             else if (LESPropertiesHeader.headerOk())
00253             {
00254                 IOdictionary LESProperties(LESPropertiesHeader);
00255 
00256                 autoPtr<basicPsiThermo> thermo(basicPsiThermo::New(mesh));
00257 
00258                 volScalarField rho
00259                 (
00260                     IOobject
00261                     (
00262                         "rho",
00263                         runTime.timeName(),
00264                         mesh
00265                     ),
00266                     thermo->rho()
00267                 );
00268 
00269                 autoPtr<compressible::LESModel> sgsModel
00270                 (
00271                     compressible::LESModel::New(rho, U, phi, thermo())
00272                 );
00273 
00274                 PePtr.set
00275                 (
00276                     new surfaceScalarField
00277                     (
00278                         IOobject
00279                         (
00280                             "Pe",
00281                             runTime.timeName(),
00282                             mesh,
00283                             IOobject::NO_READ
00284                         ),
00285                         mag(phi)
00286                        /(
00287                             mesh.magSf()
00288                           * mesh.surfaceInterpolation::deltaCoeffs()
00289                           * fvc::interpolate(sgsModel->muEff())
00290                         )
00291                     )
00292                 );
00293             }
00294             else
00295             {
00296                 IOdictionary transportProperties
00297                 (
00298                     IOobject
00299                     (
00300                         "transportProperties",
00301                         runTime.constant(),
00302                         mesh,
00303                         IOobject::MUST_READ,
00304                         IOobject::NO_WRITE
00305                     )
00306                 );
00307 
00308                 dimensionedScalar mu(transportProperties.lookup("mu"));
00309 
00310                 PePtr.set
00311                 (
00312                     new surfaceScalarField
00313                     (
00314                         IOobject
00315                         (
00316                             "Pe",
00317                             runTime.timeName(),
00318                             mesh,
00319                             IOobject::NO_READ
00320                         ),
00321                         mesh.surfaceInterpolation::deltaCoeffs()
00322                       * (mag(phi)/(mesh.magSf()))*(runTime.deltaT()/mu)
00323                     )
00324                 );
00325             }
00326         }
00327         else
00328         {
00329             FatalErrorIn(args.executable())
00330                 << "Incorrect dimensions of phi: " << phi.dimensions()
00331                     << abort(FatalError);
00332         }
00333 
00334 
00335         // can also check how many cells exceed a particular Pe limit
00336         /*
00337         {
00338             label count = 0;
00339             label PeLimit = 200;
00340             forAll(PePtr(), i)
00341             {
00342                 if (PePtr()[i] > PeLimit)
00343                 {
00344                     count++;
00345                 }
00346 
00347             }
00348 
00349             Info<< "Fraction > " << PeLimit << " = "
00350                 << scalar(count)/Pe.size() << endl;
00351         }
00352         */
00353 
00354         Info << "Pe max : " << max(PePtr()).value() << endl;
00355 
00356         if (writeResults)
00357         {
00358             PePtr().write();
00359         }
00360     }
00361     else
00362     {
00363         Info<< "    No phi" << endl;
00364     }
00365 
00366     Info<< "\nEnd\n" << endl;
00367 }
00368 
00369 
00370 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd