BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / utilities / postProcessing / miscellaneous / dsmcFieldsCalc / dsmcFieldsCalc.C
blobe32e012efe9ef965fd274682db438db3010e5c2c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     dsmcFields
27 Description
28     Calculate intensive fields (U and T) from averaged extensive fields from a
29     DSMC calculation.
31 \*---------------------------------------------------------------------------*/
33 #include "calc.H"
34 #include "fvc.H"
35 #include "dsmcCloud.H"
36 #include "dsmcFields.H"
37 #include "IOobjectList.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
44     template<class Type>
45     bool addFieldsToList
46     (
47         const fvMesh& mesh,
48         PtrList<GeometricField<Type, fvPatchField, volMesh> >& list,
49         const wordList& fieldNames
50     )
51     {
52         typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
54         label index = 0;
55         forAll(fieldNames, i)
56         {
57             IOobject obj
58             (
59                 fieldNames[i],
60                 mesh.time().timeName(),
61                 mesh,
62                 IOobject::MUST_READ
63             );
65             if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
66             {
67                 list.set(index++, new fieldType(obj, mesh));
68             }
69             else
70             {
71                 Info<< "Could not find " << fieldNames[i] << endl;
73                 return false;
74             }
75         }
77         return true;
78     }
82 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
84     bool writeResults = !args.optionFound("noWrite");
86     wordList extensiveVSFNames
87     (
88         IStringStream
89         (
90             "( \
91                 rhoNMean \
92                 rhoMMean \
93                 linearKEMean \
94                 internalEMean \
95                 iDofMean \
96             )"
97         )()
98     );
100     PtrList<volScalarField> extensiveVSFs(extensiveVSFNames.size());
102     if
103     (
104         !addFieldsToList
105         (
106             mesh,
107             extensiveVSFs,
108             extensiveVSFNames
109         )
110     )
111     {
112         return;
113     }
115     wordList extensiveVVFNames
116     (
117         IStringStream
118         (
119             "( \
120                 momentumMean \
121                 fDMean \
122             )"
123         )()
124     );
126     PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size());
128     if
129     (
130         !addFieldsToList
131         (
132             mesh,
133             extensiveVVFs,
134             extensiveVVFNames
135         )
136     )
137     {
138         return;
139     }
141     dsmcFields dF
142     (
143         "dsmcFieldsUtility",
144         mesh,
145         dictionary::null,
146         false
147     );
149     if (writeResults)
150     {
151         dF.write();
152     }
155 // ************************************************************************* //