-
Notifications
You must be signed in to change notification settings - Fork 3
/
createNewFields.H
127 lines (114 loc) · 2.06 KB
/
createNewFields.H
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
label N = Y.size();
label M = reactions.size();
label NM = N*M;
PtrList<volScalarField> RR_(NM);//reaction rate for species n in reaction m
PtrList<volScalarField> SH_(M);//enthorpy source in each reaction
PtrList<volScalarField> rr_(N);//species consumption for each species, calculated from chemistry model rr_[i] = chemistry.RR(i);
PtrList<dimensionedScalar> hcSp(N);//The formation enthapy of each species
forAll(Y, i)
{
const scalar hi = specieData[i].Hc();
hcSp.set
(
i,
new dimensionedScalar("hi",dimEnergy/dimMass,hi)
);
}
forAll(Y,i)
{
word name("RR_" + Y[i].name());
rr_.set
(
i,
new volScalarField
(
IOobject
(
name,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
}
forAll(reactions,m)
{
word name("SH_r" +Foam::name(m));
SH_.set
(
m,
new volScalarField
(
IOobject
(
name,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero", dimEnergy/dimVolume/dimTime, 0.0)
)
);
}
forAll(reactions,m)
{
forAll(Y,n)
{
forAll(reactions[m].lhs(),s)
{
if (n == reactions[m].lhs()[s].index )
{
label II = N*m + n;
word name( Y[n].name() + "_R" +Foam::name(m));
RR_.set
(
II,
new volScalarField
(
IOobject
(
name,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
}
}
forAll(reactions[m].rhs(),s)
{
if (n == reactions[m].rhs()[s].index )
{
label II = N*m + n;
word name( Y[n].name() + "_R" +Foam::name(m));
RR_.set
(
II,
new volScalarField
(
IOobject
(
name,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
}
}
}
}