FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

averageMDFields.H

Go to the documentation of this file.
00001 if (runTime.outputTime())
00002 {
00003     /*-----------------------------------------------------------------------*\
00004         Number density
00005     \*-----------------------------------------------------------------------*/
00006 
00007     scalarField totalRhoN_sum(mesh.nCells(), 0.0);
00008 
00009     forAll (allSpeciesRhoN, rN)
00010     {
00011         allSpeciesRhoN[rN].internalField() =
00012             allSpeciesN_RU[rN]
00013             /mesh.cellVolumes()
00014             /nAveragingSteps;
00015 
00016         totalRhoN_sum += allSpeciesRhoN[rN].internalField();
00017     }
00018 
00019     totalRhoN.internalField() = totalRhoN_sum;
00020 
00021 
00022     /*-----------------------------------------------------------------------*\
00023         Mass density
00024     \*-----------------------------------------------------------------------*/
00025 
00026     scalarField totalRhoM_sum(mesh.nCells(), 0.0);
00027 
00028     forAll (allSpeciesRhoM, rM)
00029     {
00030         allSpeciesRhoM[rM].internalField() =
00031             allSpeciesM_RU[rM]
00032             /mesh.cellVolumes()
00033             /nAveragingSteps;
00034 
00035         totalRhoM_sum += allSpeciesRhoM[rM].internalField();
00036     }
00037 
00038     totalRhoM.internalField() = totalRhoM_sum;
00039 
00040     /*-----------------------------------------------------------------------*\
00041         Bulk velocity
00042     \*-----------------------------------------------------------------------*/
00043 
00044     vectorField totalMomentum_sum(mesh.nCells(), vector::zero);
00045 
00046     scalarField totalMass_sum(mesh.nCells(), 0.0);
00047 
00048     forAll (allSpeciesVelocity, v)
00049     {
00050         // A check for 1/0 molecules is required.
00051 
00052         vectorField& singleSpeciesVelocity
00053         (
00054             allSpeciesVelocity[v].internalField()
00055         );
00056 
00057         forAll(singleSpeciesVelocity, sSV)
00058         {
00059             if (allSpeciesN_RU[v][sSV])
00060             {
00061                 singleSpeciesVelocity[sSV] =
00062                     allSpeciesVelocitySum_RU[v][sSV]
00063                     /allSpeciesN_RU[v][sSV];
00064 
00065                 totalMomentum_sum[sSV] +=
00066                     allSpeciesM_RU[v][sSV]
00067                     /allSpeciesN_RU[v][sSV]
00068                     *allSpeciesVelocitySum_RU[v][sSV];
00069 
00070                 totalMass_sum[sSV] += allSpeciesM_RU[v][sSV];
00071             }
00072             else
00073             {
00074                 singleSpeciesVelocity[sSV] = vector::zero;
00075             }
00076         }
00077     }
00078 
00079     forAll(totalVelocity.internalField(), tV)
00080     {
00081         if (totalMass_sum[tV] > VSMALL)
00082         {
00083             totalVelocity.internalField()[tV] =
00084                 totalMomentum_sum[tV]
00085                 /totalMass_sum[tV];
00086         }
00087         else
00088         {
00089             totalVelocity.internalField()[tV] =
00090             vector::zero;
00091         }
00092     }
00093 
00094     /*-----------------------------------------------------------------------*\
00095         Kinetic temperature
00096     \*-----------------------------------------------------------------------*/
00097 
00098     scalarField totalTemperatureVTerms_sum(mesh.nCells(), 0.0);
00099 
00100     scalarField totalN_sum(mesh.nCells(), 0.0);
00101 
00102     forAll (allSpeciesTemperature, t)
00103     {
00104         // A check for 1/0 molecules is required.
00105 
00106         scalarField& singleSpeciesTemp
00107         (
00108             allSpeciesTemperature[t].internalField()
00109         );
00110 
00111         forAll(singleSpeciesTemp, sST)
00112         {
00113             if (allSpeciesN_RU[t][sST])
00114             {
00115                 singleSpeciesTemp[sST] =
00116                     allSpeciesM_RU[t][sST]
00117                     /allSpeciesN_RU[t][sST]
00118                     /(3.0 * moleculeCloud::kb * allSpeciesN_RU[t][sST])
00119                    *(
00120                         allSpeciesVelocityMagSquaredSum_RU[t][sST]
00121                         -
00122                         (
00123                             allSpeciesVelocitySum_RU[t][sST]
00124                             &
00125                             allSpeciesVelocitySum_RU[t][sST]
00126                         )
00127                         /allSpeciesN_RU[t][sST]
00128                     );
00129 
00130                 totalTemperatureVTerms_sum[sST] +=
00131                     allSpeciesM_RU[t][sST]
00132                    /allSpeciesN_RU[t][sST]
00133                    *(
00134                         allSpeciesVelocityMagSquaredSum_RU[t][sST]
00135                       -
00136                         (
00137                             allSpeciesVelocitySum_RU[t][sST]
00138                             &
00139                             allSpeciesVelocitySum_RU[t][sST]
00140                         )
00141                         /allSpeciesN_RU[t][sST]
00142                     );
00143 
00144                 totalN_sum[sST] += allSpeciesN_RU[t][sST];
00145             }
00146             else
00147             {
00148                 singleSpeciesTemp[sST] = 0.0;
00149             }
00150         }
00151     }
00152 
00153     forAll(totalTemperature.internalField(), tT)
00154     {
00155         if(totalN_sum[tT] > 0)
00156         {
00157             totalTemperature.internalField()[tT] =
00158                 totalTemperatureVTerms_sum[tT]
00159                 /(3.0 * moleculeCloud::kb * totalN_sum[tT]);
00160         }
00161         else
00162         {
00163             totalTemperature.internalField()[tT] = 0.0;
00164         }
00165     }
00166 
00167     /*-----------------------------------------------------------------------*\
00168         Mean kinetic energy
00169     \*-----------------------------------------------------------------------*/
00170 
00171     scalarField totalKE_sum(mesh.nCells(), 0.0);
00172 
00173     forAll (allSpeciesMeanKE, mKE)
00174     {
00175         // A check for 1/0 molecules is required.
00176 
00177         scalarField& singleSpeciesMeanKE
00178         (
00179             allSpeciesMeanKE[mKE].internalField()
00180         );
00181 
00182         forAll(singleSpeciesMeanKE, sSMKE)
00183         {
00184             if(allSpeciesN_RU[mKE][sSMKE])
00185             {
00186                 singleSpeciesMeanKE[sSMKE] =
00187                     allSpeciesM_RU[mKE][sSMKE]
00188                    /allSpeciesN_RU[mKE][sSMKE]
00189                    /(2.0*allSpeciesN_RU[mKE][sSMKE])
00190                    *(
00191                         allSpeciesVelocityMagSquaredSum_RU[mKE][sSMKE]
00192                     );
00193 
00194                 totalKE_sum[sSMKE] +=
00195                     allSpeciesM_RU[mKE][sSMKE]
00196                     /allSpeciesN_RU[mKE][sSMKE]
00197                     /2.0
00198                    *(
00199                         allSpeciesVelocityMagSquaredSum_RU[mKE][sSMKE]
00200                     );
00201             }
00202             else
00203             {
00204                 singleSpeciesMeanKE[sSMKE] = 0.0;
00205             }
00206         }
00207     }
00208 
00209     forAll(totalMeanKE.internalField(), tMKE)
00210     {
00211         if(totalN_sum[tMKE] > 0)
00212         {
00213             totalMeanKE.internalField()[tMKE] =
00214                 totalKE_sum[tMKE]
00215                 /totalN_sum[tMKE];
00216         }
00217         else
00218         {
00219             totalMeanKE.internalField()[tMKE] = 0.0;
00220         }
00221     }
00222 }
00223 
00224 
00225 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines