averageMDFields.H
Go to the documentation of this file.
1if (runTime.writeTime())
2{
3 /*-----------------------------------------------------------------------*\
4 Number density
5 \*-----------------------------------------------------------------------*/
6
7 scalarField totalRhoN_sum(mesh.nCells(), Zero);
8
10 {
11 allSpeciesRhoN[rN].primitiveFieldRef() =
13 /mesh.cellVolumes()
14 /nAveragingSteps;
15
16 totalRhoN_sum += allSpeciesRhoN[rN].primitiveField();
17 }
18
19 totalRhoN.primitiveFieldRef() = totalRhoN_sum;
20
21
22 /*-----------------------------------------------------------------------*\
23 Mass density
24 \*-----------------------------------------------------------------------*/
25
26 scalarField totalRhoM_sum(mesh.nCells(), Zero);
27
29 {
30 allSpeciesRhoM[rM].primitiveFieldRef() =
32 /mesh.cellVolumes()
33 /nAveragingSteps;
34
35 totalRhoM_sum += allSpeciesRhoM[rM].primitiveField();
36 }
37
38 totalRhoM.primitiveFieldRef() = totalRhoM_sum;
39
40 /*-----------------------------------------------------------------------*\
41 Bulk velocity
42 \*-----------------------------------------------------------------------*/
43
44 vectorField totalMomentum_sum(mesh.nCells(), Zero);
45
46 scalarField totalMass_sum(mesh.nCells(), Zero);
47
49 {
50 // A check for 1/0 molecules is required.
51
52 vectorField& singleSpeciesVelocity
53 (
54 allSpeciesVelocity[v].primitiveField()
55 );
56
57 forAll(singleSpeciesVelocity, sSV)
58 {
59 if (allSpeciesN_RU[v][sSV])
60 {
61 singleSpeciesVelocity[sSV] =
63 /allSpeciesN_RU[v][sSV];
64
65 totalMomentum_sum[sSV] +=
66 allSpeciesM_RU[v][sSV]
67 /allSpeciesN_RU[v][sSV]
69
70 totalMass_sum[sSV] += allSpeciesM_RU[v][sSV];
71 }
72 else
73 {
74 singleSpeciesVelocity[sSV] = Zero;
75 }
76 }
77 }
78
79 volVectorField::Internal& itotalVelocity = totalVelocity;
80
81 forAll(itotalVelocity, tV)
82 {
83 if (totalMass_sum[tV] > VSMALL)
84 {
85 itotalVelocity[tV] = totalMomentum_sum[tV]/totalMass_sum[tV];
86 }
87 else
88 {
89 itotalVelocity[tV] = Zero;
90 }
91 }
92
93 /*-----------------------------------------------------------------------*\
94 Kinetic temperature
95 \*-----------------------------------------------------------------------*/
96
97 scalarField totalTemperatureVTerms_sum(mesh.nCells(), Zero);
98
99 scalarField totalN_sum(mesh.nCells(), Zero);
100
102 {
103 // A check for 1/0 molecules is required.
104
105 scalarField& singleSpeciesTemp
106 (
107 allSpeciesTemperature[t].primitiveField()
108 );
109
110 forAll(singleSpeciesTemp, sST)
111 {
112 if (allSpeciesN_RU[t][sST])
113 {
114 singleSpeciesTemp[sST] =
115 allSpeciesM_RU[t][sST]
116 /allSpeciesN_RU[t][sST]
117 /(3.0 * moleculeCloud::kb * allSpeciesN_RU[t][sST])
118 *(
120 -
121 (
123 &
125 )
126 /allSpeciesN_RU[t][sST]
127 );
128
129 totalTemperatureVTerms_sum[sST] +=
130 allSpeciesM_RU[t][sST]
131 /allSpeciesN_RU[t][sST]
132 *(
134 -
135 (
137 &
139 )
140 /allSpeciesN_RU[t][sST]
141 );
142
143 totalN_sum[sST] += allSpeciesN_RU[t][sST];
144 }
145 else
146 {
147 singleSpeciesTemp[sST] = 0.0;
148 }
149 }
150 }
151
152 volScalarField::Internal& itotalTemperature =
153 totalTemperature;
154
155 forAll(itotalTemperature, tT)
156 {
157 if (totalN_sum[tT] > 0)
158 {
159 itotalTemperature[tT] =
160 totalTemperatureVTerms_sum[tT]
161 /(3.0 * moleculeCloud::kb * totalN_sum[tT]);
162 }
163 else
164 {
165 itotalTemperature[tT] = 0.0;
166 }
167 }
168
169 /*-----------------------------------------------------------------------*\
170 Mean kinetic energy
171 \*-----------------------------------------------------------------------*/
172
173 scalarField totalKE_sum(mesh.nCells(), Zero);
174
176 {
177 // A check for 1/0 molecules is required.
178
179 scalarField& singleSpeciesMeanKE
180 (
181 allSpeciesMeanKE[mKE].primitiveField()
182 );
183
184 forAll(singleSpeciesMeanKE, sSMKE)
185 {
186 if (allSpeciesN_RU[mKE][sSMKE])
187 {
188 singleSpeciesMeanKE[sSMKE] =
189 allSpeciesM_RU[mKE][sSMKE]
190 /allSpeciesN_RU[mKE][sSMKE]
191 /(2.0*allSpeciesN_RU[mKE][sSMKE])
192 *(
194 );
195
196 totalKE_sum[sSMKE] +=
197 allSpeciesM_RU[mKE][sSMKE]
198 /allSpeciesN_RU[mKE][sSMKE]
199 /2.0
200 *(
202 );
203 }
204 else
205 {
206 singleSpeciesMeanKE[sSMKE] = 0.0;
207 }
208 }
209 }
210
211 volScalarField::Internal& itotalMeanKE = totalMeanKE;
212
213 forAll(itotalMeanKE, tMKE)
214 {
215 if (totalN_sum[tMKE] > 0)
216 {
217 itotalMeanKE[tMKE] =
218 totalKE_sum[tMKE]
219 /totalN_sum[tMKE];
220 }
221 else
222 {
223 itotalMeanKE[tMKE] = 0.0;
224 }
225 }
226}
dynamicFvMesh & mesh
engineTime & runTime
List< scalarField > allSpeciesN_RU(molecules.potential().nIds(), scalarField(mesh.nCells(), Zero))
List< vectorField > allSpeciesVelocitySum_RU(molecules.potential().nIds(), vectorField(mesh.nCells(), Zero))
Info<< nl<< "Creating fields."<< endl;PtrList< volScalarField > allSpeciesRhoN(molecules.potential().nIds())
List< scalarField > allSpeciesVelocityMagSquaredSum_RU(molecules.potential().nIds(), scalarField(mesh.nCells(), Zero))
List< scalarField > allSpeciesM_RU(molecules.potential().nIds(), scalarField(mesh.nCells(), Zero))
Info<< " Creating total temperature field"<< endl;volScalarField totalTemperature(IOobject("temperature_total", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimTemperature, "zeroGradient");totalTemperature.primitiveFieldRef()=0;totalTemperature.correctBoundaryConditions();PtrList< volScalarField > allSpeciesMeanKE(molecules.potential().nIds())
Info<< " Creating total number density field"<< endl;volScalarField totalRhoN(IOobject("rhoN_total", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimless/dimVolume, "zeroGradient");totalRhoN.primitiveFieldRef()=0;totalRhoN.correctBoundaryConditions();PtrList< volScalarField > allSpeciesRhoM(molecules.potential().nIds())
Info<< " Creating total mass density field"<< endl;volScalarField totalRhoM(IOobject("rhoM_total", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimMass/dimVolume, "zeroGradient");totalRhoM.primitiveFieldRef()=0;totalRhoM.correctBoundaryConditions();PtrList< volVectorField > allSpeciesVelocity(molecules.potential().nIds())
Info<< " Creating total velocity field"<< endl;volVectorField totalVelocity(IOobject("velocity_total", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimensionedVector(dimVelocity, Zero));PtrList< volScalarField > allSpeciesTemperature(molecules.potential().nIds())
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333