00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Global 00025 temperatureAndPressure.H 00026 00027 Description 00028 Accumulates values for temperature and pressure measurement, and 00029 calculates and outputs the average values at output times. 00030 Requires temperatureAndPressureVariables.H to be declared before the 00031 timeloop. 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 accumulatedTotalLinearMomentum += singleStepTotalLinearMomentum; 00036 00037 accumulatedTotalMass += singleStepTotalMass; 00038 00039 accumulatedTotalLinearKE += singleStepTotalLinearKE; 00040 00041 accumulatedTotalAngularKE += singleStepTotalAngularKE; 00042 00043 accumulatedTotalPE += singleStepTotalPE; 00044 00045 accumulatedTotalrDotfSum += singleStepTotalrDotf; 00046 00047 accumulatedNMols += singleStepNMols; 00048 00049 accumulatedDOFs += singleStepDOFs; 00050 00051 if (runTime.outputTime()) 00052 { 00053 if (accumulatedNMols) 00054 { 00055 Info << "calculating averages" << endl; 00056 00057 averageTemperature = 00058 ( 00059 2.0/(moleculeCloud::kb * accumulatedDOFs) 00060 * 00061 ( 00062 accumulatedTotalLinearKE + accumulatedTotalAngularKE 00063 - 00064 0.5*magSqr(accumulatedTotalLinearMomentum)/accumulatedTotalMass 00065 ) 00066 ); 00067 00068 averagePressure = 00069 ( 00070 ( 00071 (accumulatedNMols/nAveragingSteps) 00072 * 00073 moleculeCloud::kb * averageTemperature 00074 + 00075 accumulatedTotalrDotfSum/(6.0 * nAveragingSteps) 00076 ) 00077 / 00078 meshVolume 00079 ); 00080 00081 Info << "----------------------------------------" << nl 00082 << "Averaged properties" << nl 00083 << "Average |velocity| = " 00084 << mag(accumulatedTotalLinearMomentum)/accumulatedTotalMass << nl 00085 << "Average temperature = " << averageTemperature << nl 00086 << "Average pressure = " << averagePressure << nl 00087 << "----------------------------------------" << endl; 00088 } 00089 else 00090 { 00091 Info<< "Not averaging temperature and pressure: " 00092 << "no molecules in system" << endl; 00093 } 00094 00095 accumulatedTotalLinearMomentum = vector::zero; 00096 00097 accumulatedTotalMass = 0.0; 00098 00099 accumulatedTotalLinearKE = 0.0; 00100 00101 accumulatedTotalAngularKE = 0.0; 00102 00103 accumulatedTotalPE = 0.0; 00104 00105 accumulatedTotalrDotfSum = 0.0; 00106 00107 accumulatedNMols = 0; 00108 00109 accumulatedDOFs = 0; 00110 } 00111 00112 00113 // ************************ vim: set sw=4 sts=4 et: ************************ //