FreeFOAM The Cross-Platform CFD Toolkit
dsmcFieldsCalc.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Application
25  dsmcFields
26 
27 Description
28  Calculate intensive fields (U and T) from averaged extensive fields from a
29  DSMC calculation.
30 
31 Usage
32  - dsmcFieldsCalc [OPTION]
33 
34  @param -noWrite \n
35  Suppress output to files.
36 
37  @param -dictionary <dictionary name>\n
38  Use specified dictionary.
39 
40  @param -noZero \n
41  Ignore timestep 0.
42 
43  @param -constant \n
44  Include the constant directory.
45 
46  @param -time <time>\n
47  Apply only to specific time.
48 
49  @param -latestTime \n
50  Only apply to latest time step.
51 
52  @param -case <dir> \n
53  Specify the case directory
54 
55  @param -parallel \n
56  Run the case in parallel
57 
58  @param -help \n
59  Display short usage message
60 
61  @param -doc \n
62  Display Doxygen documentation page
63 
64  @param -srcDoc \n
65  Display source code
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #include <postCalc/calc.H>
70 #include <finiteVolume/fvc.H>
71 #include <dsmc/dsmcCloud.H>
73 #include <OpenFOAM/IOobjectList.H>
74 
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80  template<class Type>
81  bool addFieldsToList
82  (
83  const fvMesh& mesh,
84  PtrList<GeometricField<Type, fvPatchField, volMesh> >& list,
85  const wordList& fieldNames
86  )
87  {
88  typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
89 
90  label index = 0;
91  forAll(fieldNames, i)
92  {
93  IOobject obj
94  (
95  fieldNames[i],
96  mesh.time().timeName(),
97  mesh,
99  );
100 
101  if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
102  {
103  list.set(index++, new fieldType(obj, mesh));
104  }
105  else
106  {
107  Info<< "Could not find " << fieldNames[i] << endl;
108 
109  return false;
110  }
111  }
112 
113  return true;
114  }
115 }
116 
117 
118 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
119 {
120  bool writeResults = !args.optionFound("noWrite");
121 
122  wordList extensiveVSFNames
123  (
124  IStringStream
125  (
126  "( \
127  rhoNMean \
128  rhoMMean \
129  linearKEMean \
130  internalEMean \
131  iDofMean \
132  )"
133  )()
134  );
135 
136  PtrList<volScalarField> extensiveVSFs(extensiveVSFNames.size());
137 
138  if
139  (
140  !addFieldsToList
141  (
142  mesh,
143  extensiveVSFs,
144  extensiveVSFNames
145  )
146  )
147  {
148  return;
149  }
150 
151  wordList extensiveVVFNames
152  (
153  IStringStream
154  (
155  "( \
156  momentumMean \
157  fDMean \
158  )"
159  )()
160  );
161 
162  PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size());
163 
164  if
165  (
166  !addFieldsToList
167  (
168  mesh,
169  extensiveVVFs,
170  extensiveVVFNames
171  )
172  )
173  {
174  return;
175  }
176 
177  dsmcFields dF
178  (
179  "dsmcFieldsUtility",
180  mesh,
181  dictionary::null,
182  false
183  );
184 
185  if (writeResults)
186  {
187  dF.write();
188  }
189 }
190 
191 // ************************ vim: set sw=4 sts=4 et: ************************ //