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

dsmcFieldsCalc.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 Application
00026     dsmcFields
00027 
00028 Description
00029     Calculate intensive fields (U and T) from averaged extensive fields from a
00030     DSMC calculation.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #include "calc.H"
00035 #include "fvc.H"
00036 #include "dsmcCloud.H"
00037 #include "dsmcFields.H"
00038 #include "IOobjectList.H"
00039 
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045     template<class Type>
00046     bool addFieldsToList
00047     (
00048         const fvMesh& mesh,
00049         PtrList<GeometricField<Type, fvPatchField, volMesh> >& list,
00050         const wordList& fieldNames
00051     )
00052     {
00053         typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
00054 
00055         label index = 0;
00056         forAll(fieldNames, i)
00057         {
00058             IOobject obj
00059             (
00060                 fieldNames[i],
00061                 mesh.time().timeName(),
00062                 mesh,
00063                 IOobject::MUST_READ
00064             );
00065 
00066             if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
00067             {
00068                 list.set(index++, new fieldType(obj, mesh));
00069             }
00070             else
00071             {
00072                 Info<< "Could not find " << fieldNames[i] << endl;
00073 
00074                 return false;
00075             }
00076         }
00077 
00078         return true;
00079     }
00080 }
00081 
00082 
00083 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
00084 {
00085     bool writeResults = !args.optionFound("noWrite");
00086 
00087     wordList extensiveVSFNames
00088     (
00089         IStringStream
00090         (
00091             "( \
00092                 rhoNMean \
00093                 rhoMMean \
00094                 linearKEMean \
00095                 internalEMean \
00096                 iDofMean \
00097             )"
00098         )()
00099     );
00100 
00101     PtrList<volScalarField> extensiveVSFs(extensiveVSFNames.size());
00102 
00103     if
00104     (
00105         !addFieldsToList
00106         (
00107             mesh,
00108             extensiveVSFs,
00109             extensiveVSFNames
00110         )
00111     )
00112     {
00113         return;
00114     }
00115 
00116     wordList extensiveVVFNames(IStringStream ("(momentumMean)")());
00117 
00118     PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size());
00119 
00120     if
00121     (
00122         !addFieldsToList
00123         (
00124             mesh,
00125             extensiveVVFs,
00126             extensiveVVFNames
00127         )
00128     )
00129     {
00130         return;
00131     }
00132 
00133     dsmcFields dF
00134     (
00135         "dsmcFieldsUtility",
00136         mesh,
00137         dictionary::null,
00138         false
00139     );
00140 
00141     if (writeResults)
00142     {
00143         dF.write();
00144     }
00145 }
00146 
00147 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd