Remove trailing whitespace systematically
[foam-extend-3.2.git] / applications / utilities / postProcessing / miscellaneous / dsmcFieldsCalc / dsmcFieldsCalc.C
blobdebaea157b9ec9e239dc6a937d078e1492fdac6c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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 // ************************************************************************* //