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 vtkPV3FoamVolFields_H
31 #define vtkPV3FoamVolFields_H
34 #include "emptyFvPatchField.H"
35 #include "wallPolyPatch.H"
37 #include "volPointInterpolation.H"
39 #include "vtkPV3FoamFaceField.H"
40 #include "vtkPV3FoamPatchField.H"
42 #include "vtkOpenFOAMTupleRemap.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 void Foam::vtkPV3Foam::convertVolFields
50 const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList,
51 const IOobjectList& objects,
52 vtkMultiBlockDataSet* output
55 const polyBoundaryMesh& patches = mesh.boundaryMesh();
57 forAllConstIter(IOobjectList, objects, iter)
59 // restrict to GeometricField<Type, ...>
62 iter()->headerClassName()
63 != GeometricField<Type, fvPatchField, volMesh>::typeName
70 GeometricField<Type, fvPatchField, volMesh> tf
76 // Interpolated field (demand driven)
77 autoPtr<GeometricField<Type, pointPatchField, pointMesh> > ptfPtr;
80 // Convert activated internalMesh regions
90 // Convert activated cellZones
100 // Convert activated cellSets
112 // Convert patches - if activated
115 // The name for the interpolated patch point field must be consistent
116 // with the interpolated volume point field.
117 // This could be done better.
118 const word pointFldName = "volPointInterpolate(" + tf.name() + ')';
122 int partId = partInfoPatches_.start();
123 partId < partInfoPatches_.end();
127 const word patchName = getPartName(partId);
128 const label datasetNo = partDataset_[partId];
129 const label patchId = patches.findPatchID(patchName);
131 if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
136 const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
140 isType<emptyFvPatchField<Type> >(ptf)
143 reader_->GetExtrapolatePatches()
144 && !polyPatch::constraintType(patches[patchId].type())
148 fvPatch p(ptf.patch().patch(), tf.mesh().boundary());
150 tmp<Field<Type> > tpptf
152 fvPatchField<Type>(p, tf).patchInternalField()
164 convertPatchPointField
167 ppInterpList[patchId].faceToPointInterpolate(tpptf)(),
184 convertPatchPointField
187 ppInterpList[patchId].faceToPointInterpolate(ptf)(),
196 // Convert face zones - if activated
200 int partId = partInfoFaceZones_.start();
201 partId < partInfoFaceZones_.end();
205 const word zoneName = getPartName(partId);
206 const label datasetNo = partDataset_[partId];
208 if (!partStatus_[partId] || datasetNo < 0)
213 const faceZoneMesh& zMesh = mesh.faceZones();
214 const label zoneId = zMesh.findZoneID(zoneName);
235 // Convert face sets - if activated
239 int partId = partInfoFaceSets_.start();
240 partId < partInfoFaceSets_.end();
244 const word selectName = getPartName(partId);
245 const label datasetNo = partDataset_[partId];
247 if (!partStatus_[partId] || datasetNo < 0)
252 const faceSet fSet(mesh, selectName);
271 void Foam::vtkPV3Foam::convertVolFieldBlock
273 const GeometricField<Type, fvPatchField, volMesh>& tf,
274 autoPtr<GeometricField<Type, pointPatchField, pointMesh> >& ptfPtr,
275 vtkMultiBlockDataSet* output,
276 const partInfo& selector,
277 const List<polyDecomp>& decompLst
280 for (int partId = selector.start(); partId < selector.end(); ++partId)
282 const label datasetNo = partDataset_[partId];
284 if (datasetNo >= 0 && partStatus_[partId])
299 Info<< "convertVolFieldBlock interpolating:" << tf.name()
305 volPointInterpolation::New(tf.mesh()).interpolate(tf).ptr()
324 void Foam::vtkPV3Foam::convertVolField
326 const GeometricField<Type, fvPatchField, volMesh>& tf,
327 vtkMultiBlockDataSet* output,
328 const partInfo& selector,
329 const label datasetNo,
330 const polyDecomp& decompInfo
333 const label nComp = pTraits<Type>::nComponents;
334 const labelList& superCells = decompInfo.superCells();
336 vtkFloatArray* celldata = vtkFloatArray::New();
337 celldata->SetNumberOfTuples(superCells.size());
338 celldata->SetNumberOfComponents(nComp);
339 celldata->Allocate(nComp*superCells.size());
340 celldata->SetName(tf.name().c_str());
344 Info<< "convert volField: "
346 << " size = " << tf.size()
347 << " nComp=" << nComp
348 << " nTuples = " << superCells.size() << endl;
352 forAll(superCells, i)
354 const Type& t = tf[superCells[i]];
355 for (direction d=0; d<nComp; d++)
357 vec[d] = component(t, d);
359 vtkOpenFOAMTupleRemap<Type>(vec);
361 celldata->InsertTuple(i, vec);
364 vtkUnstructuredGrid::SafeDownCast
366 GetDataSetFromBlock(output, selector, datasetNo)
368 ->AddArray(celldata);
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378 // ************************************************************************* //