FreeFOAM The Cross-Platform CFD Toolkit
createFields.H
Go to the documentation of this file.
1 // Construct List of pointers to all vol fields
2 int nFields = volScalarNames.size() + 3*volVectorNames.size();
3 List<volScalarField*> volFieldPtrs
4 (
5  nFields,
6  reinterpret_cast<volScalarField*>(0)
7 );
8 
10 
11 nFields = 0;
12 {
13  // Load all scalar fields and store ptr to it
14  forAll(volScalarNames, fieldI)
15  {
16  word fieldName = volScalarNames[fieldI];
17 
18  // Check if present
19  IOobject ioHeader
20  (
21  fieldName,
22  runTime.timeName(),
23  mesh,
24  IOobject::MUST_READ,
25  IOobject::NO_WRITE
26  );
27 
28  if (ioHeader.headerOk())
29  {
31  (
32  ioHeader,
33  mesh
34  );
35  }
36 
37  fieldName = getFieldViewName(fieldName);
38 
39  volFieldNames[nFields] = fieldName;
40 
41  nFields++;
42  }
43 
44 
45  // Load all (componenents of) vector fields
46  forAll(volVectorNames, fieldI)
47  {
48  word fieldName = volVectorNames[fieldI];
49 
50  // Check if present
51  IOobject ioHeader
52  (
53  fieldName,
54  runTime.timeName(),
55  mesh,
56  IOobject::MUST_READ,
57  IOobject::NO_WRITE
58  );
59 
60  if (ioHeader.headerOk())
61  {
62  volVectorField vvf(ioHeader, mesh);
63 
64  // X component
66  new volScalarField
67  (
68  vvf.component(vector::X)
69  );
70 
71  // Y component
73  new volScalarField
74  (
75  vvf.component(vector::Y)
76  );
77 
78  // Z component
79  volFieldPtrs[nFields+2] =
80  new volScalarField
81  (
82  vvf.component(vector::Z)
83  );
84  }
85 
86  fieldName = getFieldViewName(fieldName);
87 
88  volFieldNames[nFields] = fieldName + ("x;" + fieldName);
89  volFieldNames[nFields+1] = fieldName + "y";
90  volFieldNames[nFields+2] = fieldName + "z";
91 
92  nFields += 3;
93  }
94 }
95 
96 
97 
98 //
99 // Construct List of pointers to all surface fields
100 //
101 
102 
103 
104 int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
105 List<surfaceScalarField*> surfFieldPtrs
106 (
107  nSurfFields,
108  reinterpret_cast<surfaceScalarField*>(0)
109 );
110 
111 stringList surfFieldNames(nSurfFields);
112 
113 nSurfFields = 0;
114 {
115  // Load all scalar fields
116  forAll(surfScalarNames, fieldI)
117  {
118  word fieldName = surfScalarNames[fieldI];
119 
120  // Check if present
121  IOobject ioHeader
122  (
123  fieldName,
124  runTime.timeName(),
125  mesh,
126  IOobject::MUST_READ,
127  IOobject::NO_WRITE
128  );
129 
130  if (ioHeader.headerOk())
131  {
134  (
135  ioHeader,
136  mesh
137  );
138  }
139 
140  fieldName = getFieldViewName(fieldName);
141 
142  surfFieldNames[nSurfFields] = fieldName;
143 
144  nSurfFields++;
145  }
146 
147 
148  // Set (componenents of) vector fields
149  forAll(surfVectorNames, fieldI)
150  {
151  word fieldName = surfVectorNames[fieldI];
152 
153  // Check if present
154  IOobject ioHeader
155  (
156  fieldName,
157  runTime.timeName(),
158  mesh,
159  IOobject::MUST_READ,
160  IOobject::NO_WRITE
161  );
162 
163  if (ioHeader.headerOk())
164  {
165  surfaceVectorField svf(ioHeader, mesh);
166 
167  // X component
170  (
171  svf.component(vector::X)
172  );
173 
174  // Y component
175  surfFieldPtrs[nSurfFields+1] =
177  (
178  svf.component(vector::Y)
179  );
180 
181  // Z component
182  surfFieldPtrs[nSurfFields+2] =
184  (
185  svf.component(vector::Z)
186  );
187  }
188 
189  fieldName = getFieldViewName(fieldName);
190 
191  surfFieldNames[nSurfFields] = fieldName + ("x;" + fieldName);
192  surfFieldNames[nSurfFields+1] = fieldName + "y";
193  surfFieldNames[nSurfFields+2] = fieldName + "z";
194 
195  nSurfFields += 3;
196  }
197 }