Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToFieldview9 / createFields.H
blob77f5f0ebc9a62bb42028fd47191192e558018a73
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*>(0)
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] = new volScalarField
31             (
32                 ioHeader,
33                 mesh
34             );
35         }
37         fieldName = getFieldViewName(fieldName);
39         volFieldNames[nFields] = fieldName;
41         nFields++;
42     }
45     // Load all  (componenents of) vector fields
46     forAll(volVectorNames, fieldI)
47     {
48         word fieldName = volVectorNames[fieldI];
50         // Check if present
51         IOobject ioHeader
52         (
53             fieldName,
54             runTime.timeName(),
55             mesh,
56             IOobject::MUST_READ,
57             IOobject::NO_WRITE
58         );
60         if (ioHeader.headerOk())
61         {
62             volVectorField vvf(ioHeader, mesh);
64             // X component
65             volFieldPtrs[nFields] =
66                 new volScalarField
67                 (
68                     vvf.component(vector::X)
69                 );
71             // Y component
72             volFieldPtrs[nFields+1] =
73                 new volScalarField
74                 (
75                     vvf.component(vector::Y)
76                 );
78             // Z component
79             volFieldPtrs[nFields+2] =
80                 new volScalarField
81                 (
82                     vvf.component(vector::Z)
83                 );
84         }
86         fieldName = getFieldViewName(fieldName);
88         volFieldNames[nFields]   = fieldName + ("x;" +  fieldName);
89         volFieldNames[nFields+1] = fieldName + "y";
90         volFieldNames[nFields+2] = fieldName + "z";
92         nFields += 3;
93     }
99 // Construct List of pointers to all surface fields
104 int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
105 List<surfaceScalarField*> surfFieldPtrs
107     nSurfFields,
108     reinterpret_cast<surfaceScalarField*>(0)
111 stringList surfFieldNames(nSurfFields);
113 nSurfFields = 0;
115     // Load all scalar fields
116     forAll(surfScalarNames, fieldI)
117     {
118         word fieldName = surfScalarNames[fieldI];
120         // Check if present
121         IOobject ioHeader
122         (
123             fieldName,
124             runTime.timeName(),
125             mesh,
126             IOobject::MUST_READ,
127             IOobject::NO_WRITE
128         );
130         if (ioHeader.headerOk())
131         {
132             surfFieldPtrs[nSurfFields] =
133                 new surfaceScalarField
134                 (
135                     ioHeader,
136                     mesh
137                 );
138         }
140         fieldName = getFieldViewName(fieldName);
142         surfFieldNames[nSurfFields] = fieldName;
144         nSurfFields++;
145     }
148     // Set (componenents of) vector fields
149     forAll(surfVectorNames, fieldI)
150     {
151         word fieldName = surfVectorNames[fieldI];
153         // Check if present
154         IOobject ioHeader
155         (
156             fieldName,
157             runTime.timeName(),
158             mesh,
159             IOobject::MUST_READ,
160             IOobject::NO_WRITE
161         );
163         if (ioHeader.headerOk())
164         {
165             surfaceVectorField svf(ioHeader, mesh);
167             // X component
168             surfFieldPtrs[nSurfFields] =
169                 new surfaceScalarField
170                 (
171                     svf.component(vector::X)
172                 );
174             // Y component
175             surfFieldPtrs[nSurfFields+1] =
176                 new surfaceScalarField
177                 (
178                     svf.component(vector::Y)
179                 );
181             // Z component
182             surfFieldPtrs[nSurfFields+2] =
183                 new surfaceScalarField
184                 (
185                     svf.component(vector::Z)
186                 );
187         }
189         fieldName = getFieldViewName(fieldName);
191         surfFieldNames[nSurfFields]   = fieldName + ("x;" + fieldName);
192         surfFieldNames[nSurfFields+1] = fieldName + "y";
193         surfFieldNames[nSurfFields+2] = fieldName + "z";
195         nSurfFields += 3;
196     }