BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / postProcessing / graphics / PV3FoamReader / vtkPV3Foam / vtkPV3FoamFields.C
blob24acb3d5111734940f5f15da746683dd9349c234
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "vtkPV3Foam.H"
31 // Foam includes
32 #include "IOobjectList.H"
33 #include "vtkPV3FoamReader.h"
35 // VTK includes
36 #include "vtkDataArraySelection.h"
37 #include "vtkPolyData.h"
38 #include "vtkUnstructuredGrid.h"
40 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
42 #include "vtkPV3FoamVolFields.H"
43 #include "vtkPV3FoamPointFields.H"
44 #include "vtkPV3FoamLagrangianFields.H"
47 void Foam::vtkPV3Foam::pruneObjectList
49     IOobjectList& objects,
50     const wordHashSet& selected
53     // hash all the selected field names
54     if (!selected.size())
55     {
56         objects.clear();
57     }
59     // only keep selected fields
60     forAllIter(IOobjectList, objects, iter)
61     {
62         if (!selected.found(iter()->name()))
63         {
64             objects.erase(iter);
65         }
66     }
70 void Foam::vtkPV3Foam::convertVolFields
72     vtkMultiBlockDataSet* output
75     const fvMesh& mesh = *meshPtr_;
77     wordHashSet selectedFields = getSelected
78     (
79         reader_->GetVolFieldSelection()
80     );
82     if (!selectedFields.size())
83     {
84         return;
85     }
87     // Get objects (fields) for this time - only keep selected fields
88     // the region name is already in the mesh db
89     IOobjectList objects(mesh, dbPtr_().timeName());
90     pruneObjectList(objects, selectedFields);
92     if (!objects.size())
93     {
94         return;
95     }
97     if (debug)
98     {
99         Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
100             << "converting Foam volume fields" << endl;
101         forAllConstIter(IOobjectList, objects, iter)
102         {
103             Info<< "  " << iter()->name()
104                 << " == " << iter()->objectPath() << nl;
105         }
106         printMemory();
107     }
110     PtrList<PrimitivePatchInterpolation<primitivePatch> >
111         ppInterpList(mesh.boundaryMesh().size());
113     forAll(ppInterpList, i)
114     {
115         ppInterpList.set
116         (
117             i,
118             new PrimitivePatchInterpolation<primitivePatch>
119             (
120                 mesh.boundaryMesh()[i]
121             )
122         );
123     }
126     convertVolFields<scalar>
127     (
128         mesh, ppInterpList, objects, output
129     );
130     convertVolFields<vector>
131     (
132         mesh, ppInterpList, objects, output
133     );
134     convertVolFields<sphericalTensor>
135     (
136         mesh, ppInterpList, objects, output
137     );
138     convertVolFields<symmTensor>
139     (
140         mesh, ppInterpList, objects, output
141     );
142     convertVolFields<tensor>
143     (
144         mesh, ppInterpList, objects, output
145     );
147     if (debug)
148     {
149         Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
150         printMemory();
151     }
155 void Foam::vtkPV3Foam::convertPointFields
157     vtkMultiBlockDataSet* output
160     const fvMesh& mesh = *meshPtr_;
162     wordHashSet selectedFields = getSelected
163     (
164         reader_->GetPointFieldSelection()
165     );
167     if (!selectedFields.size())
168     {
169         return;
170     }
172     // Get objects (fields) for this time - only keep selected fields
173     // the region name is already in the mesh db
174     IOobjectList objects(mesh, dbPtr_().timeName());
175     pruneObjectList(objects, selectedFields);
177     if (!objects.size())
178     {
179         return;
180     }
182     if (debug)
183     {
184         Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
185             << "converting Foam volume fields" << endl;
186         forAllConstIter(IOobjectList, objects, iter)
187         {
188             Info<< "  " << iter()->name()
189                 << " == " << iter()->objectPath() << nl;
190         }
191         printMemory();
192     }
194     // Construct interpolation on the raw mesh
196     // HJ, bug fix?  Point mesh handled by objectRegistry
197     // HJ, 11/Nov/2010
198     const pointMesh& pMesh = pointMesh::New(mesh);
199 //     pointMesh pMesh(mesh);
202     convertPointFields<scalar>
203     (
204         mesh, pMesh, objects, output
205     );
206     convertPointFields<vector>
207     (
208         mesh, pMesh, objects, output
209     );
210     convertPointFields<sphericalTensor>
211     (
212         mesh, pMesh, objects, output
213     );
214     convertPointFields<symmTensor>
215     (
216         mesh, pMesh, objects, output
217     );
218     convertPointFields<tensor>
219     (
220         mesh, pMesh, objects, output
221     );
223     if (debug)
224     {
225         Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
226         printMemory();
227     }
231 void Foam::vtkPV3Foam::convertLagrangianFields
233     vtkMultiBlockDataSet* output
236     partInfo& selector = partInfoLagrangian_;
237     const fvMesh& mesh = *meshPtr_;
239     wordHashSet selectedFields = getSelected
240     (
241         reader_->GetLagrangianFieldSelection()
242     );
244     if (!selectedFields.size())
245     {
246         return;
247     }
249     if (debug)
250     {
251         Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
252         printMemory();
253     }
255     for (int partId = selector.start(); partId < selector.end(); ++partId)
256     {
257         const word  cloudName = getPartName(partId);
258         const label datasetNo = partDataset_[partId];
260         if (!partStatus_[partId] || datasetNo < 0)
261         {
262             continue;
263         }
266         // Get the Lagrangian fields for this time and this cloud
267         // but only keep selected fields
268         // the region name is already in the mesh db
269         IOobjectList objects
270         (
271             mesh,
272             dbPtr_().timeName(),
273             cloud::prefix/cloudName
274         );
275         pruneObjectList(objects, selectedFields);
277         if (!objects.size())
278         {
279             continue;
280         }
282         if (debug)
283         {
284             Info<< "converting Foam lagrangian fields" << nl;
285             forAllConstIter(IOobjectList, objects, iter)
286             {
287                 Info<< "  " << iter()->name()
288                     << " == " << iter()->objectPath() << nl;
289             }
290         }
292         convertLagrangianFields<label>
293         (
294             objects, output, datasetNo
295         );
296         convertLagrangianFields<scalar>
297         (
298             objects, output, datasetNo
299         );
300         convertLagrangianFields<vector>
301         (
302             objects, output, datasetNo
303         );
304         convertLagrangianFields<sphericalTensor>
305         (
306             objects, output, datasetNo
307         );
308         convertLagrangianFields<symmTensor>
309         (
310             objects, output, datasetNo
311         );
312         convertLagrangianFields<tensor>
313         (
314             objects, output, datasetNo
315         );
316     }
318     if (debug)
319     {
320         Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
321         printMemory();
322     }
326 // ************************************************************************* //