1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
28 \*---------------------------------------------------------------------------*/
30 #ifndef vtkPV3FoamPointFields_H
31 #define vtkPV3FoamPointFields_H
34 #include "interpolatePointToCell.H"
36 #include "vtkOpenFOAMTupleRemap.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 void Foam::vtkPV3Foam::convertPointFields
44 const pointMesh& pMesh,
45 const IOobjectList& objects,
46 vtkMultiBlockDataSet* output
49 const polyBoundaryMesh& patches = mesh.boundaryMesh();
51 forAllConstIter(IOobjectList, objects, iter)
53 const word& fieldName = iter()->name();
54 // restrict to this GeometricField<Type, ...>
57 iter()->headerClassName()
58 != GeometricField<Type, pointPatchField, pointMesh>::typeName
66 Info<< "Foam::vtkPV3Foam::convertPointFields : "
70 GeometricField<Type, pointPatchField, pointMesh> ptf
77 // Convert activated internalMesh regions
78 convertPointFieldBlock
86 // Convert activated cellZones
87 convertPointFieldBlock
95 // Convert activated cellSets
96 convertPointFieldBlock
106 // Convert patches - if activated
110 int partId = partInfoPatches_.start();
111 partId < partInfoPatches_.end();
115 const word patchName = getPartName(partId);
116 const label datasetNo = partDataset_[partId];
117 const label patchId = patches.findPatchID(patchName);
119 if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
124 convertPatchPointField
127 ptf.boundaryField()[patchId].patchInternalField()(),
138 void Foam::vtkPV3Foam::convertPointFieldBlock
140 const GeometricField<Type, pointPatchField, pointMesh>& ptf,
141 vtkMultiBlockDataSet* output,
142 const partInfo& selector,
143 const List<polyDecomp>& decompLst
146 for (int partId = selector.start(); partId < selector.end(); ++partId)
148 const label datasetNo = partDataset_[partId];
150 if (datasetNo >= 0 && partStatus_[partId])
155 GeometricField<Type, fvPatchField, volMesh>::null(),
167 void Foam::vtkPV3Foam::convertPointField
169 const GeometricField<Type, pointPatchField, pointMesh>& ptf,
170 const GeometricField<Type, fvPatchField, volMesh>& tf,
171 vtkMultiBlockDataSet* output,
172 const partInfo& selector,
173 const label datasetNo,
174 const polyDecomp& decomp
177 const label nComp = pTraits<Type>::nComponents;
178 const labelList& addPointCellLabels = decomp.addPointCellLabels();
179 const labelList& pointMap = decomp.pointMap();
181 // use a pointMap or address directly into mesh
185 nPoints = pointMap.size();
189 nPoints = ptf.size();
192 vtkFloatArray *pointData = vtkFloatArray::New();
193 pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
194 pointData->SetNumberOfComponents(nComp);
195 pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
196 pointData->SetName(ptf.name().c_str());
200 Info<< "convert convertPointField: "
202 << " size = " << nPoints
203 << " nComp=" << nComp
204 << " nTuples = " << (nPoints + addPointCellLabels.size())
214 const Type& t = ptf[pointMap[i]];
215 for (direction d=0; d<nComp; d++)
217 vec[d] = component(t, d);
219 vtkOpenFOAMTupleRemap<Type>(vec);
221 pointData->InsertTuple(i, vec);
228 const Type& t = ptf[i];
229 for (direction d=0; d<nComp; d++)
231 vec[d] = component(t, d);
233 vtkOpenFOAMTupleRemap<Type>(vec);
235 pointData->InsertTuple(i, vec);
239 // continue insertion from here
242 if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
244 forAll(addPointCellLabels, apI)
246 const Type& t = tf[addPointCellLabels[apI]];
247 for (direction d=0; d<nComp; d++)
249 vec[d] = component(t, d);
251 vtkOpenFOAMTupleRemap<Type>(vec);
253 pointData->InsertTuple(i++, vec);
258 forAll(addPointCellLabels, apI)
260 Type t = interpolatePointToCell(ptf, addPointCellLabels[apI]);
261 for (direction d=0; d<nComp; d++)
263 vec[d] = component(t, d);
265 vtkOpenFOAMTupleRemap<Type>(vec);
267 pointData->InsertTuple(i++, vec);
271 vtkUnstructuredGrid::SafeDownCast
273 GetDataSetFromBlock(output, selector, datasetNo)
275 ->AddArray(pointData);
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 // ************************************************************************* //