1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
27 \*---------------------------------------------------------------------------*/
29 #include "vtkPV3Foam.H"
32 #include "IOobjectList.H"
33 #include "vtkPV3FoamReader.h"
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
59 // only keep selected fields
60 forAllIter(IOobjectList, objects, iter)
62 if (!selected.found(iter()->name()))
70 void Foam::vtkPV3Foam::convertVolFields
72 vtkMultiBlockDataSet* output
75 const fvMesh& mesh = *meshPtr_;
77 wordHashSet selectedFields = getSelected
79 reader_->GetVolFieldSelection()
82 if (!selectedFields.size())
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);
99 Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
100 << "converting Foam volume fields" << endl;
101 forAllConstIter(IOobjectList, objects, iter)
103 Info<< " " << iter()->name()
104 << " == " << iter()->objectPath() << nl;
110 PtrList<PrimitivePatchInterpolation<primitivePatch> >
111 ppInterpList(mesh.boundaryMesh().size());
113 forAll(ppInterpList, i)
118 new PrimitivePatchInterpolation<primitivePatch>
120 mesh.boundaryMesh()[i]
126 convertVolFields<scalar>
128 mesh, ppInterpList, objects, output
130 convertVolFields<vector>
132 mesh, ppInterpList, objects, output
134 convertVolFields<sphericalTensor>
136 mesh, ppInterpList, objects, output
138 convertVolFields<symmTensor>
140 mesh, ppInterpList, objects, output
142 convertVolFields<tensor>
144 mesh, ppInterpList, objects, output
149 Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
155 void Foam::vtkPV3Foam::convertPointFields
157 vtkMultiBlockDataSet* output
160 const fvMesh& mesh = *meshPtr_;
162 wordHashSet selectedFields = getSelected
164 reader_->GetPointFieldSelection()
167 if (!selectedFields.size())
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);
184 Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
185 << "converting Foam volume fields" << endl;
186 forAllConstIter(IOobjectList, objects, iter)
188 Info<< " " << iter()->name()
189 << " == " << iter()->objectPath() << nl;
194 // Construct interpolation on the raw mesh
195 pointMesh pMesh(mesh);
198 convertPointFields<scalar>
200 mesh, pMesh, objects, output
202 convertPointFields<vector>
204 mesh, pMesh, objects, output
206 convertPointFields<sphericalTensor>
208 mesh, pMesh, objects, output
210 convertPointFields<symmTensor>
212 mesh, pMesh, objects, output
214 convertPointFields<tensor>
216 mesh, pMesh, objects, output
221 Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
227 void Foam::vtkPV3Foam::convertLagrangianFields
229 vtkMultiBlockDataSet* output
232 partInfo& selector = partInfoLagrangian_;
233 const fvMesh& mesh = *meshPtr_;
235 wordHashSet selectedFields = getSelected
237 reader_->GetLagrangianFieldSelection()
240 if (!selectedFields.size())
247 Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
251 for (int partId = selector.start(); partId < selector.end(); ++partId)
253 const word cloudName = getPartName(partId);
254 const label datasetNo = partDataset_[partId];
256 if (!partStatus_[partId] || datasetNo < 0)
262 // Get the Lagrangian fields for this time and this cloud
263 // but only keep selected fields
264 // the region name is already in the mesh db
269 cloud::prefix/cloudName
271 pruneObjectList(objects, selectedFields);
280 Info<< "converting Foam lagrangian fields" << nl;
281 forAllConstIter(IOobjectList, objects, iter)
283 Info<< " " << iter()->name()
284 << " == " << iter()->objectPath() << nl;
288 convertLagrangianFields<label>
290 objects, output, datasetNo
292 convertLagrangianFields<scalar>
294 objects, output, datasetNo
296 convertLagrangianFields<vector>
298 objects, output, datasetNo
300 convertLagrangianFields<sphericalTensor>
302 objects, output, datasetNo
304 convertLagrangianFields<symmTensor>
306 objects, output, datasetNo
308 convertLagrangianFields<tensor>
310 objects, output, datasetNo
316 Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
322 // ************************************************************************* //