FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

Mach.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     Mach
00026 
00027 Description
00028     Calculates and optionally writes the local Mach number from the velocity
00029     field U at each time.
00030 
00031     The -nowrite option just outputs the max value without writing the field.
00032 
00033 Usage
00034 
00035     - Mach [OPTIONS]
00036 
00037     @param -noWrite \n
00038     Suppress output to files.
00039 
00040     @param -dict <dictionary name>\n
00041     Use named dictionary instead of system/controlDict.
00042 
00043     @param -noZero \n
00044     Ignore timestep 0.
00045 
00046     @param -constant \n
00047     Include the constant directory.
00048 
00049     @param -time <time>\n
00050     Apply only to specific time.
00051 
00052     @param -latestTime \n
00053     Only apply to latest time step.
00054 
00055     @param -case <dir>\n
00056     Case directory.
00057 
00058     @param -parallel \n
00059     Run in parallel.
00060 
00061     @param -help \n
00062     Display help message.
00063 
00064     @param -doc \n
00065     Display Doxygen API documentation page for this application.
00066 
00067     @param -srcDoc \n
00068     Display Doxygen source documentation page for this application.
00069 
00070 \*---------------------------------------------------------------------------*/
00071 
00072 #include <postCalc/calc.H>
00073 #include <basicThermophysicalModels/basicPsiThermo.H>
00074 
00075 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00076 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
00077 {
00078     bool writeResults = !args.optionFound("noWrite");
00079 
00080     IOobject Uheader
00081     (
00082         "U",
00083         runTime.timeName(),
00084         mesh,
00085         IOobject::MUST_READ
00086     );
00087 
00088     IOobject Theader
00089     (
00090         "T",
00091         runTime.timeName(),
00092         mesh,
00093         IOobject::MUST_READ
00094     );
00095 
00096     // Check U and T exists
00097     if (Uheader.headerOk() && Theader.headerOk())
00098     {
00099         autoPtr<volScalarField> MachPtr;
00100 
00101         volVectorField U(Uheader, mesh);
00102 
00103         if
00104         (
00105             IOobject
00106             (
00107                 "thermophysicalProperties",
00108                 runTime.constant(),
00109                 mesh
00110             ).headerOk()
00111         )
00112         {
00113             // thermophysical Mach
00114             autoPtr<basicPsiThermo> thermo
00115             (
00116                 basicPsiThermo::New(mesh)
00117             );
00118 
00119             volScalarField Cp = thermo->Cp();
00120             volScalarField Cv = thermo->Cv();
00121 
00122             MachPtr.set
00123             (
00124                 new volScalarField
00125                 (
00126                     IOobject
00127                     (
00128                         "Ma",
00129                         runTime.timeName(),
00130                         mesh
00131                     ),
00132                     mag(U)/(sqrt((Cp/Cv)*(Cp - Cv)*thermo->T()))
00133                 )
00134             );
00135         }
00136         else
00137         {
00138             // thermodynamic Mach
00139             IOdictionary thermoProps
00140             (
00141                 IOobject
00142                 (
00143                     "thermodynamicProperties",
00144                     runTime.constant(),
00145                     mesh,
00146                     IOobject::MUST_READ,
00147                     IOobject::NO_WRITE
00148                 )
00149             );
00150 
00151             dimensionedScalar R(thermoProps.lookup("R"));
00152             dimensionedScalar Cv(thermoProps.lookup("Cv"));
00153 
00154             volScalarField T(Theader, mesh);
00155 
00156             MachPtr.set
00157             (
00158                 new volScalarField
00159                 (
00160                     IOobject
00161                     (
00162                         "Ma",
00163                         runTime.timeName(),
00164                         mesh
00165                     ),
00166                     mag(U)/(sqrt(((Cv + R)/Cv)*R*T))
00167                 )
00168             );
00169         }
00170 
00171         Info<< "Mach max : " << max(MachPtr()).value() << endl;
00172 
00173         if (writeResults)
00174         {
00175             MachPtr().write();
00176         }
00177     }
00178     else
00179     {
00180         Info<< "    Missing U or T" << endl;
00181     }
00182 
00183     Info<< "\nEnd\n" << endl;
00184 }
00185 
00186 
00187 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines