initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / postProcessing / dataConversion / foamToFieldview9 / createFields.H
blob042e0e2992ccbdc32964cdc5b4216ccb5bcbc86a
1 // Construct List of pointers to all vol fields
2 int nFields = volScalarNames.size() + 3*volVectorNames.size();
3 List<volScalarField*> volFieldPtrs
5     nFields,
6     reinterpret_cast<volScalarField*>(NULL)
7 );
9 stringList volFieldNames(nFields);
11 nFields = 0;
13     // Load all scalar fields and store ptr to it
14     forAll(volScalarNames, fieldI)
15     {
16         word fieldName = volScalarNames[fieldI];
18         // Check if present
19         IOobject ioHeader
20         (
21             fieldName,
22             runTime.timeName(),
23             mesh,
24             IOobject::MUST_READ,
25             IOobject::NO_WRITE
26         );
28         if (ioHeader.headerOk())
29         {
30            volFieldPtrs[nFields] =
31                 new volScalarField
32                 (
33                     ioHeader,
34                     mesh
35                 );
36         }
38         fieldName = getFieldViewName(fieldName);
40         volFieldNames[nFields] = fieldName;
42         nFields++;
43     }
46     // Load all  (componenents of) vector fields
47     forAll(volVectorNames, fieldI)
48     {
49         word fieldName = volVectorNames[fieldI];
51         // Check if present
52         IOobject ioHeader
53         (
54             fieldName,
55             runTime.timeName(),
56             mesh,
57             IOobject::MUST_READ,
58             IOobject::NO_WRITE
59         );
61         if (ioHeader.headerOk())
62         {
63             volVectorField vvf(ioHeader, mesh);
65             // X component
66             volFieldPtrs[nFields] =
67                 new volScalarField
68                 (
69                     vvf.component(vector::X)
70                 );
72             // Y component
73             volFieldPtrs[nFields+1] =
74                 new volScalarField
75                 (
76                     vvf.component(vector::Y)
77                 );
79             // Z component
80             volFieldPtrs[nFields+2] =
81                 new volScalarField
82                 (
83                     vvf.component(vector::Z)
84                 );
85         }
87         fieldName = getFieldViewName(fieldName);
89         volFieldNames[nFields]   = fieldName + ("x;" +  fieldName);
90         volFieldNames[nFields+1] = fieldName + "y";
91         volFieldNames[nFields+2] = fieldName + "z";
93         nFields += 3;
94     }
100 // Construct List of pointers to all surface fields
105 int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
106 List<surfaceScalarField*> surfFieldPtrs
108     nSurfFields,
109     reinterpret_cast<surfaceScalarField*>(NULL)
112 stringList surfFieldNames(nSurfFields);
114 nSurfFields = 0;
116     // Load all scalar fields
117     forAll(surfScalarNames, fieldI)
118     {
119         word fieldName = surfScalarNames[fieldI];
121         // Check if present
122         IOobject ioHeader
123         (
124             fieldName,
125             runTime.timeName(),
126             mesh,
127             IOobject::MUST_READ,
128             IOobject::NO_WRITE
129         );
131         if (ioHeader.headerOk())
132         {
133             surfFieldPtrs[nSurfFields] =
134                 new surfaceScalarField
135                 (
136                     ioHeader,
137                     mesh
138                 );
139         }
141         fieldName = getFieldViewName(fieldName);
143         surfFieldNames[nSurfFields] = fieldName;
145         nSurfFields++;
146     }
149     // Set (componenents of) vector fields
150     forAll(surfVectorNames, fieldI)
151     {
152         word fieldName = surfVectorNames[fieldI];
154         // Check if present
155         IOobject ioHeader
156         (
157             fieldName,
158             runTime.timeName(),
159             mesh,
160             IOobject::MUST_READ,
161             IOobject::NO_WRITE
162         );
164         if (ioHeader.headerOk())
165         {
166             surfaceVectorField svf(ioHeader, mesh);
168             // X component
169             surfFieldPtrs[nSurfFields] =
170                 new surfaceScalarField
171                 (
172                     svf.component(vector::X)
173                 );
175             // Y component
176             surfFieldPtrs[nSurfFields+1] =
177                 new surfaceScalarField
178                 (
179                     svf.component(vector::Y)
180                 );
182             // Z component
183             surfFieldPtrs[nSurfFields+2] =
184                 new surfaceScalarField
185                 (
186                     svf.component(vector::Z)
187                 );
188         }
190         fieldName = getFieldViewName(fieldName);
192         surfFieldNames[nSurfFields]   = fieldName + ("x;" + fieldName);
193         surfFieldNames[nSurfFields+1] = fieldName + "y";
194         surfFieldNames[nSurfFields+2] = fieldName + "z";
196         nSurfFields += 3;
197     }