forked from ZhangYanTJU/reactingCanteraFoam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateFieldRefs.H
More file actions
142 lines (132 loc) · 3.07 KB
/
Copy pathcreateFieldRefs.H
File metadata and controls
142 lines (132 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
const volScalarField& psi = thermo.psi();
volScalarField& T = thermo.T();
const label inertIndex(composition.species()[inertSpecie]);
//for cantera 2.4
//Cantera::IdealGasMix gas(mechanismFile, "");
//autoPtr<Cantera::Transport> trans(newTransportMgr(transportModel, &gas, 0));
//for cantera 2.5
word mechanismFile(thermo.lookup("mechanismFile"));
auto sol = Cantera::newSolution(mechanismFile, "");
auto gas = sol->thermo();
word transportModel(thermo.lookup("transportModel")); // Mix, Multi, UnityLewis, Ion, water, HighP
autoPtr<Cantera::Transport> trans(newTransportMgr(transportModel, sol->thermo().get()));
const long unsigned int nSpecies_OF = composition.species().size();
if (gas->nSpecies() != nSpecies_OF)
{
FatalErrorIn("CanteraChemistryModel::solve")
<< "nSpecies in Cantera is not consistent with that in OpenFOAM" << endl
<< abort(FatalError) ;
}
else
{
forAll(Y, i)
{
if (gas->speciesName(i) != Y[i].name())
{
FatalErrorIn("CanteraChemistryModel::solve")
<< "species name in Cantera is not consistent with that in OpenFOAM" << endl
<< "in Cantera:" << gas->speciesName(i) << endl
<< "in OpenFOAM:" << Y[i].name() << endl
<< abort(FatalError) ;
}
}
}
PtrList<volScalarField> diff(Y.size());
forAll(Y, i)
{
diff.set
(
i,
new volScalarField
(
IOobject
(
"diff_" + Y[i].name(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimViscosity, 0) // m2/s
)
);
}
scalar Sct = readScalar(thermo.lookup("Sct"));
volScalarField hc
(
IOobject
(
"hc",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
thermo.hc()
);
volScalarField ha
(
IOobject
(
"ha",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
thermo.he()+thermo.hc()
);
volScalarField diffsh
(
IOobject
(
"diffsh",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimEnergy/dimTime/dimVolume, 0)
);
volVectorField vk
(
IOobject
(
"vk",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector(dimensionSet(1,0,-3,0,0,0,0), Zero)
);
volScalarField Hsi
(
IOobject
(
"Hsi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimEnergy/dimMass, 0.),
zeroGradientFvPatchScalarField::typeName
);
volVectorField DiffError
(
IOobject
(
"DiffError",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector("DiffError", dimDynamicViscosity/dimLength, Zero)
);