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

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-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 Application
00025     dsmcFields
00026 
00027 Description
00028     Calculate intensive fields (U and T) from averaged extensive fields from a
00029     DSMC calculation.
00030 
00031 Usage
00032     - dsmcFieldsCalc [OPTION]
00033 
00034     @param -noWrite \n
00035     Suppress output to files.
00036 
00037     @param -dictionary <dictionary name>\n
00038     Use specified dictionary.
00039 
00040     @param -noZero \n
00041     Ignore timestep 0.
00042 
00043     @param -constant \n
00044     Include the constant directory.
00045 
00046     @param -time <time>\n
00047     Apply only to specific time.
00048 
00049     @param -latestTime \n
00050     Only apply to latest time step.
00051 
00052     @param -case <dir> \n
00053     Specify the case directory
00054 
00055     @param -parallel \n
00056     Run the case in parallel
00057 
00058     @param -help \n
00059     Display short usage message
00060 
00061     @param -doc \n
00062     Display Doxygen documentation page
00063 
00064     @param -srcDoc \n
00065     Display source code
00066 
00067 \*---------------------------------------------------------------------------*/
00068 
00069 #include <postCalc/calc.H>
00070 #include <finiteVolume/fvc.H>
00071 #include <dsmc/dsmcCloud.H>
00072 #include <utilityFunctionObjects/dsmcFields.H>
00073 #include <OpenFOAM/IOobjectList.H>
00074 
00075 
00076 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00077 
00078 namespace Foam
00079 {
00080     template<class Type>
00081     bool addFieldsToList
00082     (
00083         const fvMesh& mesh,
00084         PtrList<GeometricField<Type, fvPatchField, volMesh> >& list,
00085         const wordList& fieldNames
00086     )
00087     {
00088         typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
00089 
00090         label index = 0;
00091         forAll(fieldNames, i)
00092         {
00093             IOobject obj
00094             (
00095                 fieldNames[i],
00096                 mesh.time().timeName(),
00097                 mesh,
00098                 IOobject::MUST_READ
00099             );
00100 
00101             if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
00102             {
00103                 list.set(index++, new fieldType(obj, mesh));
00104             }
00105             else
00106             {
00107                 Info<< "Could not find " << fieldNames[i] << endl;
00108 
00109                 return false;
00110             }
00111         }
00112 
00113         return true;
00114     }
00115 }
00116 
00117 
00118 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
00119 {
00120     bool writeResults = !args.optionFound("noWrite");
00121 
00122     wordList extensiveVSFNames
00123     (
00124         IStringStream
00125         (
00126             "( \
00127                 rhoNMean \
00128                 rhoMMean \
00129                 linearKEMean \
00130                 internalEMean \
00131                 iDofMean \
00132             )"
00133         )()
00134     );
00135 
00136     PtrList<volScalarField> extensiveVSFs(extensiveVSFNames.size());
00137 
00138     if
00139     (
00140         !addFieldsToList
00141         (
00142             mesh,
00143             extensiveVSFs,
00144             extensiveVSFNames
00145         )
00146     )
00147     {
00148         return;
00149     }
00150 
00151     wordList extensiveVVFNames
00152     (
00153         IStringStream
00154         (
00155             "( \
00156                 momentumMean \
00157                 fDMean \
00158             )"
00159         )()
00160     );
00161 
00162     PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size());
00163 
00164     if
00165     (
00166         !addFieldsToList
00167         (
00168             mesh,
00169             extensiveVVFs,
00170             extensiveVVFNames
00171         )
00172     )
00173     {
00174         return;
00175     }
00176 
00177     dsmcFields dF
00178     (
00179         "dsmcFieldsUtility",
00180         mesh,
00181         dictionary::null,
00182         false
00183     );
00184 
00185     if (writeResults)
00186     {
00187         dF.write();
00188     }
00189 }
00190 
00191 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines