vtkPV4FoamVolFields.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 InClass
25  vtkPV4Foam
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #ifndef vtkPV4FoamVolFields_H
30 #define vtkPV4FoamVolFields_H
31 
32 // OpenFOAM includes
33 #include "emptyFvPatchField.H"
34 #include "wallPolyPatch.H"
35 #include "faceSet.H"
36 #include "volPointInterpolation.H"
38 
39 #include "vtkPV4FoamFaceField.H"
40 #include "vtkPV4FoamPatchField.H"
41 
42 #include "vtkOpenFOAMTupleRemap.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 template<class Type>
48 (
51  const bool interpFields,
52  vtkMultiBlockDataSet* output
53 )
54 {
55  const fvMesh& mesh = tf.mesh();
56  const polyBoundaryMesh& patches = mesh.boundaryMesh();
57 
58  // Interpolated field (demand driven)
60  if (interpFields)
61  {
62  if (debug)
63  {
64  Info<< "convertVolFieldBlock interpolating:" << tf.name()
65  << endl;
66  }
67 
68  ptfPtr.reset
69  (
71  );
72  }
73 
74 
75  // Convert activated internalMesh regions
76  convertVolFieldBlock
77  (
78  tf,
79  ptfPtr,
80  output,
81  arrayRangeVolume_,
82  regionPolyDecomp_
83  );
84 
85  // Convert activated cellZones
86  convertVolFieldBlock
87  (
88  tf,
89  ptfPtr,
90  output,
91  arrayRangeCellZones_,
92  zonePolyDecomp_
93  );
94 
95  // Convert activated cellSets
96  convertVolFieldBlock
97  (
98  tf,
99  ptfPtr,
100  output,
101  arrayRangeCellSets_,
102  csetPolyDecomp_
103  );
104 
105 
106  //
107  // Convert patches - if activated
108  //
109  for
110  (
111  int partId = arrayRangePatches_.start();
112  partId < arrayRangePatches_.end();
113  ++partId
114  )
115  {
116  const word patchName = getPartName(partId);
117  const label datasetNo = partDataset_[partId];
118  const label patchId = patches.findPatchID(patchName);
119 
120  if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
121  {
122  continue;
123  }
124 
125  const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
126 
127  if
128  (
130  ||
131  (
132  reader_->GetExtrapolatePatches()
133  && !polyPatch::constraintType(patches[patchId].type())
134  )
135  )
136  {
137  fvPatch p(ptf.patch().patch(), mesh.boundary());
138 
139  tmp<Field<Type> > tpptf
140  (
141  fvPatchField<Type>(p, tf).patchInternalField()
142  );
143 
144  convertPatchField
145  (
146  tf.name(),
147  tpptf(),
148  output,
149  arrayRangePatches_,
150  datasetNo
151  );
152 
153  if (interpFields)
154  {
155  convertPatchPointField
156  (
157  tf.name(),
158  ppInterpList[patchId].faceToPointInterpolate(tpptf)(),
159  output,
160  arrayRangePatches_,
161  datasetNo
162  );
163  }
164  }
165  else
166  {
167  convertPatchField
168  (
169  tf.name(),
170  ptf,
171  output,
172  arrayRangePatches_,
173  datasetNo
174  );
175 
176  if (interpFields)
177  {
178  convertPatchPointField
179  (
180  tf.name(),
181  ppInterpList[patchId].faceToPointInterpolate(ptf)(),
182  output,
183  arrayRangePatches_,
184  datasetNo
185  );
186  }
187  }
188  }
189 
190  //
191  // Convert face zones - if activated
192  //
193  for
194  (
195  int partId = arrayRangeFaceZones_.start();
196  partId < arrayRangeFaceZones_.end();
197  ++partId
198  )
199  {
200  const word zoneName = getPartName(partId);
201  const label datasetNo = partDataset_[partId];
202 
203  if (!partStatus_[partId] || datasetNo < 0)
204  {
205  continue;
206  }
207 
208  const faceZoneMesh& zMesh = mesh.faceZones();
209  const label zoneId = zMesh.findZoneID(zoneName);
210 
211  if (zoneId < 0)
212  {
213  continue;
214  }
215 
216  convertFaceField
217  (
218  tf,
219  output,
220  arrayRangeFaceZones_,
221  datasetNo,
222  mesh,
223  zMesh[zoneId]
224  );
225 
226  // TODO: points
227  }
228 
229  //
230  // Convert face sets - if activated
231  //
232  for
233  (
234  int partId = arrayRangeFaceSets_.start();
235  partId < arrayRangeFaceSets_.end();
236  ++partId
237  )
238  {
239  const word selectName = getPartName(partId);
240  const label datasetNo = partDataset_[partId];
241 
242  if (!partStatus_[partId] || datasetNo < 0)
243  {
244  continue;
245  }
246 
247  const faceSet fSet(mesh, selectName);
248 
249  convertFaceField
250  (
251  tf,
252  output,
253  arrayRangeFaceSets_,
254  datasetNo,
255  mesh,
256  fSet.toc()
257  );
258 
259  // TODO: points
260  }
261 }
262 
263 
264 template<class Type>
266 (
267  const fvMesh& mesh,
269  const IOobjectList& objects,
270  const bool interpFields,
271  vtkMultiBlockDataSet* output
272 )
273 {
274  forAllConstIter(IOobjectList, objects, iter)
275  {
276  // restrict to GeometricField<Type, ...>
277  if
278  (
279  iter()->headerClassName()
281  )
282  {
283  continue;
284  }
285 
286  // Load field
288  (
289  *iter(),
290  mesh
291  );
292 
293  // Convert
294  convertVolField(ppInterpList, tf, interpFields, output);
295  }
296 }
297 
298 
299 template<class Type>
301 (
302  const fvMesh& mesh,
304  const IOobjectList& objects,
305  const bool interpFields,
306  vtkMultiBlockDataSet* output
307 )
308 {
309  forAllConstIter(IOobjectList, objects, iter)
310  {
311  // restrict to DimensionedField<Type, ...>
312  if
313  (
314  iter()->headerClassName()
316  )
317  {
318  continue;
319  }
320 
321  // Load field
322  DimensionedField<Type, volMesh> dimFld(*iter(), mesh);
323 
324 
325  // Construct volField with zero-gradient patch fields
326 
327  IOobject io(dimFld);
328  io.readOpt() = IOobject::NO_READ;
329 
330  PtrList<fvPatchField<Type> > patchFields(mesh.boundary().size());
331  forAll(patchFields, patchI)
332  {
333  patchFields.set
334  (
335  patchI,
337  (
339  mesh.boundary()[patchI],
340  dimFld
341  )
342  );
343  }
344 
346  (
347  io,
348  dimFld.mesh(),
349  dimFld.dimensions(),
350  dimFld,
351  patchFields
352  );
353  volFld.correctBoundaryConditions();
354 
355  convertVolField(ppInterpList, volFld, interpFields, output);
356  }
357 }
358 
359 
360 template<class Type>
362 (
365  vtkMultiBlockDataSet* output,
366  const arrayRange& range,
367  const List<polyDecomp>& decompLst
368 )
369 {
370  for (int partId = range.start(); partId < range.end(); ++partId)
371  {
372  const label datasetNo = partDataset_[partId];
373 
374  if (datasetNo >= 0 && partStatus_[partId])
375  {
376  convertVolField
377  (
378  tf,
379  output,
380  range,
381  datasetNo,
382  decompLst[datasetNo]
383  );
384 
385  if (ptfPtr.valid())
386  {
387  convertPointField
388  (
389  ptfPtr(),
390  tf,
391  output,
392  range,
393  datasetNo,
394  decompLst[datasetNo]
395  );
396  }
397  }
398  }
399 }
400 
401 
402 template<class Type>
404 (
406  vtkMultiBlockDataSet* output,
407  const arrayRange& range,
408  const label datasetNo,
409  const polyDecomp& decompInfo
410 )
411 {
412  const label nComp = pTraits<Type>::nComponents;
413  const labelList& superCells = decompInfo.superCells();
414 
415  vtkFloatArray* celldata = vtkFloatArray::New();
416  celldata->SetNumberOfTuples(superCells.size());
417  celldata->SetNumberOfComponents(nComp);
418  celldata->Allocate(nComp*superCells.size());
419  celldata->SetName(tf.name().c_str());
420 
421  if (debug)
422  {
423  Info<< "convert volField: "
424  << tf.name()
425  << " size = " << tf.size()
426  << " nComp=" << nComp
427  << " nTuples = " << superCells.size() << endl;
428  }
429 
430  float vec[nComp];
431  forAll(superCells, i)
432  {
433  const Type& t = tf[superCells[i]];
434  for (direction d=0; d<nComp; ++d)
435  {
436  vec[d] = component(t, d);
437  }
438  vtkOpenFOAMTupleRemap<Type>(vec);
439 
440  celldata->InsertTuple(i, vec);
441  }
442 
443  vtkUnstructuredGrid::SafeDownCast
444  (
445  GetDataSetFromBlock(output, range, datasetNo)
446  ) ->GetCellData()
447  ->AddArray(celldata);
448 
449  celldata->Delete();
450 }
451 
452 
453 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
454 
455 #endif
456 
457 // ************************************************************************* //
Foam::fvPatchField< Type >
vtkPV4FoamPatchField.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::vtkPV4Foam::arrayRange
Bookkeeping for GUI checklists and the multi-block organization.
Definition: vtkPV4Foam.H:112
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:41
Foam::vtkPV4Foam::polyDecomp
Bookkeeping for polyhedral cell decomposition.
Definition: vtkPV4Foam.H:188
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::HashTable::toc
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:201
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::vtkPV4Foam::convertVolFieldBlock
void convertVolFieldBlock(const GeometricField< Type, fvPatchField, volMesh > &, autoPtr< GeometricField< Type, pointPatchField, pointMesh > > &, vtkMultiBlockDataSet *output, const arrayRange &, const List< polyDecomp > &decompLst)
Volume field - all selected parts.
Definition: vtkPV4FoamVolFields.H:362
wallPolyPatch.H
Foam::MULES::interpolate
tmp< surfaceScalarField > interpolate(const RhoType &rho)
Definition: IMULESTemplates.C:40
Foam::faceSet
A list of face labels.
Definition: faceSet.H:48
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
zeroGradientFvPatchField.H
Foam::zeroGradientFvPatchField
This boundary condition applies a zero-gradient condition from the patch internal field onto the patc...
Definition: zeroGradientFvPatchField.H:63
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
tf
const tensorField & tf
Definition: getPatchFieldTensor.H:36
Foam::PtrList::set
bool set(const label) const
Is element set.
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::DimensionedField::mesh
const Mesh & mesh() const
Return mesh.
Definition: DimensionedFieldI.H:38
Foam::IOobject::readOpt
readOption readOpt() const
Definition: IOobject.H:317
Foam::Info
messageStream Info
faceSet.H
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::ZoneMesh< faceZone, polyMesh >
Foam::vtkPV4Foam::convertVolField
void convertVolField(const PtrList< PrimitivePatchInterpolation< primitivePatch > > &, const GeometricField< Type, fvPatchField, volMesh > &, const bool interpFields, vtkMultiBlockDataSet *output)
Volume field - all types.
Definition: vtkPV4FoamVolFields.H:48
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::emptyFvPatchField
This boundary condition provides an 'empty' condition for reduced dimensions cases,...
Definition: emptyFvPatchField.H:66
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::ZoneMesh::findZoneID
label findZoneID(const word &zoneName) const
Find zone index given a name.
Definition: ZoneMesh.C:348
Foam::DimensionedField::dimensions
const dimensionSet & dimensions() const
Return dimensions.
Definition: DimensionedFieldI.H:46
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
Foam::vtkPV4Foam::convertDimFields
void convertDimFields(const fvMesh &, const PtrList< PrimitivePatchInterpolation< primitivePatch > > &, const IOobjectList &, const bool interpFields, vtkMultiBlockDataSet *output)
Volume internal fields (DimensionedField)- all types.
Definition: vtkPV4FoamVolFields.H:301
Foam::vtkPV4Foam::polyDecomp::superCells
labelList & superCells()
Label of original cell for decomposed cells.
Definition: vtkPV4Foam.H:200
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:885
Foam::isType
bool isType(const Type &t)
Check the typeid.
Definition: typeInfo.H:126
volPointInterpolation.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
emptyFvPatchField.H
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::PrimitivePatchInterpolation
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
Definition: PrimitivePatchInterpolation.H:51
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::direction
unsigned char direction
Definition: direction.H:43
vtkPV4FoamFaceField.H
Foam::fvPatch::patch
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:143
Foam::vtkPV3Readers::GetDataSetFromBlock
vtkDataSet * GetDataSetFromBlock(vtkMultiBlockDataSet *output, const partInfo &selector, const label datasetNo)
Convenience method use to convert the readers from VTK 5.
Definition: vtkPV3Readers.C:140
Foam::autoPtr::reset
void reset(T *=0)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
patches
patches[0]
Definition: createSingleCellMesh.H:36
patchId
label patchId(-1)
Foam::fvPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:300
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::vtkPV4Foam::convertVolFields
void convertVolFields(vtkMultiBlockDataSet *)
Convert volume fields.
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
vtkOpenFOAMTupleRemap.H