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