All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
readInitialConditions.H
Go to the documentation of this file.
1  const word constProp(initialConditions.lookup("constantProperty"));
2  if
3  (
4  (constProp != "pressure")
5  && (constProp != "volume")
6  && (constProp != "temperature")
7  )
8  {
10  << "in initialConditions, unknown constantProperty type "
11  << constProp << nl
12  << " Valid types are: pressure volume temperature."
13  << exit(FatalError);
14  }
15 
16  const word fractionBasis(initialConditions.lookup("fractionBasis"));
17  if ((fractionBasis != "mass") && (fractionBasis != "mole"))
18  {
19  FatalError << "in initialConditions, unknown fractionBasis type " << nl
20  << "Valid types are: mass or mole."
22  }
23 
24  const label nSpecie = Y.size();
25  const scalarList W(::W(thermo));
26 
27  scalarList Y0(nSpecie, 0.0);
28  scalarList X0(nSpecie, 0.0);
29 
30  dictionary fractions(initialConditions.subDict("fractions"));
31  if (fractionBasis == "mole")
32  {
33  forAll(Y, i)
34  {
35  const word& name = Y[i].name();
36  if (fractions.found(name))
37  {
38  X0[i] = readScalar(fractions.lookup(name));
39  }
40  }
41 
42  scalar mw = 0.0;
43  const scalar mTot = sum(X0);
44  forAll(Y, i)
45  {
46  X0[i] /= mTot;
47  mw += W[i]*X0[i];
48  }
49 
50  forAll(Y, i)
51  {
52  Y0[i] = X0[i]*W[i]/mw;
53  }
54  }
55  else // mass fraction
56  {
57  forAll(Y, i)
58  {
59  const word& name = Y[i].name();
60  if (fractions.found(name))
61  {
62  Y0[i] = readScalar(fractions.lookup(name));
63  }
64  }
65 
66  scalar invW = 0.0;
67  const scalar mTot = sum(Y0);
68  forAll(Y, i)
69  {
70  Y0[i] /= mTot;
71  invW += Y0[i]/W[i];
72  }
73  const scalar mw = 1.0/invW;
74 
75  forAll(Y, i)
76  {
77  X0[i] = Y0[i]*mw/W[i];
78  }
79  }
80 
81  const scalar h0 = ::h0(thermo, Y0, p[0], T0);
82 
83  forAll(Y, i)
84  {
85  Y[i] = Y0[i];
86  }
87 
89  thermo.correct();
90 
91  rho = thermo.rho();
92  scalar rho0 = rho[0];
93  scalar u0 = h0 - p0/rho0;
94  scalar R0 = p0/(rho0*T0);
95  Rspecific[0] = R0;
96 
97  scalar integratedHeat = 0.0;
98 
99  Info << constProp << " will be held constant." << nl
100  << " p = " << p[0] << " [Pa]" << nl
101  << " T = " << thermo.T()[0] << " [K] " << nl
102  << " rho = " << rho[0] << " [kg/m^3]" << nl
103  << endl;
#define readScalar
Definition: doubleScalar.C:38
forAll(Y, i)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const scalar mTot
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
scalar rho0
rhoReactionThermo & thermo
Definition: createFields.H:28
const scalar mw
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
scalarList Y0(nSpecie, 0.0)
scalarList X0(nSpecie, 0.0)
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
static const char nl
Definition: Ostream.H:265
const word constProp(initialConditions.lookup("constantProperty"))
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const dimensionSet dimEnergy
const word fractionBasis(initialConditions.lookup("fractionBasis"))
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const scalarList W(::W(thermo))
PtrList< volScalarField > & Y
scalar R0
messageStream Info
dictionary fractions(initialConditions.subDict("fractions"))
Rspecific[0]
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
volScalarField & p
const scalar h0