machWriter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  Copyright : (C) 2011 Symscape
3  Website : www.symscape.com
4 -------------------------------------------------------------------------------
5 License
6  This file is part of OpenFOAM.
7 
8  OpenFOAM is free software: you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16  for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
20 
21 \*---------------------------------------------------------------------------*/
22 
23 #include "machWriter.H"
24 #include "volFields.H"
25 #include "dictionary.H"
26 #include "Time.H"
27 #include "fluidThermo.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(machWriter, 0);
34  const word machWriter::FIELD_NAME("Ma");
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
42 {}
43 
44 
45 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 
48 {
49  const fvMesh& mesh = refCast<const fvMesh>(obr);
50  const Time& runTime = obr.time();
51 
52  volScalarField machNo
53  (
54  IOobject
55  (
56  FIELD_NAME,
57  runTime.timeName(),
58  mesh,
61  ),
62  mesh,
63  dimensionedScalar(FIELD_NAME, dimless, 0.0)
64  );
65 
66  const word UName("U");
67  const word TName("T");
68  const word thermoPhysicalName("thermophysicalProperties");
69  const word thermoName("thermodynamicProperties");
70 
71  if (obr.foundObject<volVectorField>(UName) &&
72  obr.foundObject<volScalarField>(TName))
73  {
74  const volVectorField& U = obr.lookupObject<volVectorField>(UName);
75 
76  if (obr.foundObject<fluidThermo>(thermoPhysicalName))
77  {
78  const fluidThermo& thermo =
79  obr.lookupObject<fluidThermo>(thermoPhysicalName);
80 
81  volScalarField Cp = thermo.Cp();
82  volScalarField Cv = thermo.Cv();
83 
84  machNo = mag(U)/(sqrt((Cp/Cv)*(Cp - Cv)*thermo.T()));
85  }
86  else if (obr.foundObject<dictionary>(thermoName))
87  {
88  const volScalarField& T = obr.lookupObject<volScalarField>(TName);
89  const dictionary& thermoProps =
90  obr.lookupObject<dictionary>(thermoName);
91 
92  dimensionedScalar R(thermoProps.lookup("R"));
93  dimensionedScalar Cv(thermoProps.lookup("Cv"));
94 
95  machNo = mag(U)/(sqrt(((Cv + R)/Cv)*R*T));
96  }
97  }
98 
99  machNo.write();
100 }
101 
102 
103 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::machWriter::FIELD_NAME
static const word FIELD_NAME
Field file name.
Definition: machWriter.H:54
fluidThermo.H
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:117
Foam::fluidThermo
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
U
U
Definition: pEqn.H:46
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
R
#define R(A, B, C, D, E, F, K, M)
machWriter.H
Foam::derivedFieldWriter
Basis for writers used in derivedFields e.g., wallShearStressWriter.
Definition: derivedFieldWriter.H:49
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::machWriter::write
virtual void write(const objectRegistry &obr)
Write derived field.
Definition: machWriter.C:47
Foam::objectRegistry::foundObject
bool foundObject(const word &name) const
Is the named Type found?
Definition: objectRegistryTemplates.C:142
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
dictionary.H
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::machWriter::machWriter
machWriter(const dictionary &dict)
Definition: machWriter.C:40