vtkPV3FoamFaceField.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 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  vtkPV3Foam
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #ifndef vtkPV3FoamFaceField_H
30 #define vtkPV3FoamFaceField_H
31 
32 // VTK includes
33 #include "vtkCellData.h"
34 #include "vtkFloatArray.h"
35 #include "vtkMultiBlockDataSet.h"
36 #include "vtkPolyData.h"
37 
38 #include "vtkOpenFOAMTupleRemap.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 template<class Type>
44 (
46  vtkMultiBlockDataSet* output,
47  const arrayRange& range,
48  const label datasetNo,
49  const fvMesh& mesh,
50  const labelList& faceLabels
51 )
52 {
53  const label nComp = pTraits<Type>::nComponents;
54  const label nInternalFaces = mesh.nInternalFaces();
55  const labelList& faceOwner = mesh.faceOwner();
56  const labelList& faceNeigh = mesh.faceNeighbour();
57 
58  vtkFloatArray* cellData = vtkFloatArray::New();
59  cellData->SetNumberOfTuples(faceLabels.size());
60  cellData->SetNumberOfComponents(nComp);
61  cellData->Allocate(nComp*faceLabels.size());
62  cellData->SetName(tf.name().c_str());
63 
64  if (debug)
65  {
66  Info<< "convert convertFaceField: "
67  << tf.name()
68  << " size = " << tf.size()
69  << " nComp=" << nComp
70  << " nTuples = " << faceLabels.size() << endl;
71  }
72 
73  float vec[nComp];
74 
75  // for interior faces: average owner/neighbour
76  // for boundary faces: owner
77  forAll(faceLabels, faceI)
78  {
79  const label faceNo = faceLabels[faceI];
80  if (faceNo < nInternalFaces)
81  {
82  Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
83 
84  for (direction d=0; d<nComp; ++d)
85  {
86  vec[d] = component(t, d);
87  }
88  }
89  else
90  {
91  const Type& t = tf[faceOwner[faceNo]];
92  for (direction d=0; d<nComp; ++d)
93  {
94  vec[d] = component(t, d);
95  }
96  }
97  vtkOpenFOAMTupleRemap<Type>(vec);
98 
99  cellData->InsertTuple(faceI, vec);
100  }
101 
102 
103  vtkPolyData::SafeDownCast
104  (
105  GetDataSetFromBlock(output, range, datasetNo)
106  ) ->GetCellData()
107  ->AddArray(cellData);
108 
109  cellData->Delete();
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 #endif
116 
117 // ************************************************************************* //
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::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
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
vtkOpenFOAMTupleRemap.H
Foam::vtkPV3Foam::convertFaceField
void convertFaceField(const GeometricField< Type, fvPatchField, volMesh > &, vtkMultiBlockDataSet *output, const arrayRange &, const label datasetNo, const fvMesh &, const labelList &faceLabels)
Face set/zone field.
Definition: vtkPV3FoamFaceField.H:44
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
tf
const tensorField & tf
Definition: getPatchFieldTensor.H:36
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::Info
messageStream Info
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::vtkPV3Foam::arrayRange
Bookkeeping for GUI checklists and the multi-block organization.
Definition: vtkPV3Foam.H:112
range
scalar range
Definition: LISASMDCalcMethod1.H:12
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
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::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52