OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

dsmcFields.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2009-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "dsmcFields.H"
00028 #include "volFields.H"
00029 #include "dictionary.H"
00030 #include "dsmcCloud.H"
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036     defineTypeNameAndDebug(dsmcFields, 0);
00037 }
00038 
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 Foam::dsmcFields::dsmcFields
00043 (
00044     const word& name,
00045     const objectRegistry& obr,
00046     const dictionary& dict,
00047     const bool loadFromFiles
00048 )
00049 :
00050     name_(name),
00051     obr_(obr),
00052     active_(true)
00053 {
00054     // Check if the available mesh is an fvMesh, otherwise deactivate
00055     if (!isA<fvMesh>(obr_))
00056     {
00057         active_ = false;
00058         WarningIn
00059         (
00060             "dsmcFields::dsmcFields"
00061             "(const objectRegistry&, const dictionary&)"
00062         )   << "No fvMesh available, deactivating." << nl
00063             << endl;
00064     }
00065 
00066     read(dict);
00067 }
00068 
00069 
00070 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00071 
00072 Foam::dsmcFields::~dsmcFields()
00073 {}
00074 
00075 
00076 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00077 
00078 void Foam::dsmcFields::read(const dictionary& dict)
00079 {
00080     if (active_)
00081     {
00082 
00083     }
00084 }
00085 
00086 
00087 void Foam::dsmcFields::execute()
00088 {
00089     // Do nothing - only valid on write
00090 }
00091 
00092 
00093 void Foam::dsmcFields::end()
00094 {
00095     // Do nothing - only valid on write
00096 }
00097 
00098 
00099 void Foam::dsmcFields::write()
00100 {
00101     if (active_)
00102     {
00103         word rhoNMeanName = "rhoNMean";
00104         word rhoMMeanName = "rhoMMean";
00105         word momentumMeanName = "momentumMean";
00106         word linearKEMeanName = "linearKEMean";
00107         word internalEMeanName = "internalEMean";
00108         word iDofMeanName = "iDofMean";
00109 
00110         const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
00111         (
00112             rhoNMeanName
00113         );
00114 
00115         const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
00116         (
00117             rhoMMeanName
00118         );
00119 
00120         const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
00121         (
00122             momentumMeanName
00123         );
00124 
00125         const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
00126         (
00127             linearKEMeanName
00128         );
00129 
00130         const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
00131         (
00132             internalEMeanName
00133         );
00134 
00135         const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
00136         (
00137             iDofMeanName
00138         );
00139 
00140         if (min(mag(rhoNMean)).value() > VSMALL)
00141         {
00142             Info<< "Calculating dsmcFields." << endl;
00143 
00144             Info<< "    Calculating UMean field." << endl;
00145             volVectorField UMean
00146             (
00147                 IOobject
00148                 (
00149                     "UMean",
00150                     obr_.time().timeName(),
00151                     obr_,
00152                     IOobject::NO_READ
00153                 ),
00154                 momentumMean/rhoMMean
00155             );
00156 
00157             Info<< "    Calculating translationalT field." << endl;
00158             volScalarField translationalT
00159             (
00160                 IOobject
00161                 (
00162                     "translationalT",
00163                     obr_.time().timeName(),
00164                     obr_,
00165                     IOobject::NO_READ
00166                 ),
00167                 2.0/(3.0*dsmcCloud::kb*rhoNMean)
00168                 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
00169             );
00170 
00171             Info<< "    Calculating internalT field." << endl;
00172             volScalarField internalT
00173             (
00174                 IOobject
00175                 (
00176                     "internalT",
00177                     obr_.time().timeName(),
00178                     obr_,
00179                     IOobject::NO_READ
00180                 ),
00181                 2.0/(dsmcCloud::kb*iDofMean)*internalEMean
00182             );
00183 
00184             Info<< "    Calculating overallT field." << endl;
00185             volScalarField overallT
00186             (
00187                 IOobject
00188                 (
00189                     "overallT",
00190                     obr_.time().timeName(),
00191                     obr_,
00192                     IOobject::NO_READ
00193                 ),
00194                 2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean))
00195                 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
00196             );
00197 
00198             Info<< "    mag(UMean) max/min : "
00199                 << max(mag(UMean)).value() << " "
00200                 << min(mag(UMean)).value() << endl;
00201 
00202             Info<< "    translationalT max/min : "
00203                 << max(translationalT).value() << " "
00204                 << min(translationalT).value() << endl;
00205 
00206             Info<< "    internalT max/min : "
00207                 << max(internalT).value() << " "
00208                 << min(internalT).value() << endl;
00209 
00210             Info<< "    overallT max/min : "
00211                 << max(overallT).value() << " "
00212                 << min(overallT).value() << endl;
00213 
00214             UMean.write();
00215 
00216             translationalT.write();
00217 
00218             internalT.write();
00219 
00220             overallT.write();
00221 
00222             Info<< "dsmcFields written." << nl << endl;
00223         }
00224         else
00225         {
00226             Info<< "Small value (" << min(mag(rhoNMean))
00227                 << ") found in rhoNMean field. "
00228                 << "Not calculating dsmcFields to avoid division by zero."
00229                 << endl;
00230         }
00231     }
00232 }
00233 
00234 
00235 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd