1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Calculates and optionally writes the local Mach number from the velocity
31 The -nowrite option just outputs the max value without writing the field.
33 \*---------------------------------------------------------------------------*/
36 #include "basicPsiThermo.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
41 bool writeResults = !args.optionFound("noWrite");
59 // Check U and T exists
60 if (Uheader.headerOk() && Theader.headerOk())
62 autoPtr<volScalarField> MachPtr;
64 volVectorField U(Uheader, mesh);
70 "thermophysicalProperties",
76 // thermophysical Mach
77 autoPtr<basicPsiThermo> thermo
79 basicPsiThermo::New(mesh)
82 volScalarField Cp(thermo->Cp());
83 volScalarField Cv(thermo->Cv());
95 mag(U)/(sqrt((Cp/Cv)*(Cp - Cv)*thermo->T()))
101 // thermodynamic Mach
102 IOdictionary thermoProps
106 "thermodynamicProperties",
109 IOobject::MUST_READ_IF_MODIFIED,
114 dimensionedScalar R(thermoProps.lookup("R"));
115 dimensionedScalar Cv(thermoProps.lookup("Cv"));
117 volScalarField T(Theader, mesh);
129 mag(U)/(sqrt(((Cv + R)/Cv)*R*T))
134 Info<< "Mach max : " << max(MachPtr()).value() << endl;
143 Info<< " Missing U or T" << endl;
146 Info<< "\nEnd\n" << endl;
150 // ************************************************************************* //